From 7f0fad78ef24b2f8e101ac48ab3d7aadcccd38e9 Mon Sep 17 00:00:00 2001 From: Domenico Iezzi Date: Sat, 27 Jan 2018 19:42:36 +0100 Subject: [PATCH] Added functions to change locale Locale and Timezone can be changed even during a session, and results will change accordingly --- gpapi/config.py | 2 +- gpapi/googleplay.py | 8 +++++++- test.py | 4 ++-- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/gpapi/config.py b/gpapi/config.py index 432d8df..f2b5586 100644 --- a/gpapi/config.py +++ b/gpapi/config.py @@ -48,7 +48,7 @@ class DeviceBuilder(object): for (key, value) in config.items(device): self.device[key] = value - def setLocale(self, locale): + def set_locale(self, locale): # test if provided locale is valid if locale is None or type(locale) is not str: raise Exception('Wrong locale supplied') diff --git a/gpapi/googleplay.py b/gpapi/googleplay.py index 5dbc960..3cba6dc 100644 --- a/gpapi/googleplay.py +++ b/gpapi/googleplay.py @@ -53,7 +53,13 @@ class GooglePlayAPI(object): self.debug = debug self.proxies_config = proxies_config 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) def encrypt_password(self, login, passwd): diff --git a/test.py b/test.py index 2cfcb8d..109cadd 100644 --- a/test.py +++ b/test.py @@ -9,7 +9,7 @@ ap.add_argument('-p', '--password', dest='password', help='google password') args = ap.parse_args() -server = GooglePlayAPI(debug=True, locale='it_IT', timezone='Europe/Rome') +server = GooglePlayAPI('it_IT', 'Europe/Rome', debug=True) # LOGIN @@ -19,7 +19,7 @@ gsfId = server.gsfId authSubToken = server.authSubToken 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) # SEARCH