Added functions to change locale

Locale and Timezone can be changed even during a session, and results
will change accordingly
This commit is contained in:
Domenico Iezzi 2018-01-27 19:42:36 +01:00
parent 2e4166f4e5
commit 7f0fad78ef
No known key found for this signature in database
GPG Key ID: 7AC94D5DDA2FB7EE
3 changed files with 10 additions and 4 deletions

View File

@ -48,7 +48,7 @@ class DeviceBuilder(object):
for (key, value) in config.items(device): for (key, value) in config.items(device):
self.device[key] = value self.device[key] = value
def setLocale(self, locale): def set_locale(self, locale):
# test if provided locale is valid # test if provided locale is valid
if locale is None or type(locale) is not str: if locale is None or type(locale) is not str:
raise Exception('Wrong locale supplied') raise Exception('Wrong locale supplied')

View File

@ -53,7 +53,13 @@ class GooglePlayAPI(object):
self.debug = debug self.debug = debug
self.proxies_config = proxies_config self.proxies_config = proxies_config
self.deviceBuilder = config.DeviceBuilder(device_codename) self.deviceBuilder = config.DeviceBuilder(device_codename)
self.deviceBuilder.setLocale(locale) self.set_locale(locale)
self.set_timezone(timezone)
def set_locale(self, locale):
self.deviceBuilder.set_locale(locale)
def set_timezone(self, timezone):
self.deviceBuilder.set_timezone(timezone) self.deviceBuilder.set_timezone(timezone)
def encrypt_password(self, login, passwd): def encrypt_password(self, login, passwd):

View File

@ -9,7 +9,7 @@ ap.add_argument('-p', '--password', dest='password', help='google password')
args = ap.parse_args() args = ap.parse_args()
server = GooglePlayAPI(debug=True, locale='it_IT', timezone='Europe/Rome') server = GooglePlayAPI('it_IT', 'Europe/Rome', debug=True)
# LOGIN # LOGIN
@ -19,7 +19,7 @@ gsfId = server.gsfId
authSubToken = server.authSubToken authSubToken = server.authSubToken
print('\nNow trying secondary login with ac2dm token and gsfId saved\n') print('\nNow trying secondary login with ac2dm token and gsfId saved\n')
server = GooglePlayAPI(debug=True, locale='it_IT', timezone='Europe/Rome') server = GooglePlayAPI('it_IT', 'Europe/Rome', debug=True)
server.login(None, None, gsfId, authSubToken) server.login(None, None, gsfId, authSubToken)
# SEARCH # SEARCH