Crash with ValueError: too many values to unpack when google token contains = char
I'm using GooglePlayDownloader v2.3 on Archlinux
My GooglePlayDownloader crash today with the following stacktrace:
Traceback (most recent call last):
File "/usr/lib/python2.7/site-packages/googleplaydownloader/googleplaydownloader.py", line 650, in <module>
main()
File "/usr/lib/python2.7/site-packages/googleplaydownloader/googleplaydownloader.py", line 637, in main
app = App()
File "/usr/lib/python2.7/site-packages/wx-3.0-gtk2/wx/_core.py", line 8628, in __init__
self._BootstrapApp()
File "/usr/lib/python2.7/site-packages/wx-3.0-gtk2/wx/_core.py", line 8196, in _BootstrapApp
return _core_.PyApp__BootstrapApp(*args, **kwargs)
File "/usr/lib/python2.7/site-packages/googleplaydownloader/googleplaydownloader.py", line 627, in OnInit
fen = MainFrame(self, title)
File "/usr/lib/python2.7/site-packages/googleplaydownloader/googleplaydownloader.py", line 621, in __init__
self.panel.connect_to_googleplay_api()
File "/usr/lib/python2.7/site-packages/googleplaydownloader/googleplaydownloader.py", line 459, in connect_to_googleplay_api
token = api.login(config["gmail_address"], config["gmail_password"], AUTH_TOKEN)
File "/usr/lib/python2.7/site-packages/googleplaydownloader/ext_libs/googleplayapi/googleplay.py", line 162, in login
k, v = d.split("=")
ValueError: too many values to unpack
When looking at the line 162 of the /usr/lib/python2.7/site-packages/googleplaydownloader/ext_libs/googleplayapi/googleplay.py file, I see the following:
k, v = d.split("=")
The problem is that my current google token is the following:
Token=tototata[…]trololo==
As you can see, it ends with two == signs and thus, the split function return more than two elements.
I monkey patch the googleplay.py file as this:
toto = d.split("=")
if len(toto) > 2:
# The following allow me to determine the cause of the crash
logging.error('Weird error with toto {0}'.format(d))
k = toto[0]
v = toto[1]
Strange enough, that was sufficient to have GPD working as expected, even if my token does not contain the trailing =.
By the way, my monkey patch was ugly and the problem is solved if you replace the line 162 by the following:
k, v = d.split("=", 1)
Edited by Étienne Deparis