MCPcopy
hub / github.com/InstaPy/InstaPy / get_nonfollowers

Function get_nonfollowers

instapy/relationship_tools.py:731–802  ·  view source on GitHub ↗

Finds Nonfollowers of a given user

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

Source from the content-addressed store, hash-verified

729
730
731def get_nonfollowers(
732 browser,
733 self_username,
734 username,
735 relationship_data,
736 live_match,
737 store_locally,
738 logger,
739 logfolder,
740):
741 """Finds Nonfollowers of a given user"""
742
743 if username is None or not isinstance(username, str):
744 logger.info(
745 "Please enter a username to pick Nonfollowers ~leaving out of "
746 "an invalid value"
747 )
748 return []
749
750 # get `Followers` data
751 all_followers = get_followers(
752 browser,
753 self_username,
754 username,
755 "full",
756 relationship_data,
757 live_match,
758 store_locally,
759 logger,
760 logfolder,
761 )
762
763 # if all_followers is False we have targeted a private account that we don't follow
764 if not all_followers:
765 return False
766
767 # get `Following` data
768 all_following = get_following(
769 browser,
770 self_username,
771 username,
772 "full",
773 relationship_data,
774 live_match,
775 store_locally,
776 logger,
777 logfolder,
778 )
779
780 # using this approach we can preserve the order of elements to be used
781 # with `FIFO`, `LIFO` or `RANDOM` styles
782 nonfollowers = [user for user in all_following if user not in all_followers]
783
784 # uniqify elements
785 nonfollowers = sorted(set(nonfollowers), key=nonfollowers.index)
786
787 logger.info(
788 "There are {0} Nonfollowers of {1} ~the users {1} is following WHO "

Callers 2

unfollowFunction · 0.85
pick_nonfollowersMethod · 0.85

Calls 3

get_followersFunction · 0.85
get_followingFunction · 0.85
store_nonfollowersFunction · 0.85

Tested by

no test coverage detected