-
Notifications
You must be signed in to change notification settings - Fork 0
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
Sourcery refactored master branch #1
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,27 +22,25 @@ def get_page(usrname): | |
global resp_js | ||
session = requests.session() | ||
session.headers = {'User-Agent': random.choice(useragent)} | ||
resp_js = session.get('https://www.instagram.com/'+usrname+'/?__a=1').text | ||
resp_js = session.get(f'https://www.instagram.com/{usrname}/?__a=1').text | ||
return resp_js | ||
|
||
def exinfo(): | ||
|
||
def xprint(xdict, text): | ||
if xdict != {}: | ||
print(f"{su} {re}most used %s :" % text) | ||
i = 0 | ||
for key, val in xdict.items(): | ||
if len(mail) == 1: | ||
if key in mail[0]: | ||
continue | ||
print(f" {gr}%s : {wh}%s" % (key, val)) | ||
i += 1 | ||
if i > 4: | ||
break | ||
print() | ||
else: | ||
pass | ||
|
||
if xdict == {}: | ||
return | ||
print(f"{su} {re}most used %s :" % text) | ||
i = 0 | ||
for key, val in xdict.items(): | ||
if len(mail) == 1 and key in mail[0]: | ||
continue | ||
print(f" {gr}%s : {wh}%s" % (key, val)) | ||
i += 1 | ||
if i > 4: | ||
break | ||
print() | ||
|
||
Comment on lines
-31
to
+43
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Function
|
||
raw = find(resp_js) | ||
|
||
mail = raw['email'] | ||
|
@@ -65,17 +63,15 @@ def xprint(xdict, text): | |
def user_info(usrname): | ||
|
||
global total_uploads, is_private | ||
|
||
resp_js = get_page(usrname) | ||
js = json.loads(resp_js) | ||
js = js['graphql']['user'] | ||
|
||
if js['is_private'] != False: | ||
is_private = True | ||
|
||
if js['edge_owner_to_timeline_media']['count'] > 12: | ||
pass | ||
else: | ||
|
||
if js['edge_owner_to_timeline_media']['count'] <= 12: | ||
Comment on lines
-68
to
+74
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Function
|
||
total_uploads = js['edge_owner_to_timeline_media']['count'] | ||
|
||
usrinfo = { | ||
|
@@ -112,7 +108,6 @@ def user_info(usrname): | |
|
||
def highlight_post_info(i): | ||
|
||
postinfo = {} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Function
|
||
total_child = 0 | ||
child_img_list = [] | ||
|
||
|
@@ -156,9 +151,6 @@ def highlight_post_info(i): | |
|
||
child_img_list.append(img_info) | ||
|
||
postinfo['imgs'] = child_img_list | ||
postinfo['info'] = info | ||
|
||
else: | ||
info = { | ||
'comments': js['edge_media_to_comment']['count'], | ||
|
@@ -186,24 +178,18 @@ def highlight_post_info(i): | |
'is_video': js['is_video'], | ||
'accessibility': js['accessibility_caption'] | ||
} | ||
|
||
child_img_list.append(img_info) | ||
|
||
postinfo['imgs'] = child_img_list | ||
postinfo['info'] = info | ||
|
||
return postinfo | ||
return {'imgs': child_img_list, 'info': info} | ||
|
||
def post_info(): | ||
|
||
if is_private != False: | ||
print(f"{fa} {gr}cannot use -p for private accounts !\n") | ||
sys.exit(1) | ||
|
||
posts = [] | ||
|
||
for x in range(total_uploads): | ||
posts.append(highlight_post_info(x)) | ||
|
||
posts = [highlight_post_info(x) for x in range(total_uploads)] | ||
Comment on lines
-202
to
+192
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Function
|
||
|
||
for x in range(len(posts)): | ||
# get 1 item from post list | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,7 +8,7 @@ | |
def validate_mail(mail): | ||
regex = r"^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,})$" | ||
match = r.match(regex, mail) | ||
if match == None: | ||
if match is None: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Function
|
||
print('regex : fail') | ||
else: | ||
print('regex : success') | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,7 +19,7 @@ | |
# 30-33, 48-50, 94-96, 195-210 | ||
|
||
def urlshortner(url): | ||
data = requests.get("http://tinyurl.com/api-create.php?url=" + url) | ||
data = requests.get(f"http://tinyurl.com/api-create.php?url={url}") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Function
|
||
return data.text | ||
|
||
def write(stri): | ||
|
@@ -30,14 +30,11 @@ def write(stri): | |
|
||
def sort_list(xlist): | ||
with_count = dict(collections.Counter(xlist)) | ||
output = {k: v for k, v in sorted(with_count.items(), reverse=True, key=lambda item: item[1])} | ||
return output | ||
return dict(sorted(with_count.items(), reverse=True, key=lambda item: item[1])) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Function
|
||
|
||
def find(stri): | ||
exinfo = {} | ||
email = r.findall(r"[_a-z0-9-\.]+[@@]{1}[a-z0-9]+\.[a-z0-9]+", stri.lower()) | ||
exinfo['email'] = email | ||
|
||
exinfo = {'email': email} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Function
|
||
#(?:^|\s)([#|@]{1}[_a-zA-Z0-9\.\+-]+) | ||
tags = r.findall(r"[##]{1}([_a-zA-Z0-9\.\+-]+)", stri) | ||
exinfo['tags'] = tags | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,15 @@ | ||
#!/bin/env python3 | ||
|
||
import os, sys | ||
sys.path.append(os.getcwd()+"/.lib/") | ||
sys.path.append(f"{os.getcwd()}/.lib/") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Lines
|
||
import argparse | ||
from api import * | ||
|
||
ap = argparse.ArgumentParser() | ||
ap.add_argument("-u", "--user", required=True, help="username of account to scan") | ||
ap.add_argument("-p", "--post", action="store_true", help="image info of user uploads") | ||
args = vars(ap.parse_args()) | ||
|
||
os.system("clear") | ||
|
||
if args['user']: | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Function
get_page
refactored with the following changes:use-fstring-for-concatenation
)