Revert "Added proxy config for requests"

This reverts commit d422074ea8.
This commit is contained in:
Domenico Iezzi 2017-12-09 09:41:07 +01:00
parent 6e8a02527b
commit b99ceb8410
2 changed files with 25 additions and 42 deletions

1
.gitignore vendored
View File

@ -6,4 +6,3 @@ __pycache__/
build/ build/
dist/ dist/
*.egg-info/ *.egg-info/
.idea/

View File

@ -1,15 +1,15 @@
#!/usr/bin/python #!/usr/bin/python
from base64 import b64decode, urlsafe_b64encode from Crypto.Util import asn1
from itertools import chain from Crypto.PublicKey import RSA
from Crypto.Hash import SHA
from Crypto.Cipher import PKCS1_OAEP
from clint.textui import progress
import requests import requests
from Crypto.Cipher import PKCS1_OAEP from base64 import b64decode, urlsafe_b64encode
from Crypto.Hash import SHA from itertools import chain
from Crypto.PublicKey import RSA
from Crypto.Util import asn1
from clint.textui import progress
from . import googleplay_pb2, config, utils from . import googleplay_pb2, config, utils
@ -45,12 +45,9 @@ class GooglePlayAPI(object):
CHECKINURL = BASE + "checkin" CHECKINURL = BASE + "checkin"
AUTHURL = BASE + "auth" AUTHURL = BASE + "auth"
proxies_config = None
def __init__(self, debug=False, device_codename='bacon', def __init__(self, debug=False, device_codename='bacon',
locale=None, timezone=None, locale=None, timezone=None,
sim_operator=None, cell_operator=None, sim_operator=None, cell_operator=None):
proxies_config=proxies_config):
self.authSubToken = None self.authSubToken = None
self.gsfId = None self.gsfId = None
self.debug = debug self.debug = debug
@ -71,8 +68,8 @@ class GooglePlayAPI(object):
binaryKey = b64decode(config.GOOGLE_PUBKEY) binaryKey = b64decode(config.GOOGLE_PUBKEY)
i = utils.readInt(binaryKey, 0) i = utils.readInt(binaryKey, 0)
modulus = utils.toBigInt(binaryKey[4:][0:i]) modulus = utils.toBigInt(binaryKey[4:][0:i])
j = utils.readInt(binaryKey, i + 4) j = utils.readInt(binaryKey, i+4)
exponent = utils.toBigInt(binaryKey[i + 8:][0:j]) exponent = utils.toBigInt(binaryKey[i+8:][0:j])
seq = asn1.DerSequence() seq = asn1.DerSequence()
seq.append(modulus) seq.append(modulus)
@ -113,8 +110,7 @@ class GooglePlayAPI(object):
stringRequest = request.SerializeToString() stringRequest = request.SerializeToString()
res = requests.post(self.CHECKINURL, data=stringRequest, 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 = googleplay_pb2.AndroidCheckinResponse()
response.ParseFromString(res.content) response.ParseFromString(res.content)
@ -127,8 +123,7 @@ class GooglePlayAPI(object):
request2.accountCookie.append(ac2dmToken) request2.accountCookie.append(ac2dmToken)
stringRequest = request2.SerializeToString() stringRequest = request2.SerializeToString()
requests.post(self.CHECKINURL, data=stringRequest, requests.post(self.CHECKINURL, data=stringRequest,
headers=headers, verify=ssl_verify, headers=headers, verify=ssl_verify)
proxies=self.proxies_config, )
return response.androidId return response.androidId
@ -140,15 +135,13 @@ class GooglePlayAPI(object):
upload.deviceConfiguration.CopyFrom(self.deviceBuilder.getDeviceConfig()) upload.deviceConfiguration.CopyFrom(self.deviceBuilder.getDeviceConfig())
headers = self.getDefaultHeaders() headers = self.getDefaultHeaders()
headers["X-DFE-Enabled-Experiments"] = "cl:billing.select_add_instrument_by_default" headers["X-DFE-Enabled-Experiments"] = "cl:billing.select_add_instrument_by_default"
headers[ headers["X-DFE-Unsupported-Experiments"] = "nocache:billing.use_charging_poller,market_emails,buyer_currency,prod_baseline,checkin.set_asset_paid_app_field,shekel_test,content_ratings,buyer_currency_in_app,nocache:encrypted_apk,recent_changes"
"X-DFE-Unsupported-Experiments"] = "nocache:billing.use_charging_poller,market_emails,buyer_currency,prod_baseline,checkin.set_asset_paid_app_field,shekel_test,content_ratings,buyer_currency_in_app,nocache:encrypted_apk,recent_changes"
headers["X-DFE-Client-Id"] = "am-android-google" headers["X-DFE-Client-Id"] = "am-android-google"
headers["X-DFE-SmallestScreenWidthDp"] = "320" headers["X-DFE-SmallestScreenWidthDp"] = "320"
headers["X-DFE-Filter-Level"] = "3" headers["X-DFE-Filter-Level"] = "3"
stringRequest = upload.SerializeToString() stringRequest = upload.SerializeToString()
res = requests.post(self.UPLOADURL, data=stringRequest, 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) googleplay_pb2.ResponseWrapper.FromString(res.content)
def login(self, email=None, password=None, gsfId=None, authSubToken=None): def login(self, email=None, password=None, gsfId=None, authSubToken=None):
@ -166,8 +159,7 @@ class GooglePlayAPI(object):
encryptedPass = self.encrypt_password(email, password).decode('utf-8') encryptedPass = self.encrypt_password(email, password).decode('utf-8')
# AC2DM token # AC2DM token
params = self.deviceBuilder.getLoginParams(email, encryptedPass) 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() data = response.text.split()
params = {} params = {}
for d in data: for d in data:
@ -204,8 +196,7 @@ class GooglePlayAPI(object):
def getAuthSubToken(self, email, passwd): def getAuthSubToken(self, email, passwd):
requestParams = self.deviceBuilder.getAuthParams(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() data = response.text.split()
params = {} params = {}
for d in data: for d in data:
@ -236,8 +227,7 @@ class GooglePlayAPI(object):
previousParams.pop('EncryptedPasswd') previousParams.pop('EncryptedPasswd')
response = requests.post(self.AUTHURL, response = requests.post(self.AUTHURL,
data=previousParams, data=previousParams,
verify=ssl_verify, verify=ssl_verify)
proxies=self.proxies_config, )
data = response.text.split() data = response.text.split()
params = {} params = {}
for d in data: for d in data:
@ -265,13 +255,11 @@ class GooglePlayAPI(object):
if datapost is not None: if datapost is not None:
response = requests.post(url, data=str(datapost), response = requests.post(url, data=str(datapost),
headers=headers, verify=ssl_verify, headers=headers, verify=ssl_verify,
timeout=60, timeout=60)
proxies=self.proxies_config, )
else: else:
response = requests.get(url, headers=headers, response = requests.get(url, headers=headers,
verify=ssl_verify, verify=ssl_verify,
timeout=60, timeout=60)
proxies=self.proxies_config, )
message = googleplay_pb2.ResponseWrapper.FromString(response.content) message = googleplay_pb2.ResponseWrapper.FromString(response.content)
if message.commands.displayErrorMessage != "": if message.commands.displayErrorMessage != "":
@ -445,7 +433,7 @@ class GooglePlayAPI(object):
path += "&n=%d" % int(nb_results) path += "&n=%d" % int(nb_results)
if (offset is not None): if (offset is not None):
path += "&o=%d" % int(offset) path += "&o=%d" % int(offset)
if (filterByDevice): if(filterByDevice):
path += "&dfil=1" path += "&dfil=1"
data = self.executeRequestApi2(path) data = self.executeRequestApi2(path)
output = [] output = []
@ -469,13 +457,11 @@ class GooglePlayAPI(object):
if not progress_bar: if not progress_bar:
return requests.get(url, headers=headers, return requests.get(url, headers=headers,
cookies=cookies, verify=ssl_verify, cookies=cookies, verify=ssl_verify,
timeout=60, timeout=60).content
proxies=self.proxies_config, ).content
response_content = bytes() response_content = bytes()
response = requests.get(url, headers=headers, response = requests.get(url, headers=headers,
cookies=cookies, verify=ssl_verify, 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')) total_length = int(response.headers.get('content-length'))
chunk_size = 32 * (1 << 10) # 32 KB chunk_size = 32 * (1 << 10) # 32 KB
bar = progress.Bar(expected_size=(total_length >> 10)) bar = progress.Bar(expected_size=(total_length >> 10))
@ -522,8 +508,7 @@ class GooglePlayAPI(object):
url = "https://android.clients.google.com/fdfe/%s" % path url = "https://android.clients.google.com/fdfe/%s" % path
response = requests.get(url, headers=headers, response = requests.get(url, headers=headers,
params=params, verify=ssl_verify, params=params, verify=ssl_verify,
timeout=60, timeout=60)
proxies=self.proxies_config, )
resObj = googleplay_pb2.ResponseWrapper.FromString(response.content) resObj = googleplay_pb2.ResponseWrapper.FromString(response.content)
if resObj.commands.displayErrorMessage != "": if resObj.commands.displayErrorMessage != "":
raise RequestError(resObj.commands.displayErrorMessage) raise RequestError(resObj.commands.displayErrorMessage)
@ -588,8 +573,7 @@ class GooglePlayAPI(object):
url = self.FDFE + path url = self.FDFE + path
response = requests.post(url, headers=headers, response = requests.post(url, headers=headers,
params=params, verify=ssl_verify, params=params, verify=ssl_verify,
timeout=60, timeout=60)
proxies=self.proxies_config, )
resObj = googleplay_pb2.ResponseWrapper.FromString(response.content) resObj = googleplay_pb2.ResponseWrapper.FromString(response.content)
if resObj.commands.displayErrorMessage != "": if resObj.commands.displayErrorMessage != "":