forked from opengapps/apkcrawler
-
Notifications
You must be signed in to change notification settings - Fork 0
/
apkcrawler.py
executable file
·87 lines (73 loc) · 2.76 KB
/
apkcrawler.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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
#!/usr/bin/env python3
import logging
import os
import sys
from debug import Debug
from reporthelper import ReportHelper
from apkbeastcrawler import ApkBeastCrawler
from apkdlcrawler import ApkdlCrawler
from apkmirrorcrawler import ApkMirrorCrawler
from apkpurecrawler import ApkPureCrawler
from aptoidecrawler import AptoideCrawler
from mobogeniecrawler import MobogenieCrawler
from playstorecrawler import PlayStoreCrawler
from plazzacrawler import PlazzaCrawler
from uptodowncrawler import UptodownCrawler
from aptoidecrawler import StoresException as AptoideStoresException
from playstorecrawler import CredentialsException as PlayStoreCredentialsException
# logging
logFile = '{0}.log'.format(os.path.basename(__file__))
logLevel = (logging.DEBUG if Debug.DEBUG else logging.INFO)
logFormat = '%(asctime)s %(levelname)s/%(funcName)s(%(process)-5d): %(message)s'
if __name__ == "__main__":
"""
main(): single parameter for report_sources.sh output
"""
logging.basicConfig(filename=logFile, filemode='w', level=logLevel, format=logFormat)
logging.getLogger("requests").setLevel(logging.WARNING)
lines = ''
if len(sys.argv[1:]) == 1:
with open(sys.argv[1]) as report:
lines = report.readlines()
else:
lines = sys.stdin.readlines()
report = ReportHelper(lines)
keys = list(report.getAllApkIds())
if len(keys) == 0:
print('ERROR: expecting:')
print(' - 1 parameter (report file from output of report_sources.sh)')
print(' or ')
print(' - stdin from report_sources.sh')
exit(1)
nonbeta = []
beta = []
crawlers = [ApkBeastCrawler(report),
ApkdlCrawler(report),
ApkMirrorCrawler(report),
ApkPureCrawler(report),
AptoideCrawler(report),
MobogenieCrawler(report),
PlayStoreCrawler(report),
PlazzaCrawler(report),
UptodownCrawler(report)]
for crawler in crawlers:
try:
logging.debug('Crawling {0}'.format(crawler.__class__.__name__))
crawler.crawl()
except AptoideStoresException as e:
pass
logging.info('AptoideStoresException {0}'.format(e))
print('AptoideStoresException: {0}'.format(e))
except PlayStoreCredentialsException as e:
pass
logging.info('PlayStoreCredentialsException {0}'.format(e))
print('PlayStoreCredentialsException: {0}'.format(e))
nonbeta.extend(crawler.dlFiles)
beta.extend(crawler.dlFilesBeta)
outputString = ' '.join(nonbeta)
if beta:
outputString += ' beta ' + ' '.join(beta)
if outputString:
print(outputString)
sys.stdout.flush()
logging.debug('Done ...')