mirror of
https://github.com/FliegendeWurst/googleplay-api.git
synced 2024-11-22 21:04:59 +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)
|
verify=ssl_verify)
|
||||||
data = response.content
|
data = response.content
|
||||||
cluster = googleplay_pb2.SearchClusterResponse.FromString(data)
|
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):
|
def details(self, packageName):
|
||||||
"""Get app details from a package name.
|
"""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
|
versionCode can be grabbed by using the details() method on the given
|
||||||
app."""
|
app."""
|
||||||
|
|
||||||
path = "purchase"
|
path = "purchase"
|
||||||
data = "ot=%d&doc=%s&vc=%d" % (offerType, packageName, versionCode)
|
|
||||||
message = self.executeRequestApi2(path, data)
|
headers = self.getDefaultHeaders()
|
||||||
response = message.payload.buyResponse.purchaseStatusResponse
|
|
||||||
if len(response.appDeliveryData.downloadAuthCookie) == 0:
|
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
|
raise DecodeError
|
||||||
url = response.appDeliveryData.downloadUrl
|
else:
|
||||||
cookie = response.appDeliveryData.downloadAuthCookie[0]
|
dlToken = resObj.payload.buyResponse.downloadToken
|
||||||
|
path = "delivery"
|
||||||
cookies = {
|
params['dtok'] = dlToken
|
||||||
str(cookie.name): str(cookie.value)
|
url = "https://android.clients.google.com/fdfe/%s" % path
|
||||||
}
|
|
||||||
|
|
||||||
headers = {
|
|
||||||
"User-Agent": "AndroidDownloadManager/4.4.3 (Linux; U; " +
|
|
||||||
"Android 4.4.3; Nexus S Build/JRO03E)",
|
|
||||||
"Accept-Encoding": "",
|
|
||||||
}
|
|
||||||
|
|
||||||
if not progress_bar:
|
|
||||||
response = requests.get(url, headers=headers,
|
response = requests.get(url, headers=headers,
|
||||||
cookies=cookies, verify=ssl_verify)
|
params=params, verify=ssl_verify)
|
||||||
return response.content
|
resObj = googleplay_pb2.ResponseWrapper.FromString(response.content)
|
||||||
# If progress_bar is asked
|
downloadUrl = resObj.payload.deliveryResponse.appDeliveryData.downloadUrl
|
||||||
from clint.textui import progress
|
cookie = resObj.payload.deliveryResponse.appDeliveryData.downloadAuthCookie[0]
|
||||||
response_content = str()
|
cookies = {
|
||||||
response = requests.get(url,
|
str(cookie.name): str(cookie.value)
|
||||||
headers=headers,
|
}
|
||||||
cookies=cookies,
|
return requests.get(downloadUrl, headers=headers,
|
||||||
verify=ssl_verify,
|
cookies=cookies, verify=ssl_verify).content
|
||||||
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
|
|
||||||
|
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)
|
server = GooglePlayAPI(True)
|
||||||
if AC2DM == "":
|
if AC2DM == "":
|
||||||
server.login(EMAIL, PASSWD, None, None)
|
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:
|
else:
|
||||||
server.gsfId = GSFID
|
server.gsfId = GSFID
|
||||||
server.login(EMAIL, PASSWD, AC2DM, GSFID)
|
server.login(EMAIL, PASSWD, AC2DM, GSFID)
|
||||||
print(server.search('firefox', 1, None).doc[0].child[0])
|
print(server.search('firefox', 1, None).child[0])
|
||||||
print(server.download('org.telegram.messenger', 10853))
|
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