mirror of
https://github.com/FliegendeWurst/googleplay-api.git
synced 2024-11-25 06:14:58 +00:00
Added API to fetch home apps
This commit is contained in:
parent
78113555b5
commit
05170a1e0a
@ -95,6 +95,7 @@ class GooglePlayAPI(object):
|
||||
"X-DFE-Encoded-Targets": config.DFE_TARGETS,
|
||||
"User-Agent": self.deviceBuilder.getUserAgent(),
|
||||
"X-DFE-Client-Id": "am-android-google",
|
||||
"X-DFE-MCCMNC": self.deviceBuilder.device.get('celloperator'),
|
||||
"X-DFE-Network-Type": "4",
|
||||
"X-DFE-Content-Filters": "",
|
||||
"X-DFE-Request-Params": "timeoutMs=4000"}
|
||||
@ -268,7 +269,7 @@ class GooglePlayAPI(object):
|
||||
else:
|
||||
raise LoginError("Auth token not found.")
|
||||
|
||||
def executeRequestApi2(self, path, post_data=None, content_type=None):
|
||||
def executeRequestApi2(self, path, post_data=None, content_type=None, params=None):
|
||||
if self.authSubToken is None:
|
||||
raise Exception("You need to login before executing any request")
|
||||
headers = self.getDefaultHeaders()
|
||||
@ -281,12 +282,14 @@ class GooglePlayAPI(object):
|
||||
response = requests.post(url,
|
||||
data=str(post_data),
|
||||
headers=headers,
|
||||
params=params,
|
||||
verify=ssl_verify,
|
||||
timeout=60,
|
||||
proxies=self.proxies_config)
|
||||
else:
|
||||
response = requests.get(url,
|
||||
headers=headers,
|
||||
params=params,
|
||||
verify=ssl_verify,
|
||||
timeout=60,
|
||||
proxies=self.proxies_config)
|
||||
@ -370,17 +373,30 @@ class GooglePlayAPI(object):
|
||||
if the app doesn't exist"""
|
||||
|
||||
path = "bulkDetails"
|
||||
params = {'au': '1'}
|
||||
req = googleplay_pb2.BulkDetailsRequest()
|
||||
req.docid.extend(packageNames)
|
||||
data = req.SerializeToString()
|
||||
message = self.executeRequestApi2(path,
|
||||
post_data=data.decode("utf-8"),
|
||||
content_type="application/x-protobuf")
|
||||
content_type="application/x-protobuf",
|
||||
params=params)
|
||||
response = message.payload.bulkDetailsResponse
|
||||
return [None if not utils.hasDoc(entry) else
|
||||
utils.fromDocToDictionary(entry.doc)
|
||||
for entry in response.entry]
|
||||
|
||||
def getHomeApps(self):
|
||||
path = "homeV2?c=3&nocache_isui=true"
|
||||
data = self.executeRequestApi2(path)
|
||||
output = []
|
||||
cluster = data.preFetch[0].response.payload.listResponse.cluster[0]
|
||||
for doc in cluster.doc:
|
||||
output.append({"categoryId": doc.docid,
|
||||
"categoryStr": doc.title,
|
||||
"apps": [utils.fromDocToDictionary(c) for c in doc.child]})
|
||||
return output
|
||||
|
||||
def browse(self, cat=None, subCat=None):
|
||||
"""Browse categories. If neither cat nor subcat are specified,
|
||||
return a list of categories, otherwise it return a list of apps
|
||||
|
9
test.py
9
test.py
@ -33,6 +33,15 @@ print('\nFound those apps:\n')
|
||||
for a in apps:
|
||||
print(a['docId'])
|
||||
|
||||
# HOME APPS
|
||||
|
||||
print('\nFetching apps from play store home\n')
|
||||
home = server.getHomeApps()
|
||||
|
||||
for cat in home:
|
||||
print("cat {0} with {1} apps".format(cat.get('categoryId'),
|
||||
str(len(cat.get('apps')))))
|
||||
|
||||
# DOWNLOAD
|
||||
docid = apps[0]['docId']
|
||||
print('\nTelegram docid is: %s\n' % docid)
|
||||
|
Loading…
Reference in New Issue
Block a user