Skip to content
This repository has been archived by the owner on Jan 27, 2025. It is now read-only.

Commit

Permalink
• Fix previous update (thanks Dennis for his PR)
Browse files Browse the repository at this point in the history
• Print instagram version on start
• Fix switching language
• Do not clear logs after crash (full logs will be saved on each crash)
  • Loading branch information
Alexander Mishchenko committed Oct 7, 2020
1 parent 4b458ee commit 5898cdf
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 11 deletions.
2 changes: 2 additions & 0 deletions insomniac.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ def main():
if not check_adb_connection(is_device_id_provided=(device_id is not None)):
return

print("Instagram version: " + get_instagram_version())

device = create_device(args.old, device_id)
if device is None:
return
Expand Down
9 changes: 4 additions & 5 deletions src/action_handle_blogger.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,7 @@ def _open_user_followers(device, username):
username_view.click()

print("Open @" + username + " followers")
followers_button = device.find(resourceId='com.instagram.android:id/row_profile_header_followers_container',
className='android.widget.LinearLayout')
followers_button = device.find(resourceIdMatches=FOLLOWERS_BUTTON_ID_REGEX)
followers_button.click()

return True
Expand Down Expand Up @@ -308,15 +307,15 @@ def _follow(device, username, follow_percentage):

random_sleep()

follow_button = device.find(className='android.widget.TextView',
follow_button = device.find(className='android.widget.Button',
clickable=True,
text='Follow')
if not follow_button.exists():
follow_button = device.find(className='android.widget.TextView',
follow_button = device.find(className='android.widget.Button',
clickable=True,
text='Follow Back')
if not follow_button.exists():
unfollow_button = device.find(className='android.widget.TextView',
unfollow_button = device.find(className='android.widget.Button',
clickable=True,
text='Following')
if unfollow_button.exists():
Expand Down
9 changes: 5 additions & 4 deletions src/navigation.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,11 @@ def switch_to_english(device):

action_bar = device.find(resourceId='com.instagram.android:id/action_bar',
className='android.widget.LinearLayout')
options_view = action_bar.child(index=2, className='android.widget.ImageView')
if not options_view.exists():
options_view = action_bar.child(index=3, className='android.widget.ImageView')
if not options_view.exists():
# We wanna pick last ImageView in the action bar
options_view = None
for options_view in action_bar.child(className='android.widget.ImageView'):
pass
if options_view is None or not options_view.exists():
print(COLOR_FAIL + "No idea how to open menu..." + COLOR_ENDC)
return
options_view.click()
Expand Down
14 changes: 12 additions & 2 deletions src/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,18 @@ def get_version():
return version


def get_instagram_version():
stream = os.popen('adb shell dumpsys package com.instagram.android | grep versionName')
output = stream.read()
version_match = re.findall('versionName=(\\S+)', output)
if len(version_match) == 1:
version = version_match[0]
else:
version = "not found"
stream.close()
return version


def check_adb_connection(is_device_id_provided):
stream = os.popen('adb devices')
output = stream.read()
Expand Down Expand Up @@ -101,8 +113,6 @@ def save_crash(device):
print(COLOR_OKGREEN + "Please attach this file if you gonna report the crash at" + COLOR_ENDC)
print(COLOR_OKGREEN + "https://github.com/alexal1/Insomniac/issues\n" + COLOR_ENDC)

print_log = ""


def detect_block(device):
block_dialog = device.find(resourceId='com.instagram.android:id/dialog_root_view',
Expand Down

0 comments on commit 5898cdf

Please sign in to comment.