Instapy: 'min_following' not adhered

Created on 6 Sep 2018  路  3Comments  路  Source: timgrossmann/InstaPy

Expected Behavior

Interaction on images should be avoided if account's following count is lesser than the 'min_following' set.

Current Behavior

I have 'min_following' set to 30 (complete configuration below). But this is not adhered in a case where following for account is zero.

InstaPy configuration

session.set_relationship_bounds(enabled=True, potency_ratio=-0.65, delimit_by_numbers=True, max_followers=1000, max_following=5555, min_followers=30, min_following=30)

Screenshot

2018-09-06 22_59_51-

wontfix

Most helpful comment

Hey @Nocturnal-2 , I actually had the same issue on this one too and made another customization for my cloned repo.

I'm simply ignoring any user whose follower or following count comes back as None

In validate_username() in util.py, simply add the code between the two obnoxiously large # ---- # lines:

.
.
.

    """Checks the potential of target user by relationship status in order to delimit actions within the desired boundary"""
    if potency_ratio or delimit_by_numbers and (max_followers or max_following or min_followers or min_following):

        relationship_ratio = None
        reverse_relationship = False

        # Get followers & following counts
        followers_count, following_count = get_relationship_counts(browser, username, logger)

        if potency_ratio and potency_ratio < 0:
            potency_ratio *= -1
            reverse_relationship = True

        if followers_count and following_count:
            relationship_ratio = (float(followers_count)/float(following_count)
                       if not reverse_relationship
                        else float(following_count)/float(followers_count))

        logger.info('User: {} >> followers: {}  |  following: {}  |  relationship ratio: {}'.format(username,
        followers_count if followers_count else 'unknown',
        following_count if following_count else 'unknown',
        float("{0:.2f}".format(relationship_ratio)) if relationship_ratio else 'unknown'))

        ### ---------------------------------------------------------------------------------- ###
        ### ignore users with 'strange' / None type / irretrievable follower,following counts
        ### ---------------------------------------------------------------------------------- ###

        if followers_count and following_count:
            pass
        else:
            print('\n\n')
            print('found user with strange following/follower data: '+username)
            print('\n\n')
            return False, "User {} has strange follower/following data...ignoring!\n".format(username)

        ### ---------------------------------------------------------------------------------- ###
        ### ---------------------------------------------------------------------------------- ###
        ### ---------------------------------------------------------------------------------- ###

        if followers_count  or following_count:
            if potency_ratio and not delimit_by_numbers:
                if relationship_ratio and relationship_ratio < potency_ratio:
                        return False, \
                            "{} is not a {} with the relationship ratio of {}  ~skipping user\n".format(
                            username, "potential user" if not reverse_relationship else "massive follower",
                            float("{0:.2f}".format(relationship_ratio)))

.
.
.

All 3 comments

Current behavior

I encountered this scenario again today. I am using _session.like_by_tags()_ method to like photos. Someone with zero following flooded a hashtag with bunch of spam images as be seen the screenshot below.

Screenshot

2018-09-15 10_46_58-

Instapy configuration

session.set_relationship_bounds(enabled=True, potency_ratio=-0.40, delimit_by_numbers=True, max_followers=2500, max_following=5555, min_followers=30, min_following=30)

Issues & improvements

I think two things can be improved in these scenarios.

  1. When the follower count is zero, _potency_ratio_ and _min_following_ set using _set_relationship_bounds()_ is not adhered.

  2. It will be good if there is way to restrict more than one photo from the same user from being liked in the same session as mentioned in #2861. In scenarios like these, when _set_relationship_bounds()_ is set, the program is switches back and forth between the image and the profile page several times ( = wasted server calls with lesser chances of any fruitful return :( ). Thanks to @hotdogcannon for a solution. It will be great if something like is implemented.

Hey @Nocturnal-2 , I actually had the same issue on this one too and made another customization for my cloned repo.

I'm simply ignoring any user whose follower or following count comes back as None

In validate_username() in util.py, simply add the code between the two obnoxiously large # ---- # lines:

.
.
.

    """Checks the potential of target user by relationship status in order to delimit actions within the desired boundary"""
    if potency_ratio or delimit_by_numbers and (max_followers or max_following or min_followers or min_following):

        relationship_ratio = None
        reverse_relationship = False

        # Get followers & following counts
        followers_count, following_count = get_relationship_counts(browser, username, logger)

        if potency_ratio and potency_ratio < 0:
            potency_ratio *= -1
            reverse_relationship = True

        if followers_count and following_count:
            relationship_ratio = (float(followers_count)/float(following_count)
                       if not reverse_relationship
                        else float(following_count)/float(followers_count))

        logger.info('User: {} >> followers: {}  |  following: {}  |  relationship ratio: {}'.format(username,
        followers_count if followers_count else 'unknown',
        following_count if following_count else 'unknown',
        float("{0:.2f}".format(relationship_ratio)) if relationship_ratio else 'unknown'))

        ### ---------------------------------------------------------------------------------- ###
        ### ignore users with 'strange' / None type / irretrievable follower,following counts
        ### ---------------------------------------------------------------------------------- ###

        if followers_count and following_count:
            pass
        else:
            print('\n\n')
            print('found user with strange following/follower data: '+username)
            print('\n\n')
            return False, "User {} has strange follower/following data...ignoring!\n".format(username)

        ### ---------------------------------------------------------------------------------- ###
        ### ---------------------------------------------------------------------------------- ###
        ### ---------------------------------------------------------------------------------- ###

        if followers_count  or following_count:
            if potency_ratio and not delimit_by_numbers:
                if relationship_ratio and relationship_ratio < potency_ratio:
                        return False, \
                            "{} is not a {} with the relationship ratio of {}  ~skipping user\n".format(
                            username, "potential user" if not reverse_relationship else "massive follower",
                            float("{0:.2f}".format(relationship_ratio)))

.
.
.

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. > If this problem still occurs, please open a new issue

Was this page helpful?
0 / 5 - 0 ratings

Related issues

neomh picture neomh  路  3Comments

46960 picture 46960  路  3Comments

n0sw34r picture n0sw34r  路  3Comments

ghost picture ghost  路  3Comments

tibor picture tibor  路  3Comments