How to use the instaloader.structures.Profile.from_id function in instaloader

To help you get started, we’ve selected a few instaloader examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github cad0p / maskrcnn-modanet / maskrcnn_modanet / instagram_impl.py View on Github external
with suppress(ProfileNotExistsException):
			profile = ProfileURL.from_username(self.context, profile_name)
		profile_exists = profile is not None
		id_filename = self._get_id_filename(profile_name)
		try:
			with open(id_filename, 'rb') as id_file:
				profile_id = int(id_file.read())
			if (not profile_exists) or \
					(profile_id != profile.userid):
				if profile_exists:
					self.context.log("Profile {0} does not match the stored unique ID {1}.".format(profile_name,
																								   profile_id))
				else:
					self.context.log("Trying to find profile {0} using its unique ID {1}.".format(profile_name,
																								  profile_id))
				profile_from_id = Profile.from_id(self.context, profile_id)
				newname = profile_from_id.username
				self.context.log("Profile {0} has changed its name to {1}.".format(profile_name, newname))
				if ((format_string_contains_key(self.dirname_pattern, 'profile') or
					 format_string_contains_key(self.dirname_pattern, 'target'))):
					os.rename(self.dirname_pattern.format(profile=profile_name.lower(),
														  target=profile_name.lower()),
							  self.dirname_pattern.format(profile=newname.lower(),
														  target=newname.lower()))
				else:
					os.rename('{0}/{1}_id'.format(self.dirname_pattern.format(), profile_name.lower()),
							  '{0}/{1}_id'.format(self.dirname_pattern.format(), newname.lower()))
				return profile_from_id
			return profile
		except (FileNotFoundError, ValueError):
			pass
		if profile_exists:
github instaloader / instaloader / instaloader / instaloader.py View on Github external
profile = Profile.from_username(self.context, profile_name)
        except ProfileNotExistsException as err:
            profile_name_not_exists_err = err
        id_filename = self._get_id_filename(profile_name)
        try:
            with open(id_filename, 'rb') as id_file:
                profile_id = int(id_file.read())
            if (profile is None) or \
                    (profile_id != profile.userid):
                if profile is not None:
                    self.context.log("Profile {0} does not match the stored unique ID {1}.".format(profile_name,
                                                                                                   profile_id))
                else:
                    self.context.log("Trying to find profile {0} using its unique ID {1}.".format(profile_name,
                                                                                                  profile_id))
                profile_from_id = Profile.from_id(self.context, profile_id)
                newname = profile_from_id.username
                self.context.log("Profile {0} has changed its name to {1}.".format(profile_name, newname))
                if ((format_string_contains_key(self.dirname_pattern, 'profile') or
                     format_string_contains_key(self.dirname_pattern, 'target'))):
                    os.rename(self.dirname_pattern.format(profile=profile_name.lower(),
                                                          target=profile_name.lower()),
                              self.dirname_pattern.format(profile=newname.lower(),
                                                          target=newname.lower()))
                else:
                    os.rename('{0}/{1}_id'.format(self.dirname_pattern.format(), profile_name.lower()),
                              '{0}/{1}_id'.format(self.dirname_pattern.format(), newname.lower()))
                return profile_from_id
            # profile exists and profile id matches saved id
            return profile
        except (FileNotFoundError, ValueError):
            pass
github instaloader / instaloader / instaloader / structures.py View on Github external
def owner_profile(self) -> Profile:
        """:class:`Profile` instance of the story item's owner."""
        if not self._owner_profile:
            self._owner_profile = Profile.from_id(self._context, self._node['owner']['id'])
        assert self._owner_profile is not None
        return self._owner_profile