Repository: InstaPy/InstaPy

Issue:
Where are the unfollowed users stored?
I'm new to instapy and I'm trying to find out where instapy stores the users, which have been followed and unfollowed, to make sure they are not followed a second time.

My understanding is, that the log/usernameFollowedPool.csv keeps the actual followed users, but not the ones who have been followed previously.

Thanks for your help!



Discussion:
there is a json file in this folder with the number of times been followed.
Well, the json file stores the username of the account which followers I follow - but not a list of the individual users. in my case it just has one line, but it would need to have a list of hundred users...right?

It just says:
{"username": 10}
instapy already have this feature, but I think there's a bug. this pr fix it #1118 
@TiborMuc Can you please try again?
@timgrossmann 
It doesn't work.
Now, it stores all the users in the jason file like:
"username":timesfollowed
But - it ignores the count. 
I was running the following scripts twice, with unfollowing them in between, but it just increases the count from 1 to 2 instead of bypassing the user...

session.login()
session.set_do_follow(enabled=True, times=1)
session.follow_user_followers(['famous_account'], amount=5, randomize=False, sleep_delay=60)

What it should do from my understanding, is follow 5 followers of "famous_account" from the top without randomising, checking if they are in the json file already.
instead it ignores, that they are already listed in the json file and simply increases the count by one.

Any idea? your help is very much appreciated!

Tibor


Resolving patch:
diff --git a/instapy/instapy.py b/instapy/instapy.py
--- a/instapy/instapy.py
+++ b/instapy/instapy.py
@@ -1083,7 +1083,6 @@ def interact_user_followers(self, usernames, amount=10, randomize=False):
                                                 amount,
                                                 self.dont_include,
                                                 self.username,
-                                                self.follow_restrict,
                                                 randomize,
                                                 self.logger)
                 if isinstance(user, list):
@@ -1124,7 +1123,6 @@ def interact_user_following(self, usernames, amount=10, randomize=False):
                     amount,
                     self.dont_include,
                     self.username,
-                    self.follow_restrict,
                     randomize,
                     self.logger)
         except (TypeError, RuntimeWarning) as err:
@@ -1171,7 +1169,8 @@ def follow_user_followers(self,
                                                             randomize,
                                                             sleep_delay,
                                                             self.blacklist,
-                                                            self.logger)
+                                                            self.logger,
+                                                            self.follow_times)
 
             except (TypeError, RuntimeWarning) as err:
                 if isinstance(err, RuntimeWarning):
@@ -1218,7 +1217,8 @@ def follow_user_following(self,
                                                             randomize,
                                                             sleep_delay,
                                                             self.blacklist,
-                                                            self.logger)
+                                                            self.logger,
+                                                            self.follow_times)
 
             except (TypeError, RuntimeWarning) as err:
                 if isinstance(err, RuntimeWarning):
diff --git a/instapy/unfollow_util.py b/instapy/unfollow_util.py
--- a/instapy/unfollow_util.py
+++ b/instapy/unfollow_util.py
@@ -424,6 +424,7 @@ def follow_through_dialog(browser,
                           delay,
                           blacklist,
                           logger,
+                          follow_times,
                           callbacks=[]):
     sleep(2)
     person_followed = []
@@ -504,7 +505,9 @@ def follow_through_dialog(browser,
                 hasSlept = True
                 continue
 
-            if person not in dont_include:
+            if (person not in dont_include and
+                follow_restrict.get(person, 0) < follow_times):
+
                 followNum += 1
                 # Register this session's followed user for further interaction
                 person_followed.append(person)
@@ -554,7 +557,6 @@ def get_given_user_followers(browser,
                              amount,
                              dont_include,
                              login,
-                             follow_restrict,
                              randomize,
                              logger):
 
@@ -620,7 +622,6 @@ def get_given_user_following(browser,
                              amount,
                              dont_include,
                              login,
-                             follow_restrict,
                              randomize,
                              logger):
 
@@ -691,7 +692,8 @@ def follow_given_user_followers(browser,
                                 random,
                                 delay,
                                 blacklist,
-                                logger):
+                                logger,
+                                follow_times):
 
     browser.get('https://www.instagram.com/' + user_name)
     # update server calls
@@ -725,6 +727,7 @@ def follow_given_user_followers(browser,
                                            delay,
                                            blacklist,
                                            logger,
+                                           follow_times,
                                            callbacks=[])
 
     return personFollowed
@@ -739,7 +742,8 @@ def follow_given_user_following(browser,
                                 random,
                                 delay,
                                 blacklist,
-                                logger):
+                                logger,
+                                follow_times):
 
     browser.get('https://www.instagram.com/' + user_name)
     # update server calls
@@ -772,7 +776,8 @@ def follow_given_user_following(browser,
                                            random,
                                            delay,
                                            blacklist,
-                                           logger)
+                                           logger,
+                                           follow_times)
 
     return personFollowed
 


Test patch: