mirror of
https://github.com/FliegendeWurst/googleplay-api.git
synced 2024-11-22 12:54:58 +00:00
Implemented new Download API
Signed-off-by: Domenico Iezzi <domenico.iezzi.201@gmail.com>
This commit is contained in:
parent
2f68991ad1
commit
361a5777e4
@ -341,7 +341,7 @@ class GooglePlayAPI(object):
|
||||
verify=ssl_verify)
|
||||
data = response.content
|
||||
cluster = googleplay_pb2.SearchClusterResponse.FromString(data)
|
||||
return cluster.preFetch[0].response.wrapper.wrapper.cluster[0]
|
||||
return cluster.preFetch[0].response.wrapper.wrapper.cluster[0].doc[0]
|
||||
|
||||
def details(self, packageName):
|
||||
"""Get app details from a package name.
|
||||
@ -416,40 +416,37 @@ class GooglePlayAPI(object):
|
||||
|
||||
versionCode can be grabbed by using the details() method on the given
|
||||
app."""
|
||||
|
||||
path = "purchase"
|
||||
data = "ot=%d&doc=%s&vc=%d" % (offerType, packageName, versionCode)
|
||||
message = self.executeRequestApi2(path, data)
|
||||
response = message.payload.buyResponse.purchaseStatusResponse
|
||||
if len(response.appDeliveryData.downloadAuthCookie) == 0:
|
||||
|
||||
headers = self.getDefaultHeaders()
|
||||
|
||||
params = {
|
||||
'ot': str(offerType),
|
||||
'doc': packageName,
|
||||
'vc': str(versionCode)
|
||||
}
|
||||
|
||||
url = "https://android.clients.google.com/fdfe/%s" % path
|
||||
response = requests.post(url, headers=headers,
|
||||
params=params, verify=ssl_verify)
|
||||
|
||||
resObj = googleplay_pb2.ResponseWrapper.FromString(response.content)
|
||||
if "ErrorMessage" in str(resObj):
|
||||
raise DecodeError
|
||||
url = response.appDeliveryData.downloadUrl
|
||||
cookie = response.appDeliveryData.downloadAuthCookie[0]
|
||||
|
||||
cookies = {
|
||||
str(cookie.name): str(cookie.value)
|
||||
}
|
||||
|
||||
headers = {
|
||||
"User-Agent": "AndroidDownloadManager/4.4.3 (Linux; U; " +
|
||||
"Android 4.4.3; Nexus S Build/JRO03E)",
|
||||
"Accept-Encoding": "",
|
||||
}
|
||||
|
||||
if not progress_bar:
|
||||
else:
|
||||
dlToken = resObj.payload.buyResponse.downloadToken
|
||||
path = "delivery"
|
||||
params['dtok'] = dlToken
|
||||
url = "https://android.clients.google.com/fdfe/%s" % path
|
||||
response = requests.get(url, headers=headers,
|
||||
cookies=cookies, verify=ssl_verify)
|
||||
return response.content
|
||||
# If progress_bar is asked
|
||||
from clint.textui import progress
|
||||
response_content = str()
|
||||
response = requests.get(url,
|
||||
headers=headers,
|
||||
cookies=cookies,
|
||||
verify=ssl_verify,
|
||||
stream=True)
|
||||
total_length = int(response.headers.get('content-length'))
|
||||
for chunk in progress.bar(response.iter_content(chunk_size=1024),
|
||||
expected_size=(total_length/1024) + 1):
|
||||
if chunk:
|
||||
response_content += chunk
|
||||
return response_content
|
||||
params=params, verify=ssl_verify)
|
||||
resObj = googleplay_pb2.ResponseWrapper.FromString(response.content)
|
||||
downloadUrl = resObj.payload.deliveryResponse.appDeliveryData.downloadUrl
|
||||
cookie = resObj.payload.deliveryResponse.appDeliveryData.downloadAuthCookie[0]
|
||||
cookies = {
|
||||
str(cookie.name): str(cookie.value)
|
||||
}
|
||||
return requests.get(downloadUrl, headers=headers,
|
||||
cookies=cookies, verify=ssl_verify).content
|
||||
|
||||
|
3
requiremets.txt
Normal file
3
requiremets.txt
Normal file
@ -0,0 +1,3 @@
|
||||
protobuf
|
||||
requests
|
||||
pycrypto
|
15
test.py
15
test.py
@ -8,9 +8,18 @@ GSFID = 0
|
||||
server = GooglePlayAPI(True)
|
||||
if AC2DM == "":
|
||||
server.login(EMAIL, PASSWD, None, None)
|
||||
print(server.search('firefox', 1, None))
|
||||
print(server.search('firefox', 1, None).child[0])
|
||||
print(server.bulkDetails(['com.mozilla.firefox']))
|
||||
fl = server.download('com.cpuid.cpu_z', 23)
|
||||
with open('com.cpuid.cpu_z.apk', 'wb') as f:
|
||||
f.write(fl)
|
||||
f.close()
|
||||
else:
|
||||
server.gsfId = GSFID
|
||||
server.login(EMAIL, PASSWD, AC2DM, GSFID)
|
||||
print(server.search('firefox', 1, None).doc[0].child[0])
|
||||
print(server.download('org.telegram.messenger', 10853))
|
||||
print(server.search('firefox', 1, None).child[0])
|
||||
print(server.bulkDetails(['com.mozilla.firefox']))
|
||||
fl = server.download('com.cpuid.cpu_z', 23)
|
||||
with open('com.cpuid.cpu_z.apk', 'wb') as f:
|
||||
f.write(fl)
|
||||
f.close()
|
||||
|
Loading…
Reference in New Issue
Block a user