diff --git a/.gitignore b/.gitignore index 19767b9..b010015 100644 --- a/.gitignore +++ b/.gitignore @@ -7,3 +7,6 @@ # ignore downloaded apps *.apk + +config.py +.DS_Store diff --git a/__init__.py b/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/config.py b/config.py.sample similarity index 100% rename from config.py rename to config.py.sample diff --git a/download.py b/download.py index 7a6ba42..bb190e4 100755 --- a/download.py +++ b/download.py @@ -36,6 +36,8 @@ # Download print "Downloading %s..." % sizeof_fmt(doc.details.appDetails.installationSize), data = api.download(packagename, vc, ot) -open(filename, "wb").write(data) -print "Done" - +if data: + open(filename, "wb").write(data) + print "Done" +else: + print "Error" diff --git a/googleplay.py b/googleplay.py index aba1e72..585adcd 100644 --- a/googleplay.py +++ b/googleplay.py @@ -127,7 +127,9 @@ def login(self, email=None, password=None, authSubToken=None): params = {} for d in data: if not "=" in d: continue - k, v = d.split("=") + v_len = d.find('=') + 1 + k = d.split("=")[0] + v = d[v_len:] params[k.strip().lower()] = v.strip() if "auth" in params: self.setAuthSubToken(params["auth"]) @@ -219,10 +221,11 @@ def browse(self, cat=None, ctr=None): path += "&cat=%s" % requests.utils.quote(cat) if (ctr != None): path += "&ctr=%s" % requests.utils.quote(ctr) + message = self.executeRequestApi2(path) return message.payload.browseResponse - def list(self, cat, ctr=None, nb_results=None, offset=None): + def list(self, cat, ctr=None, nb_results=None, offset=None, ctntkn=None): """List apps. If ctr (subcategory ID) is None, returns a list of valid subcategories. @@ -232,9 +235,12 @@ def list(self, cat, ctr=None, nb_results=None, offset=None): if (ctr != None): path += "&ctr=%s" % requests.utils.quote(ctr) if (nb_results != None): - path += "&n=%s" % requests.utils.quote(nb_results) + path += "&n=%s" % int(nb_results) if (offset != None): - path += "&o=%s" % requests.utils.quote(offset) + path += "&o=%s" % int(offset) + if (ctntkn != None): + path += "&ctntkn=%s" % requests.utils.quote(ctntkn) + message = self.executeRequestApi2(path) return message.payload.listResponse @@ -264,8 +270,13 @@ def download(self, packageName, versionCode, offerType=1): message = self.executeRequestApi2(path, data) url = message.payload.buyResponse.purchaseStatusResponse.appDeliveryData.downloadUrl - cookie = message.payload.buyResponse.purchaseStatusResponse.appDeliveryData.downloadAuthCookie[0] - + cookie = message.payload.buyResponse.purchaseStatusResponse.appDeliveryData.downloadAuthCookie + + if len(cookie) > 0: + cookie = cookie[0] + else: + return False + cookies = { str(cookie.name): str(cookie.value) # python-requests #459 fixes this } diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..c98fc6c --- /dev/null +++ b/requirements.txt @@ -0,0 +1,4 @@ +protobuf==3.0.0 +requests==2.10.0 +six==1.10.0 +wheel==0.24.0