mirror of
https://github.com/FliegendeWurst/googleplay-api.git
synced 2024-11-22 12:54:58 +00:00
Fixed and improved browse() function
Signed-off-by: Domenico Iezzi <domenico.iezzi.201@gmail.com>
This commit is contained in:
parent
73081ee57a
commit
a79c1556ab
@ -328,16 +328,29 @@ class GooglePlayAPI(object):
|
|||||||
result = list(map(utils.fromDocToDictionary, detailsList))
|
result = list(map(utils.fromDocToDictionary, detailsList))
|
||||||
return result
|
return result
|
||||||
|
|
||||||
def browse(self, cat=None, ctr=None):
|
def browse(self, cat=None, subCat=None):
|
||||||
"""Browse categories.
|
"""Browse categories.
|
||||||
cat (category ID) and ctr (subcategory ID) are used as filters."""
|
cat (category ID) and ctr (subcategory ID) are used as filters."""
|
||||||
path = "browse?c=3"
|
path = "browse?c=3"
|
||||||
if cat is not None:
|
if cat is not None:
|
||||||
path += "&cat=%s" % requests.utils.quote(cat)
|
path += "&cat=%s" % requests.utils.quote(cat)
|
||||||
if ctr is not None:
|
if subCat is not None:
|
||||||
path += "&ctr=%s" % requests.utils.quote(ctr)
|
path += "&ctr=%s" % requests.utils.quote(subCat)
|
||||||
message = self.executeRequestApi2(path)
|
data = self.executeRequestApi2(path)
|
||||||
return message.payload.browseResponse
|
output = {}
|
||||||
|
|
||||||
|
if len(data.preFetch) > 0:
|
||||||
|
# get Play Store showcase categories
|
||||||
|
# (like Top Trending, Recently Updated ...)
|
||||||
|
for preFetch in data.preFetch:
|
||||||
|
doc = preFetch.response.payload.listResponse.cluster[0].doc
|
||||||
|
if len(doc) == 0:
|
||||||
|
continue
|
||||||
|
categoryTitle = doc[0].title
|
||||||
|
output[categoryTitle] = list(map(utils.fromDocToDictionary,
|
||||||
|
[apps for apps in doc[0].child]))
|
||||||
|
|
||||||
|
return output
|
||||||
|
|
||||||
def list(self, cat, ctr=None, nb_results=None, offset=None):
|
def list(self, cat, ctr=None, nb_results=None, offset=None):
|
||||||
"""List apps.
|
"""List apps.
|
||||||
|
17
test.py
17
test.py
@ -8,6 +8,8 @@ PASSWD = "fjgozwjmkwyvvutt"
|
|||||||
testApps = ['com.cpuid.cpu_z']
|
testApps = ['com.cpuid.cpu_z']
|
||||||
server = GooglePlayAPI(debug=True)
|
server = GooglePlayAPI(debug=True)
|
||||||
|
|
||||||
|
# LOGIN
|
||||||
|
|
||||||
print('\nLogging in with email and password\n')
|
print('\nLogging in with email and password\n')
|
||||||
server.login(EMAIL, PASSWD, None, None)
|
server.login(EMAIL, PASSWD, None, None)
|
||||||
gsfId = server.gsfId
|
gsfId = server.gsfId
|
||||||
@ -17,14 +19,20 @@ print('\nNow trying secondary login with ac2dm token and gsfId saved\n')
|
|||||||
server = GooglePlayAPI(debug=True)
|
server = GooglePlayAPI(debug=True)
|
||||||
server.login(None, None, gsfId, authSubToken)
|
server.login(None, None, gsfId, authSubToken)
|
||||||
|
|
||||||
|
# SEARCH
|
||||||
|
|
||||||
apps = server.search('telegram', 34, None)
|
apps = server.search('telegram', 34, None)
|
||||||
|
|
||||||
print('nb_result: 34')
|
print('nb_result: 34')
|
||||||
print('number of results: %d' % len(apps))
|
print('number of results: %d' % len(apps))
|
||||||
|
|
||||||
|
|
||||||
print('\nFound those apps:\n')
|
print('\nFound those apps:\n')
|
||||||
for a in apps:
|
for a in apps:
|
||||||
print(a['docId'])
|
print(a['docId'])
|
||||||
|
|
||||||
|
# DOWNLOAD
|
||||||
|
|
||||||
docid = apps[0]['docId']
|
docid = apps[0]['docId']
|
||||||
version = apps[0]['versionCode']
|
version = apps[0]['versionCode']
|
||||||
print('\nTelegram docid is: %s\n' % docid)
|
print('\nTelegram docid is: %s\n' % docid)
|
||||||
@ -34,6 +42,15 @@ with open(docid + '.apk', 'wb') as f:
|
|||||||
f.write(fl)
|
f.write(fl)
|
||||||
print('\nDownload successful\n')
|
print('\nDownload successful\n')
|
||||||
f.close()
|
f.close()
|
||||||
|
|
||||||
|
# BULK DETAILS
|
||||||
|
|
||||||
print('\nGetting details for %s\n' % testApps[0])
|
print('\nGetting details for %s\n' % testApps[0])
|
||||||
bulk = server.bulkDetails(testApps)
|
bulk = server.bulkDetails(testApps)
|
||||||
print(bulk)
|
print(bulk)
|
||||||
|
|
||||||
|
# BROWSE
|
||||||
|
browse = server.browse(cat='MUSIC_AND_AUDIO')
|
||||||
|
for key in list(browse.keys()):
|
||||||
|
print('First app for category %s is %s' %
|
||||||
|
(key, browse[key][0]['docId']))
|
||||||
|
Loading…
Reference in New Issue
Block a user