MCPcopy
hub / github.com/InstaPy/InstaPy / get_fans

Function get_fans

instapy/relationship_tools.py:805–870  ·  view source on GitHub ↗

Find Fans of a given user

(
    browser,
    self_username,
    username,
    relationship_data,
    live_match,
    store_locally,
    logger,
    logfolder,
)

Source from the content-addressed store, hash-verified

803
804
805def get_fans(
806 browser,
807 self_username,
808 username,
809 relationship_data,
810 live_match,
811 store_locally,
812 logger,
813 logfolder,
814):
815 """Find Fans of a given user"""
816
817 if username is None or not isinstance(username, str):
818 logger.info(
819 "Please enter a username to pick Fans ~leaving out of an invalid value"
820 )
821 return []
822
823 # get `Followers` data
824 all_followers = get_followers(
825 browser,
826 self_username,
827 username,
828 "full",
829 relationship_data,
830 live_match,
831 store_locally,
832 logger,
833 logfolder,
834 )
835
836 # if all_followers is False we have targeted a private account that we don't follow
837 if not all_followers:
838 return False
839
840 # get `Following` data
841 all_following = get_following(
842 browser,
843 self_username,
844 username,
845 "full",
846 relationship_data,
847 live_match,
848 store_locally,
849 logger,
850 logfolder,
851 )
852
853 # using this approach we can preserve the order of elements to be used
854 # with `FIFO`, `LIFO` or `RANDOM` styles
855 fans = [user for user in all_followers if user not in all_following]
856
857 # uniqify elements
858 fans = sorted(set(fans), key=fans.index)
859
860 logger.info(
861 "There are {0} Fans of {1} ~the users following {1} WHOM {1} does "
862 "not follow back\n".format(len(fans), username)

Callers 1

pick_fansMethod · 0.85

Calls 3

get_followersFunction · 0.85
get_followingFunction · 0.85
store_fansFunction · 0.85

Tested by

no test coverage detected