Skip to content

Commit

Permalink
Added follows_viewer & followed_by_viewer attributes to Profile
Browse files Browse the repository at this point in the history
  • Loading branch information
davidwickerhf committed Jan 24, 2021
1 parent f24577c commit 73c84ca
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 4 deletions.
11 changes: 9 additions & 2 deletions instaclient/client/scraper.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,8 @@ def get_profile(self:'InstaClient', username:str, context:bool=True) -> Optional

# Context Based
business_email = user.get('business_email'),
followed_by_viewer = user.get('followed_by_viewer'),
follows_viewer= user.get('follows_viewer'),
blocked_by_viewer = user['blocked_by_viewer'],
restricted_by_viewer = user['restricted_by_viewer'],
has_blocked_viewer = user['has_blocked_viewer'],
Expand Down Expand Up @@ -521,6 +523,8 @@ def get_followers(self:'InstaClient', user:str, count:int, use_api:bool=True, de
name = user['full_name'],
is_private = user['is_private'],
is_verified = user['is_verified'],
follows_viewer = user['follows_viewer'],
followed_by_viewer = user['followed_by_viewer'],
requested_by_viewer = user['requested_by_viewer'],
profile_pic_url= user.get('profile_pic_url')
)
Expand Down Expand Up @@ -713,6 +717,8 @@ def get_following(self:'InstaClient', user:str, count:int, use_api:bool=True, de
name = user['full_name'],
is_private = user['is_private'],
is_verified = user['is_verified'],
follows_viewer = user['follows_viewer'],
followed_by_viewer = user['followed_by_viewer'],
requested_by_viewer = user['requested_by_viewer'],
profile_pic_url= user.get('profile_pic_url')
)
Expand Down Expand Up @@ -1057,8 +1063,9 @@ def get_search_results(self:'InstaClient', query:str) -> dict:
name=item['full_name'],
is_private=item['is_private'],
is_verified=item['is_verified'],
has_requested_viewer=friendship_status.get('incoming_request') if friendship_status else None,
requested_by_viewer=friendship_status.get('outgoing_request') if friendship_status else None,
followed_by_viewer = None if not friendship_status else friendship_status.get('is_following') ,
has_requested_viewer=None if not friendship_status else friendship_status.get('incoming_request'),
requested_by_viewer=None if not friendship_status else friendship_status.get('outgoing_request'),
profile_pic_url= item.get('profile_pic_url'),
))
except:
Expand Down
14 changes: 12 additions & 2 deletions instaclient/instagram/profile.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,12 @@ class Profile(InstaBaseObject):
and if the email is set to be public, it will be saved in this attribute.
Defaults to None.
follows_viewer (bool, optional): True if this profile follows the `viewer`.
Defaults to None.
followed_by_viewer (bool, optional): True if this profile is followed by the `viewer`.
Defaults to None.
blocked_by_viewer (bool, optional): Is true if the `viewer` is currently
blocked by this profile. Defaults to None.
Expand Down Expand Up @@ -124,8 +130,10 @@ def __init__(self,
external_url:str=None,
fb_id:str=None,
profile_pic_url:str=None,

business_email:str=None,

follows_viewer:bool=None,
followed_by_viewer:bool=None,
blocked_by_viewer:bool=None,
restricted_by_viewer:bool=None,
has_blocked_viewer:bool=None,
Expand All @@ -152,8 +160,10 @@ def __init__(self,
self.external_url = external_url
self.fb_id = fb_id
self.profile_pic_url = profile_pic_url

self.business_email = business_email

self.follows_viewer = follows_viewer
self.followed_by_viewer = followed_by_viewer
self.blocked_by_viewer = blocked_by_viewer
self.restricted_by_viewer = restricted_by_viewer
self.has_blocked_viewer = has_blocked_viewer
Expand Down
1 change: 1 addition & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
install_requires=[ # I get to this in a second
'selenium',
'urllib3',
'requests'
],
classifiers=[
'Development Status :: 5 - Production/Stable', # Chose either "3 - Alpha", "4 - Beta" or "5 - Production/Stable" as the current state of your package
Expand Down

0 comments on commit 73c84ca

Please sign in to comment.