forked from Te-k/analyst-scripts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathkoodous_search.py
executable file
·52 lines (45 loc) · 1.29 KB
/
koodous_search.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#!/usr/bin/env python3
import argparse
import os
import sys
import requests
def search(key, query):
"""
Search in Koodous
"""
url = "https://api.koodous.com/apks"
headers = {"Authorization":"Token {}".format(key)}
params = {'search':query}
results = []
finished = False
next = None
while not finished:
if next:
r = requests.get(url=next, headers=headers)
else:
r = requests.get(url=url, headers=headers, params=params)
if r.status_code != 200:
return results
data = r.json()
results += data['results']
if data.get('next', None):
next = data['next']
else:
finished = True
return results
"""
Query a list of apps on Koodous, downvote and comment on all of them
"""
if __name__ == '__main__':
parser = argparse.ArgumentParser()
parser.add_argument("QUERY", help="Query to be done on Koodous")
args = parser.parse_args()
koodous_conf = os.path.expanduser("~/.koodous")
if not os.path.isfile(koodous_conf):
print("Please add your Koodous key to ~/.koodous")
sys.exit(-1)
with open(koodous_conf, 'r') as f:
key = f.read().strip()
apks = search(key, args.QUERY)
for app in apks:
print(app['sha256'])