mirror of
https://github.com/FliegendeWurst/googleplay-api.git
synced 2024-10-18 06:50:45 +00:00
Take latest apk if not version specified
If no *versionCode* parameter is specified to *download* or *delivery* methods, fetch the latest one with a simple `self.details(pkgName)`
This commit is contained in:
parent
639c7f9e98
commit
693ae8348f
@ -491,7 +491,7 @@ class GooglePlayAPI(object):
|
||||
bar.done()
|
||||
return response_content
|
||||
|
||||
def delivery(self, packageName, versionCode, offerType=1,
|
||||
def delivery(self, packageName, versionCode=None, offerType=1,
|
||||
downloadToken=None, progress_bar=False, expansion_files=False):
|
||||
"""Download an already purchased app.
|
||||
|
||||
@ -513,6 +513,11 @@ class GooglePlayAPI(object):
|
||||
Data to build this name string is provided in the dict object. For more
|
||||
info check https://developer.android.com/google/play/expansion-files.html
|
||||
"""
|
||||
|
||||
if versionCode is None:
|
||||
# pick up latest version
|
||||
versionCode = self.details(packageName)['versionCode']
|
||||
|
||||
path = "delivery"
|
||||
params = {'ot': str(offerType),
|
||||
'doc': packageName,
|
||||
@ -557,7 +562,7 @@ class GooglePlayAPI(object):
|
||||
result['additionalData'].append(a)
|
||||
return result
|
||||
|
||||
def download(self, packageName, versionCode, offerType=1,
|
||||
def download(self, packageName, versionCode=None, offerType=1,
|
||||
progress_bar=False, expansion_files=False):
|
||||
"""Download an app and return its raw data (APK file). Free apps need
|
||||
to be "purchased" first, in order to retrieve the download cookie.
|
||||
@ -578,6 +583,10 @@ class GooglePlayAPI(object):
|
||||
if self.authSubToken is None:
|
||||
raise Exception("You need to login before executing any request")
|
||||
|
||||
if versionCode is None:
|
||||
# pick up latest version
|
||||
versionCode = self.details(packageName)['versionCode']
|
||||
|
||||
path = "purchase"
|
||||
headers = self.getDefaultHeaders()
|
||||
params = {
|
||||
|
3
test.py
3
test.py
@ -35,10 +35,9 @@ for a in apps:
|
||||
|
||||
# DOWNLOAD
|
||||
docid = apps[0]['docId']
|
||||
version = apps[0]['versionCode']
|
||||
print('\nTelegram docid is: %s\n' % docid)
|
||||
print('\nAttempting to download %s\n' % docid)
|
||||
fl = server.download(docid, version, progress_bar=True)
|
||||
fl = server.download(docid, None, progress_bar=True)
|
||||
with open(docid + '.apk', 'wb') as f:
|
||||
f.write(fl['data'])
|
||||
print('\nDownload successful\n')
|
||||
|
Loading…
Reference in New Issue
Block a user