Skip to content

Commit

Permalink
General fixes (#163)
Browse files Browse the repository at this point in the history
    introduced the screen record for debug purpose: --screen-record
    it will start recording when ig gets open, it stops when the deamon get killed (there is a method screenrecord.stop() to stop it, but I'm having some problem to call it)
    add some logs to know exacty what we are doing in unfollow mode
    add a sleep in unfollow to prevent to click on button and get no reaction (because still loading)
  • Loading branch information
mastrolube authored and philip-ulrich committed Dec 26, 2020
1 parent e8efa59 commit 92c0e75
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 5 deletions.
6 changes: 5 additions & 1 deletion GramAddict/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,11 @@ def run():
logger.info("Device screen on and unlocked.")

open_instagram()

if configs.args.screen_record:
logger.warning(
"Start screen recording: it will be saved as debug.mp4 in main folder"
)
device.screenrecord()
try:
profileView = TabBarView(device).navigateToProfile()
random_sleep()
Expand Down
7 changes: 7 additions & 0 deletions GramAddict/core/device_facade.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,13 @@ def back(self):
else:
self.deviceV2.press("back")

def screenrecord(self, output="debug.mp4", fps=10):
"""for debug, available for V2 only"""
if self.deviceV1 is not None:
logger.error("Screen recording is only available for UA2")
else:
self.deviceV2.screenrecord(output, fps)

def screenshot(self, path):
if self.deviceV1 is not None:
self.deviceV1.screenshot(path)
Expand Down
10 changes: 6 additions & 4 deletions GramAddict/plugins/action_unfollow_followers.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,7 @@ def sort_followings_by_date(self, device):
)
return
sort_button.click()
random_sleep()

sort_options_recycler_view = device.find(
resourceId=self.ResourceID.FOLLOW_LIST_SORTING_OPTIONS_RECYCLER_VIEW
Expand Down Expand Up @@ -357,7 +358,8 @@ def do_unfollow(
save_crash(device)
switch_to_english(device)
raise LanguageNotEnglishException()

random_sleep()
logger.debug("Unfollow btn click")
unfollow_button.click()
logger.info(f"Unfollow @{username}.", extra={"color": f"{Fore.YELLOW}"})

Expand All @@ -368,8 +370,7 @@ def do_unfollow(
attempts = 2
for _ in range(attempts):
confirm_unfollow_button = device.find(
resourceId=self.ResourceID.FOLLOW_SHEET_UNFOLLOW_ROW,
className=ClassName.TEXT_VIEW,
resourceId=self.ResourceID.FOLLOW_SHEET_UNFOLLOW_ROW
)
if confirm_unfollow_button.exists():
break
Expand All @@ -379,7 +380,7 @@ def do_unfollow(
save_crash(device)
device.back()
return False

logger.debug("Confirm unfollow")
confirm_unfollow_button.click()

random_sleep(0, 1)
Expand All @@ -391,6 +392,7 @@ def do_unfollow(
)

if private_unfollow_button.exists():
logger.debug("Confirm unfollow private account")
private_unfollow_button.click()

detect_block(device)
Expand Down
5 changes: 5 additions & 0 deletions GramAddict/plugins/core_arguments.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,11 @@ def __init__(self):
"help": "enable debug logging",
"action": "store_true",
},
{
"arg": "--screen-record",
"help": "enable screen recording: it will be saved as debug.mp4",
"action": "store_true",
},
{
"arg": "--uia-version",
"nargs": None,
Expand Down

0 comments on commit 92c0e75

Please sign in to comment.