diff --git a/.gitignore b/.gitignore index 59ddc736..5a9790d6 100644 --- a/.gitignore +++ b/.gitignore @@ -20,3 +20,4 @@ Pipfile.lock *.log* *.ini *.db +server-restart.py \ No newline at end of file diff --git a/GramAddict/core/views.py b/GramAddict/core/views.py index fb2d0c07..161ab356 100644 --- a/GramAddict/core/views.py +++ b/GramAddict/core/views.py @@ -920,6 +920,9 @@ def detect_media_type(content_desc) -> Tuple[Optional[MediaType], Optional[int]] ) obj_count = n_photos + n_videos media_type = MediaType.CAROUSEL + if obj_count == 0: + media_type = MediaType.REEL + logger.info("Activating workaround test for Bug #285 - switching to REEL media type") return media_type, obj_count def _like_in_post_view( diff --git a/GramAddict/plugins/action_unfollow_followers.py b/GramAddict/plugins/action_unfollow_followers.py index d30a6a97..ce61aa92 100644 --- a/GramAddict/plugins/action_unfollow_followers.py +++ b/GramAddict/plugins/action_unfollow_followers.py @@ -294,6 +294,10 @@ def iterate_over_followings( total_unfollows_limit_reached = False posts_end_detector.notify_new_page() prev_screen_iterated_followings = [] + # variables to save appeared usernames + seen_users = set() + seen_user_threshold = 3 #how many people with the same usernames the bot should see again to stop + seen_user_count = 0 while True: screen_iterated_followings = [] logger.info("Iterate over visible followings.") @@ -301,7 +305,8 @@ def iterate_over_followings( resourceIdMatches=self.ResourceID.USER_LIST_CONTAINER, ) row_height, n_users = inspect_current_view(user_list) - for item in user_list: + for item in user_list: + # inner user_list counter cur_row_height = item.get_height() if cur_row_height < row_height: continue @@ -316,6 +321,10 @@ def iterate_over_followings( username = user_name_view.get_text() screen_iterated_followings.append(username) + # check if a username has seen previously + if username in seen_users: + seen_user_count += 1 + seen_users.add(username) if username not in checked: checked[username] = None @@ -409,6 +418,13 @@ def iterate_over_followings( if screen_iterated_followings != prev_screen_iterated_followings: prev_screen_iterated_followings = screen_iterated_followings + # exit if reach seen threshold + if seen_user_count > seen_user_threshold: + logger.info( + "Reached the following list end, finish.", + extra={"color": f"{Fore.GREEN}"}, + ) + return logger.info("Need to scroll now.", extra={"color": f"{Fore.GREEN}"}) list_view = device.find( resourceId=self.ResourceID.LIST,