supeapp PoC
This commit is contained in:
parent
83a8084ef2
commit
d079758203
3
.gitignore
vendored
3
.gitignore
vendored
@ -1,3 +1,6 @@
|
|||||||
|
TOKEN
|
||||||
|
media/
|
||||||
|
|
||||||
# Byte-compiled / optimized / DLL files
|
# Byte-compiled / optimized / DLL files
|
||||||
__pycache__/
|
__pycache__/
|
||||||
*.py[cod]
|
*.py[cod]
|
||||||
|
69
supeapp.py
Normal file
69
supeapp.py
Normal file
@ -0,0 +1,69 @@
|
|||||||
|
import requests
|
||||||
|
import os
|
||||||
|
from os.path import expanduser, join
|
||||||
|
|
||||||
|
API_DOMAIN = "http://api.supe.io/"
|
||||||
|
|
||||||
|
API_HEADERS = {
|
||||||
|
'User-Agent': 'okhttp/3.6.0',
|
||||||
|
'Platform-Name': 'Android 8.0.0',
|
||||||
|
'Application-Version': '1.1.2',
|
||||||
|
'Device-Name': 'OnePlus ONEPLUS A3003',
|
||||||
|
'Authorization': 'Bearer {}'.format(os.environ['SUPE_TOKEN']),
|
||||||
|
'Accept': 'application/vnd.api.v3+json',
|
||||||
|
'Content-Type': 'application/json'
|
||||||
|
}
|
||||||
|
|
||||||
|
# Standard code for making request \o/
|
||||||
|
def request(endpoint, data={}, headers={}, method='POST'):
|
||||||
|
headers.update(API_HEADERS)
|
||||||
|
r = requests.request(method, API_DOMAIN+endpoint, data=data, headers=headers)
|
||||||
|
if r.status_code == 200:
|
||||||
|
return r.json()
|
||||||
|
return None
|
||||||
|
|
||||||
|
def download(media_url, cwd=expanduser("~")):
|
||||||
|
filename = media_url.split("/")[-1]
|
||||||
|
file_path = join(cwd, filename)
|
||||||
|
|
||||||
|
r = requests.get(media_url, stream=True)
|
||||||
|
if r.status_code == 403:
|
||||||
|
raise Exception("Access Denied")
|
||||||
|
with open(file_path, 'wb') as fh:
|
||||||
|
for chunk in r.iter_content(chunk_size=1024):
|
||||||
|
fh.write(chunk)
|
||||||
|
|
||||||
|
def get_pubblishers():
|
||||||
|
obj = request("me/inbox/publishers?type=broadcast", method='GET')
|
||||||
|
users = obj['_embedded']['items']
|
||||||
|
|
||||||
|
for user in users:
|
||||||
|
print(user['id'],user['username'])
|
||||||
|
|
||||||
|
profile_pic = user['_embedded']['profileAsset']['filename']
|
||||||
|
cwd = join("./media",str(user['id']))
|
||||||
|
if not os.path.isdir(cwd):
|
||||||
|
os.mkdir(cwd)
|
||||||
|
|
||||||
|
download(profile_pic, cwd=cwd)
|
||||||
|
|
||||||
|
get_pubblisher_video(user['id'])
|
||||||
|
|
||||||
|
|
||||||
|
def get_pubblisher_video(pub_id):
|
||||||
|
obj = request("me/inbox/publisher/{}?type=broadcast".format(pub_id), method='GET')
|
||||||
|
posts = obj['_embedded']['items']
|
||||||
|
|
||||||
|
for post in posts:
|
||||||
|
print(post['id'],post['type'],post['caption'])
|
||||||
|
|
||||||
|
media = post['_embedded']['asset']['filename']
|
||||||
|
cwd = join("./media",str(pub_id))
|
||||||
|
if not os.path.isdir(cwd):
|
||||||
|
os.mkdir(cwd)
|
||||||
|
|
||||||
|
print("Downloading {}".format(post['_embedded']['asset']['type']))
|
||||||
|
download(media, cwd=cwd)
|
||||||
|
|
||||||
|
|
||||||
|
get_pubblishers()
|
Loading…
Reference in New Issue
Block a user