Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix #379 #407 [NEW] #408

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,4 @@ Pipfile.lock
*.log*
*.ini
*.db
server-restart.py
3 changes: 3 additions & 0 deletions GramAddict/core/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
18 changes: 17 additions & 1 deletion GramAddict/plugins/action_unfollow_followers.py
Original file line number Diff line number Diff line change
Expand Up @@ -294,14 +294,19 @@ 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.")
user_list = device.find(
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
Expand All @@ -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

Expand Down Expand Up @@ -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,
Expand Down