cfangmeier / tuijam

A fancy TUI client for Google Play Music
MIT License
129 stars 9 forks source link

Crash on rapid adding tracks in queue #18

Closed t1meshift closed 5 years ago

t1meshift commented 5 years ago

Because Ctrl+q key combination doesn't work, I started pressing 'q' and then 'arrow down' repeatedly. And I got a crash.

Traceback (most recent call last):
  File "/usr/lib/python3.7/site-packages/googleapiclient/discovery_cache/__init__.py", line 36, in autodetect
    from google.appengine.api import memcache
ModuleNotFoundError: No module named 'google.appengine'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/lib/python3.7/site-packages/googleapiclient/discovery_cache/file_cache.py", line 33, in <module>
    from oauth2client.contrib.locked_file import LockedFile
ModuleNotFoundError: No module named 'oauth2client.contrib.locked_file'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/lib/python3.7/site-packages/googleapiclient/discovery_cache/file_cache.py", line 37, in <module>
    from oauth2client.locked_file import LockedFile
ModuleNotFoundError: No module named 'oauth2client.locked_file'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/lib/python3.7/site-packages/googleapiclient/discovery_cache/__init__.py", line 41, in autodetect
    from . import file_cache
  File "/usr/lib/python3.7/site-packages/googleapiclient/discovery_cache/file_cache.py", line 41, in <module>
    'file_cache is unavailable when using oauth2client >= 4.0.0 or google-auth')
ImportError: file_cache is unavailable when using oauth2client >= 4.0.0 or google-auth
ERROR:root:Missing Key 'artistId' in dict 
{'kind': 'sj#track', 'title': 'Placebo Effect', 'artist': 'Various Artists', 'composer': '', 'album': 'Resting Spaces – Best Relaxation Music: Spa Ambient, Freetime, Reflexology, Feel Pleasure, Journey for Senses', 'albumArtist': 'Various Artists', 'trackNumber': 21, 'genre': 'New Age', 'durationMillis': '216000', 'albumArtRef': [{'kind': 'sj#imageRef', 'url': 'http://lh3.googleusercontent.com/QQtjCmq5w9XcuznQq8AZLCVZEdzLXn-v85W3Ssj4gtnfEr3U-OFIFODR7mHkIXiLldWpDwwBIqk', 'aspectRatio': '1', 'autogen': False}], 'discNumber': 1, 'estimatedSize': '8661196', 'trackType': '7', 'storeId': 'Tkax5nojml3puez4f4z6svmujcq', 'albumId': 'nc7cl6n46uqdwgwk4j27tqrnve', 'nid': 'kax5nojml3puez4f4z6svmujcq', 'trackAvailableForSubscription': True, 'trackAvailableForPurchase': True, 'albumAvailableForPurchase': True, 'explicitType': '2'}
Traceback (most recent call last):
  File "/usr/bin/tuijam", line 107, in from_dict
    artistId = d['artistId'][0]
KeyError: 'artistId'
WARNING:googleapiclient.discovery_cache:file_cache is unavailable when using oauth2client >= 4.0.0 or google-auth
Traceback (most recent call last):
  File "/usr/lib/python3.7/site-packages/googleapiclient/discovery_cache/__init__.py", line 36, in autodetect
    from google.appengine.api import memcache
ModuleNotFoundError: No module named 'google.appengine'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/lib/python3.7/site-packages/googleapiclient/discovery_cache/file_cache.py", line 33, in <module>
    from oauth2client.contrib.locked_file import LockedFile
ModuleNotFoundError: No module named 'oauth2client.contrib.locked_file'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/lib/python3.7/site-packages/googleapiclient/discovery_cache/file_cache.py", line 37, in <module>
    from oauth2client.locked_file import LockedFile
ModuleNotFoundError: No module named 'oauth2client.locked_file'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/lib/python3.7/site-packages/googleapiclient/discovery_cache/__init__.py", line 41, in autodetect
    from . import file_cache
  File "/usr/lib/python3.7/site-packages/googleapiclient/discovery_cache/file_cache.py", line 41, in <module>
    'file_cache is unavailable when using oauth2client >= 4.0.0 or google-auth')
ImportError: file_cache is unavailable when using oauth2client >= 4.0.0 or google-auth
ERROR:root:4
Traceback (most recent call last):
  File "/usr/bin/tuijam", line 1329, in main
    loop.run()
  File "/usr/lib/python3.7/site-packages/urwid/main_loop.py", line 286, in run
    self._run()
  File "/usr/lib/python3.7/site-packages/urwid/main_loop.py", line 384, in _run
    self.event_loop.run()
  File "/usr/lib/python3.7/site-packages/urwid/main_loop.py", line 1005, in run
    reraise(*exc_info)
  File "/usr/lib/python3.7/site-packages/urwid/compat.py", line 58, in reraise
    raise value
  File "/usr/lib/python3.7/site-packages/urwid/main_loop.py", line 1018, in wrapper
    return f(*args,**kargs)
  File "/usr/lib/python3.7/site-packages/urwid/main_loop.py", line 938, in io_callback
    callback()
  File "/usr/lib/python3.7/site-packages/urwid/raw_display.py", line 404, in <lambda>
    event_loop, callback, self.get_available_raw_input())
  File "/usr/lib/python3.7/site-packages/urwid/raw_display.py", line 502, in parse_input
    callback(processed, processed_codes)
  File "/usr/lib/python3.7/site-packages/urwid/main_loop.py", line 411, in _update
    self.process_input(keys)
  File "/usr/lib/python3.7/site-packages/urwid/main_loop.py", line 511, in process_input
    k = self._topmost_widget.keypress(self.screen_size, k)
  File "/usr/bin/tuijam", line 900, in keypress
    return self.focus.keypress(size, key)
  File "/usr/lib/python3.7/site-packages/urwid/container.py", line 1590, in keypress
    key = self.focus.keypress(tsize, key)
  File "/usr/lib/python3.7/site-packages/urwid/container.py", line 2271, in keypress
    key = w.keypress((mc,) + size[1:], key)
  File "/usr/bin/tuijam", line 392, in keypress
    self.app.queue_panel.add_songs_to_queue(selected.songs)
  File "/usr/bin/tuijam", line 528, in add_songs_to_queue
    self.add_song_to_queue(song)
  File "/usr/bin/tuijam", line 524, in add_song_to_queue
    self.walker.append(song.ui())
  File "/usr/bin/tuijam", line 92, in ui
    '{:d}:{:02d}'.format(*self.length), RATE_UI[self.rating],
KeyError: 4
cfangmeier commented 5 years ago

Thanks for reporting this! I think there are two separate issues here:

  1. ctrl q not working. I'm guessing that this key combination is being caught by your terminal emulator. If you tell me what OS/terminal you are using, I can try to find a workaround. Alternatively, you can go in and edit this line to an alternative key combination that works for you. At some point, I'd like to make the key bindings user configurable...

  2. The actual exception is being caused by an invalid rating number being used to lookup the symbol that indicates whether a song has been thumbed up/down. According to the docs the only valid values are 0, 1, and 5. But for some reason, this particular song has a value of 4. If I remember correctly there was once a numeric rating system in the web app so maybe non-standard values are leftover from those days? In any case, I made a quick fix in ad46e87 to handle this. Let me know if that fixes the problem. As far as I can tell, this has nothing to do with adding songs to the queue too fast.

t1meshift commented 5 years ago

Well, I haven't seen any track rating system but like/dislike since my day one on Google Play Music, but OK. What about my terminal, I use gnome-terminal. Ctrl+q key combination just does nothing. I'll try other combinations described in readme.

t1meshift commented 5 years ago

I've tried to install tuijam from git and it failed:

running bdist_egg
running egg_info
creating tuijam.egg-info
writing tuijam.egg-info/PKG-INFO
writing dependency_links to tuijam.egg-info/dependency_links.txt
writing requirements to tuijam.egg-info/requires.txt
writing top-level names to tuijam.egg-info/top_level.txt
writing manifest file 'tuijam.egg-info/SOURCES.txt'
reading manifest file 'tuijam.egg-info/SOURCES.txt'
reading manifest template 'MANIFEST.in'
writing manifest file 'tuijam.egg-info/SOURCES.txt'
installing library code to build/bdist.linux-x86_64/egg
running install_lib
warning: install_lib: 'build/lib' does not exist -- no Python modules to install
[...]
Searching for PyGObject==3.28.3
Reading https://pypi.org/simple/PyGObject/
Downloading https://files.pythonhosted.org/packages/e0/e8/1e4f21800015a9ca153969e85fc29f7962f8f82fc5dbc1ecbdeb9dc54c75/PyGObject-3.28.3.tar.gz#sha256=250fb669b6ac64eba034cc4404fcbcc993717b1f77c29dff29f8c9202da20d55
Best match: PyGObject 3.28.3
Processing PyGObject-3.28.3.tar.gz
Writing /tmp/easy_install-1wlu__71/PyGObject-3.28.3/setup.cfg
Running PyGObject-3.28.3/setup.py -q bdist_egg --dist-dir /tmp/easy_install-1wlu__71/PyGObject-3.28.3/egg-dist-tmp-3qzbaur1
Package gobject-introspection-1.0 was not found in the pkg-config search path.
Perhaps you should add the directory containing `gobject-introspection-1.0.pc'
to the PKG_CONFIG_PATH environment variable
Package 'gobject-introspection-1.0', required by 'virtual:world', not found
error: Setup script exited with Command '('pkg-config', '--print-errors', '--exists', 'gobject-introspection-1.0 >= 1.46.0')' returned non-zero exit status 1.

However, I've managed to launch git version by just running ./tuijam as I didn't delete the dependencies installed by AUR package. If installer would be fixed, I'd make a package for git installation.

UPD: The queue since last crash is restored. Ctrl-p combination works. I thought Ctrl-q was system-wide combination but I don't see it in keyboard shortcut settings in GNOME.

t1meshift commented 5 years ago

Also, it would be great if previous tracks from queue were saved somewhere because there is no way to go to them right now.

cfangmeier commented 5 years ago

What about my terminal, I use gnome-terminal. Ctrl+q key combination just does nothing. I'll try other combinations described in readme.

I just tried running TUIJam in Gnome terminal and the ctrl-q combination works fine for me. Maybe your shell(bash/zsh/etc) is actually trapping it somehow?

I've tried to install tuijam from git and it failed

It looks like PyGObject is failing to be installed. I think that what is happening is that GObject's packages need to be installed already by the package manager. Looking at the AUR package, The gobject-introspection package (which seems to be what is specifically missing here) will get included via tuijam->pygobject-devel->gobject-introspection. I think that the takeaway is that the list of dependencies in the README is incomplete.

Also, it would be great if previous tracks from queue were saved somewhere because there is no way to go to them right now.

Previous tracks in fact are saved. They can be viewed via the ctrl r key combination. Maybe I'm misunderstanding what you are asking for though...

t1meshift commented 5 years ago

I use zsh with oh-my-zsh extension but should the shell override current app's key shortcuts?

They can be viewed via the ctrl r key combination

I mean that I can't go to previous tracks with key combinations. I can view previously played tracks with ctrl r but I need to add them to my queue manually. I think that's not so convenient. Maybe I should open a new issue with this feature request.

UPD: I think I know why PyGObject dependency is never satisfied. I use GNOME 3.30.2 while dependencies file contains PyGObject==3.28.3. Also, I have pygobject-devel installed from Manjaro's repo with version 3.30.4. PyGObject>=3.28.3 should fix it.

cfangmeier commented 5 years ago

Thanks for handling the PyGObject issue. I'll have a look at the PR. Also, if you would like to implement the previous track feature, please feel free to submit a PR. I didn't implement it originally just because it's not a feature I feel I would personally use very often.

In any case, I think this issue is resolved.