diff --git a/.gitignore b/.gitignore index 439b380..e66e0b0 100644 --- a/.gitignore +++ b/.gitignore @@ -6,3 +6,4 @@ __pycache__/ build/ dist/ *.egg-info/ +.idea/ diff --git a/gpapi/googleplay.py b/gpapi/googleplay.py index e10caa2..7ab0f7a 100644 --- a/gpapi/googleplay.py +++ b/gpapi/googleplay.py @@ -45,9 +45,12 @@ class GooglePlayAPI(object): CHECKINURL = BASE + "checkin" AUTHURL = BASE + "auth" + proxies_config = None + def __init__(self, debug=False, device_codename='bacon', locale=None, timezone=None, - sim_operator=None, cell_operator=None): + sim_operator=None, cell_operator=None, + proxies_config=proxies_config): self.authSubToken = None self.gsfId = None self.debug = debug @@ -110,7 +113,8 @@ class GooglePlayAPI(object): stringRequest = request.SerializeToString() res = requests.post(self.CHECKINURL, data=stringRequest, - headers=headers, verify=ssl_verify) + headers=headers, verify=ssl_verify, + proxies=self.proxies_config) response = googleplay_pb2.AndroidCheckinResponse() response.ParseFromString(res.content) @@ -123,7 +127,8 @@ class GooglePlayAPI(object): request2.accountCookie.append(ac2dmToken) stringRequest = request2.SerializeToString() requests.post(self.CHECKINURL, data=stringRequest, - headers=headers, verify=ssl_verify) + headers=headers, verify=ssl_verify, + proxies=self.proxies_config) return response.androidId @@ -141,7 +146,8 @@ class GooglePlayAPI(object): headers["X-DFE-Filter-Level"] = "3" stringRequest = upload.SerializeToString() res = requests.post(self.UPLOADURL, data=stringRequest, - headers=headers, verify=ssl_verify) + headers=headers, verify=ssl_verify, + proxies=self.proxies_config) googleplay_pb2.ResponseWrapper.FromString(res.content) def login(self, email=None, password=None, gsfId=None, authSubToken=None): @@ -159,7 +165,8 @@ class GooglePlayAPI(object): encryptedPass = self.encrypt_password(email, password).decode('utf-8') # AC2DM token params = self.deviceBuilder.getLoginParams(email, encryptedPass) - response = requests.post(self.AUTHURL, data=params, verify=ssl_verify) + response = requests.post(self.AUTHURL, data=params, verify=ssl_verify, + proxies=self.proxies_config) data = response.text.split() params = {} for d in data: @@ -196,7 +203,8 @@ class GooglePlayAPI(object): def getAuthSubToken(self, email, passwd): requestParams = self.deviceBuilder.getAuthParams(email, passwd) - response = requests.post(self.AUTHURL, data=requestParams, verify=ssl_verify) + response = requests.post(self.AUTHURL, data=requestParams, verify=ssl_verify, + proxies=self.proxies_config) data = response.text.split() params = {} for d in data: @@ -227,7 +235,8 @@ class GooglePlayAPI(object): previousParams.pop('EncryptedPasswd') response = requests.post(self.AUTHURL, data=previousParams, - verify=ssl_verify) + verify=ssl_verify, + proxies=self.proxies_config) data = response.text.split() params = {} for d in data: @@ -255,11 +264,13 @@ class GooglePlayAPI(object): if datapost is not None: response = requests.post(url, data=str(datapost), headers=headers, verify=ssl_verify, - timeout=60) + timeout=60, + proxies=self.proxies_config) else: response = requests.get(url, headers=headers, verify=ssl_verify, - timeout=60) + timeout=60, + proxies=self.proxies_config) message = googleplay_pb2.ResponseWrapper.FromString(response.content) if message.commands.displayErrorMessage != "": @@ -457,11 +468,13 @@ class GooglePlayAPI(object): if not progress_bar: return requests.get(url, headers=headers, cookies=cookies, verify=ssl_verify, - timeout=60).content + timeout=60, + proxies=self.proxies_config).content response_content = bytes() response = requests.get(url, headers=headers, cookies=cookies, verify=ssl_verify, - stream=True, timeout=60) + stream=True, timeout=60, + proxies=self.proxies_config) total_length = int(response.headers.get('content-length')) chunk_size = 32 * (1 << 10) # 32 KB bar = progress.Bar(expected_size=(total_length >> 10)) @@ -508,7 +521,8 @@ class GooglePlayAPI(object): url = "https://android.clients.google.com/fdfe/%s" % path response = requests.get(url, headers=headers, params=params, verify=ssl_verify, - timeout=60) + timeout=60, + proxies=self.proxies_config) resObj = googleplay_pb2.ResponseWrapper.FromString(response.content) if resObj.commands.displayErrorMessage != "": raise RequestError(resObj.commands.displayErrorMessage) @@ -573,7 +587,8 @@ class GooglePlayAPI(object): url = self.FDFE + path response = requests.post(url, headers=headers, params=params, verify=ssl_verify, - timeout=60) + timeout=60, + proxies=self.proxies_config) resObj = googleplay_pb2.ResponseWrapper.FromString(response.content) if resObj.commands.displayErrorMessage != "":