mirror of
https://github.com/FliegendeWurst/googleplay-api.git
synced 2024-11-22 12:54:58 +00:00
Added log function
This function is needed by the purchase API to insert app into user's library. Without this, new apps won't be downloaded
This commit is contained in:
parent
15cf326184
commit
d984a92dc7
@ -9,6 +9,7 @@ from Crypto.Cipher import PKCS1_OAEP
|
||||
import requests
|
||||
from base64 import b64decode, urlsafe_b64encode
|
||||
from itertools import chain
|
||||
from datetime import datetime
|
||||
|
||||
from . import googleplay_pb2, config, utils
|
||||
|
||||
@ -43,6 +44,7 @@ class GooglePlayAPI(object):
|
||||
SEARCHURL = FDFE + "search"
|
||||
CHECKINURL = BASE + "checkin"
|
||||
AUTHURL = BASE + "auth"
|
||||
LOGURL = FDFE + "log"
|
||||
|
||||
proxies_config = None
|
||||
|
||||
@ -613,6 +615,7 @@ class GooglePlayAPI(object):
|
||||
'doc': packageName,
|
||||
'vc': str(versionCode)}
|
||||
url = self.FDFE + path
|
||||
self.log(packageName)
|
||||
response = requests.post(url, headers=headers,
|
||||
params=params, verify=ssl_verify,
|
||||
timeout=60,
|
||||
@ -626,6 +629,24 @@ class GooglePlayAPI(object):
|
||||
return self.delivery(packageName, versionCode, offerType, dlToken,
|
||||
expansion_files=expansion_files)
|
||||
|
||||
def log(self, docid):
|
||||
log_request = googleplay_pb2.LogRequest()
|
||||
log_request.downloadConfirmationQuery = "confirmFreeDownload?doc=" + docid
|
||||
timestamp = int(datetime.now().timestamp())
|
||||
log_request.timestamp = timestamp
|
||||
|
||||
string_request = log_request.SerializeToString()
|
||||
response = requests.post(self.LOGURL,
|
||||
data=string_request,
|
||||
headers=self.getDefaultHeaders(),
|
||||
verify=ssl_verify,
|
||||
timeout=60,
|
||||
proxies=self.proxies_config)
|
||||
response = googleplay_pb2.ResponseWrapper.FromString(response.content)
|
||||
if response.commands.displayErrorMessage != "":
|
||||
raise RequestError(resObj.commands.displayErrorMessage)
|
||||
|
||||
|
||||
@staticmethod
|
||||
def getDevicesCodenames():
|
||||
return config.getDevicesCodenames()
|
||||
|
@ -17,7 +17,7 @@ server.login(args.email, args.password, None, None)
|
||||
docid = 'com.pixel.gun3d'
|
||||
|
||||
print('\nDownloading apk\n')
|
||||
download = server.delivery(docid, versionCode=None, expansion_files=True)
|
||||
download = server.download(docid, expansion_files=True)
|
||||
with open(download['docId'] + '.apk', 'wb') as first:
|
||||
for chunk in download.get('file').get('data'):
|
||||
first.write(chunk)
|
||||
|
2
test.py
2
test.py
@ -37,7 +37,7 @@ for a in apps:
|
||||
docid = apps[0]['docId']
|
||||
print('\nTelegram docid is: %s\n' % docid)
|
||||
print('\nAttempting to download %s\n' % docid)
|
||||
fl = server.delivery(docid, versionCode=None)
|
||||
fl = server.download(docid)
|
||||
with open(docid + '.apk', 'wb') as apk_file:
|
||||
for chunk in fl.get('file').get('data'):
|
||||
apk_file.write(chunk)
|
||||
|
Loading…
Reference in New Issue
Block a user