Skip to content

Commit

Permalink
Added functions to change locale
Browse files Browse the repository at this point in the history
Locale and Timezone can be changed even during a session, and results
will change accordingly
  • Loading branch information
Domenico Iezzi committed Jan 27, 2018
1 parent 2e4166f commit 7f0fad7
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
2 changes: 1 addition & 1 deletion gpapi/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ def __init__(self, device):
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')
Expand Down
8 changes: 7 additions & 1 deletion gpapi/googleplay.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,13 @@ def __init__(self, locale, timezone, debug=False, device_codename='bacon',
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):
Expand Down
4 changes: 2 additions & 2 deletions test.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

args = ap.parse_args()

server = GooglePlayAPI(debug=True, locale='it_IT', timezone='Europe/Rome')
server = GooglePlayAPI('it_IT', 'Europe/Rome', debug=True)

# LOGIN

Expand All @@ -19,7 +19,7 @@
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
Expand Down

0 comments on commit 7f0fad7

Please sign in to comment.