mirror of
https://github.com/FliegendeWurst/googleplay-api.git
synced 2024-11-22 12:54:58 +00:00
Integrity check before returning lists
In order to catch invalid tokens, an additional integrity check is done before returning lists in details() and bulkDetails() functions. If the check doesn't pass, raise a LoginError.
This commit is contained in:
parent
e1acc14424
commit
866c633b1c
@ -203,6 +203,11 @@ class GooglePlayAPI(object):
|
||||
else:
|
||||
raise LoginError("Auth token not found.")
|
||||
|
||||
def _check_response_integrity(self, apps):
|
||||
if any([a['docId'] == '' for a in apps]):
|
||||
raise LoginError('Unexpected behaviour, probably expired '
|
||||
'token')
|
||||
|
||||
def executeRequestApi2(self, path, datapost=None,
|
||||
post_content_type="application/x-www-form-urlencoded; charset=UTF-8"):
|
||||
if self.authSubToken is None:
|
||||
@ -283,6 +288,7 @@ class GooglePlayAPI(object):
|
||||
path = "details?doc=%s" % requests.utils.quote(packageName)
|
||||
data = self.executeRequestApi2(path)
|
||||
app = utils.fromDocToDictionary(data.payload.detailsResponse.docV2)
|
||||
self._check_response_integrity([app])
|
||||
return app
|
||||
|
||||
def bulkDetails(self, packageNames):
|
||||
@ -303,6 +309,7 @@ class GooglePlayAPI(object):
|
||||
response = message.payload.bulkDetailsResponse
|
||||
detailsList = [entry.doc for entry in response.entry]
|
||||
result = list(map(utils.fromDocToDictionary, detailsList))
|
||||
self._check_response_integrity(result)
|
||||
return result
|
||||
|
||||
def browse(self, cat=None, subCat=None):
|
||||
|
Loading…
Reference in New Issue
Block a user