_delivery_data returns more information

This commit is contained in:
Domenico Iezzi 2018-01-27 18:39:40 +01:00
parent e05d126f6b
commit 0a13755ff9
No known key found for this signature in database
GPG Key ID: 7AC94D5DDA2FB7EE
3 changed files with 17 additions and 8 deletions

View File

@ -502,7 +502,11 @@ class GooglePlayAPI(object):
cookies=cookies, verify=ssl_verify,
stream=True, timeout=60,
proxies=self.proxies_config)
return response.iter_content(chunk_size=(32 * 1 << 10))
total_size = response.headers.get('content-length')
chunk_size = 32 * (1 << 10)
return {'data': response.iter_content(chunk_size=chunk_size),
'total_size': total_size,
'chunk_size': chunk_size}
def delivery(self, packageName, versionCode=None, offerType=1,
downloadToken=None, expansion_files=False):
@ -557,7 +561,7 @@ class GooglePlayAPI(object):
cookies = {
str(cookie.name): str(cookie.value)
}
result['data'] = self._deliver_data(downloadUrl, cookies)
result['file'] = self._deliver_data(downloadUrl, cookies)
if not expansion_files:
return result
for obb in resObj.payload.deliveryResponse.appDeliveryData.additionalFile:
@ -570,7 +574,7 @@ class GooglePlayAPI(object):
obbType = 'patch'
a['type'] = obbType
a['versionCode'] = obb.versionCode
a['data'] = self._deliver_data(obb.downloadUrl, None)
a['file'] = self._deliver_data(obb.downloadUrl, None)
result['additionalData'].append(a)
return result

View File

@ -8,20 +8,25 @@ ap.add_argument('-p', '--password', dest='password', help='google password')
args = ap.parse_args()
server = GooglePlayAPI(debug=True)
server = GooglePlayAPI(debug=True, locale='it_IT', timezone='Europe/Rome')
# LOGIN
print('\nLogging in with email and password\n')
server.login(args.email, args.password, None, None)
docid = 'com.pixel.gun3d'
download = server.download('com.mapswithme.maps.pro', 1754, progress_bar=True, expansion_files=True)
print('\nDownloading apk\n')
download = server.delivery(docid, versionCode=None, expansion_files=True)
with open(download['docId'] + '.apk', 'wb') as first:
first.write(download['data'])
for chunk in download.get('file').get('data'):
first.write(chunk)
print('\nDownloading additional files\n')
for obb in download['additionalData']:
name = obb['type'] + '.' + str(obb['versionCode']) + '.' + download['docId'] + '.obb'
with open(name, 'wb') as second:
second.write(obb['data'])
for chunk in obb.get('file').get('data'):
second.write(chunk)
print('\nDownload successful\n')

View File

@ -39,7 +39,7 @@ print('\nTelegram docid is: %s\n' % docid)
print('\nAttempting to download %s\n' % docid)
fl = server.delivery(docid, versionCode=None)
with open(docid + '.apk', 'wb') as apk_file:
for chunk in fl.get('data'):
for chunk in fl.get('file').get('data'):
apk_file.write(chunk)
print('\nDownload successful\n')