2017-10-07 16:21:05 +00:00
|
|
|
from gpapi.googleplay import GooglePlayAPI, RequestError
|
2017-09-05 20:28:06 +00:00
|
|
|
|
2017-09-18 14:06:57 +00:00
|
|
|
import sys
|
|
|
|
|
2017-09-19 15:52:29 +00:00
|
|
|
EMAIL = "maracaiboez"
|
|
|
|
PASSWD = "fjgozwjmkwyvvutt"
|
2017-09-16 11:17:21 +00:00
|
|
|
|
2017-09-16 17:13:01 +00:00
|
|
|
testApps = ['com.cpuid.cpu_z']
|
2017-10-04 09:32:56 +00:00
|
|
|
server = GooglePlayAPI(debug=True)
|
2017-09-16 17:13:01 +00:00
|
|
|
|
2017-10-05 19:51:43 +00:00
|
|
|
# LOGIN
|
|
|
|
|
2017-10-05 18:39:24 +00:00
|
|
|
print('\nLogging in with email and password\n')
|
|
|
|
server.login(EMAIL, PASSWD, None, None)
|
|
|
|
gsfId = server.gsfId
|
|
|
|
authSubToken = server.authSubToken
|
|
|
|
|
|
|
|
print('\nNow trying secondary login with ac2dm token and gsfId saved\n')
|
|
|
|
server = GooglePlayAPI(debug=True)
|
|
|
|
server.login(None, None, gsfId, authSubToken)
|
|
|
|
|
2017-10-05 19:51:43 +00:00
|
|
|
# SEARCH
|
|
|
|
|
2017-10-06 09:53:53 +00:00
|
|
|
apps = server.search('termux', 34, None)
|
2017-10-05 18:39:24 +00:00
|
|
|
|
|
|
|
print('nb_result: 34')
|
|
|
|
print('number of results: %d' % len(apps))
|
|
|
|
|
|
|
|
print('\nFound those apps:\n')
|
|
|
|
for a in apps:
|
|
|
|
print(a['docId'])
|
2017-10-05 19:51:43 +00:00
|
|
|
|
|
|
|
# DOWNLOAD
|
2017-10-05 18:39:24 +00:00
|
|
|
docid = apps[0]['docId']
|
|
|
|
version = apps[0]['versionCode']
|
2017-10-06 09:53:53 +00:00
|
|
|
print('\nTermux docid is: %s\n' % docid)
|
2017-10-05 18:39:24 +00:00
|
|
|
print('\nAttempting to download %s\n' % docid)
|
2017-10-07 17:22:55 +00:00
|
|
|
fl = server.download(docid, version, progress_bar=True)
|
2017-10-05 18:39:24 +00:00
|
|
|
with open(docid + '.apk', 'wb') as f:
|
|
|
|
f.write(fl)
|
|
|
|
print('\nDownload successful\n')
|
|
|
|
f.close()
|
2017-10-05 19:51:43 +00:00
|
|
|
|
2017-10-07 16:21:05 +00:00
|
|
|
# DOWNLOAD APP NOT PURCHASED
|
|
|
|
# Attempting to download Nova Launcher Prime
|
|
|
|
# it should throw an error 'App Not Purchased'
|
|
|
|
|
2017-10-07 17:22:55 +00:00
|
|
|
print('\nAttempting to download "com.teslacoilsw.launcher.prime"\n')
|
2017-10-07 16:21:05 +00:00
|
|
|
errorThrown = False
|
|
|
|
try:
|
|
|
|
app = server.search('nova launcher prime', 3, None)
|
|
|
|
app = filter(lambda x: x['docId'] == 'com.teslacoilsw.launcher.prime', app)
|
|
|
|
app = list(app)[0]
|
2017-10-07 17:22:55 +00:00
|
|
|
fl = server.delivery(app['docId'], app['versionCode'], progress_bar=True)
|
2017-10-07 16:21:05 +00:00
|
|
|
with open(docid + '.apk', 'wb') as f:
|
|
|
|
f.write(fl)
|
|
|
|
print('\nDownload successful\n')
|
|
|
|
f.close()
|
|
|
|
except RequestError as e:
|
|
|
|
errorThrown = True
|
2017-10-07 17:22:55 +00:00
|
|
|
print(e)
|
2017-10-07 16:21:05 +00:00
|
|
|
|
|
|
|
if not errorThrown:
|
|
|
|
print('Download of previous app should have failed')
|
|
|
|
sys.exit(1)
|
|
|
|
|
|
|
|
|
2017-10-05 19:51:43 +00:00
|
|
|
# BULK DETAILS
|
|
|
|
|
2017-10-08 17:50:29 +00:00
|
|
|
print('\nGetting bulkDetails for %s\n' % testApps[0])
|
2017-10-05 18:39:24 +00:00
|
|
|
bulk = server.bulkDetails(testApps)
|
|
|
|
print(bulk)
|
2017-10-05 19:51:43 +00:00
|
|
|
|
2017-10-08 17:50:29 +00:00
|
|
|
# DETAILS
|
|
|
|
print('\nGetting details for %s\n' % testApps[0])
|
|
|
|
details = server.details(testApps[0])
|
|
|
|
print(details)
|
|
|
|
|
2017-10-05 19:51:43 +00:00
|
|
|
# BROWSE
|
2017-10-05 20:04:29 +00:00
|
|
|
|
2017-10-06 09:53:53 +00:00
|
|
|
print('\nBrowse play store categories\n')
|
|
|
|
browse = server.browse()
|
|
|
|
for b in browse:
|
|
|
|
print(b['name'])
|
2017-10-06 07:39:28 +00:00
|
|
|
|
2017-10-06 09:53:53 +00:00
|
|
|
print('\nBrowsing the %s category\n' % browse[0]['catId'])
|
|
|
|
browseCat = server.browse(browse[0]['catId'])
|
|
|
|
for b in browseCat:
|
|
|
|
print('%s subcategory with %d apps' % (b['title'],len(b['apps'])))
|
|
|
|
|
|
|
|
# LIST
|
|
|
|
|
|
|
|
cat = 'MUSIC_AND_AUDIO'
|
|
|
|
print('\nList %s subcategories\n' % cat)
|
|
|
|
catList = server.list(cat)
|
|
|
|
for c in catList:
|
|
|
|
print(c)
|
|
|
|
|
|
|
|
print('\nList %s apps for %s category\n' % (catList[0],cat))
|
|
|
|
appList = server.list(cat, catList[0])
|
|
|
|
for app in appList:
|
|
|
|
print(app['docId'])
|