lotan / rhythmbox-ampache

Rhythmbox plugin to stream music from Ampache
GNU General Public License v2.0
21 stars 7 forks source link

crash while parsing #25

Open trent30 opened 4 years ago

trent30 commented 4 years ago

(23:56:33) [0x5610a2c1aa70] [AmpacheBrowser.handshake_cb] /usr/lib/rhythmbox/plugins/ampache/AmpacheBrowser.py:1094: downloading playlists: https://myserver.tld/ampache/server/xml.server.php?action=playlists&auth=c5760ccc5b248c0665b46799cbc28640 Traceback (most recent call last): File "/usr/lib/rhythmbox/plugins/ampache/AmpacheBrowser.py", line 404, in playlists_cb parser.feed(contents) File "/usr/lib/python3.6/xml/sax/expatreader.py", line 217, in feed self._parser.Parse(data, isFinal) File "../Modules/pyexpat.c", line 419, in StartElement File "/usr/lib/python3.6/xml/sax/expatreader.py", line 333, in start_element self._cont_handler.startElement(name, AttributesImpl(attrs)) File "/usr/lib/rhythmbox/plugins/ampache/AmpacheBrowser.py", line 41, in startElement self.__id = int(attrs['id']) ValueError: invalid literal for int() with base 10: 'smart_14'

lotan commented 4 years ago

Are you running the current head of the repository? 26c6e0278fdd7d789696060ac94418097ef9267c should have fixed your issue.

trent30 commented 4 years ago

I'm running on Xubuntu 18.04 :

$ apt-cache policy rhythmbox-ampache rhythmbox-ampache: Installed: 0.11.1+svn43-1 Candidate: 0.11.1+svn43-1

So I git clone the repo ( commit ed4b0826a7ebd ), now I have :

(16:20:42) [0x5623a8561920] [AmpacheBrowser.download_songs_chunk] /usr/lib/rhythmbox/plugins/ampache/AmpacheBrowser.py:687: download _songs[0]: https://mydomain.tld/ampache/server/xml.server.php?action=songs&auth=secret&offset=0&limit=5000
TypeError: do_get_status() takes 3 positional arguments but 4 were given
lotan commented 4 years ago

Your log shows the auth argument of the URL not set. Did you get errors earlier in the log? Did you fill in user/password in the configuration settings of the plugin?

trent30 commented 4 years ago

My bad, the auth argument of the URL is set but I replace it by "secret" between "<" and ">" symbols before copy/paste (like "mydomain.tld" to prevent leak information), so the github form sanitizer remove it. In reality, auth is set : auth=3f854....

lotan commented 4 years ago

Does Rhythmbox download the library eventually? Or does the plugin crash? The do_get_status() function is responsible for showing status/progress, not for the actual functionality.

The error indicates that Xubuntu 18.04 has not updated Rhythmbox and thus runs the old library from a plugin point of view. You could try leaving the HEAD commit - adaptation to the RB-3.0 library - and checking out the version prior to that: 26c6e0278fdd7d789696060ac94418097ef9267c.

I'll have to do some homework and find out how to test for the RB library version... maybe I'll be able handle both cases then.

trent30 commented 4 years ago

There no error in console with commit 26c6e02, but after a while I have a GtkDialog : « Songs response: g-io-error-quark: HTTP error:Gateway Time-out (0) » and nothing is loaded (0 artist, 0 album). Server side, I see the request : « GET /ampache/server/xml.server.php?action=playlists&auth=3625... »

lotan commented 4 years ago

Can you try opening the URLs (especially the song chunk download) from your rhythmbox logs in a browser and confirm that they get the information without timing out?

trent30 commented 4 years ago

There is no URLs after « handshake ».

lotan commented 4 years ago

Maybe not directly. But you pasted a URL in the op:

(23:56:33) [0x5610a2c1aa70] [AmpacheBrowser.handshake_cb] /usr/lib/rhythmbox/plugins/ampache/AmpacheBrowser.py:1094: downloading playlists: https://myserver.tld/ampache/server/xml.server.php?action=playlists&auth=c5760ccc5b248c0665b46799cbc28640

That is the API call to download playlist data. The one that downloads song data contains ?action=songs. If you find them in the log, copy and paste them into a browser address bar to see if they return data.

trent30 commented 4 years ago

The response is :

<?xml version="1.0"?>
<root>
  <error code="401">Invalid Login - cannot parse time</error>
</root>

But I suppose some parameters are send with POST method... ? I see only a crypted TLS with tcpdump

lotan commented 4 years ago

Can you please add the URL that caused this response? Was that the action=handshake?

POST is right.

Refer here for the XML API if you want to try things out for yourself: https://github.com/ampache/ampache/wiki/XML-methods

trent30 commented 4 years ago

Yes it is the action=handshake :

https://mydomain.tld/nextcloud/apps/music/ampache/server/xml.server.php?action=handshake&auth=f166...blablabla...c6657d6a&timestamp=1593009242&user=toto&version=350001
lotan commented 4 years ago

Hmmm, I'd think that the error might refer to the timestamp argument. But according to the XML API that's supposed to be a Unix timestamp which it definitely is.

I searched github repository for ampache in order to see why an error like this would be returned but couldn't find anything.

But before that error has been resolved for your ampache installation, we don't have to go any further.

One thing I'd noticed on the API page was that they now have a minimum version of 380001. You could try that in the URL and see whether it works.

trent30 commented 4 years ago

with version=380001 :

<?xml version="1.0"?>
<root>
  <error code="401">Invalid Login - passphrase does not match</error>
</root>
lotan commented 4 years ago

What is the version of the ampache server?

Can you access the server? Enable debugging https://github.com/ampache/ampache/wiki/Troubleshooting?

If I look at the current API implementation, there are similar errors but not the same: https://github.com/ampache/ampache/blob/46a53a3a2e95910a7dc2eebe1cf21f177466a424/lib/class/api.class.php

trent30 commented 4 years ago

What is the version of the ampache server?

It's a fresh install on yunohost, the version is 4.1.1.1~ynh1

Can you access the server?

Yes

Enable debugging https://github.com/ampache/ampache/wiki/Troubleshooting?

I try this on /etc/yunohost/apps/ampache/conf/ampache.cfg.php but it don't work (yes I make the directory and chmod 777 on it).

lotan commented 4 years ago

I've managed to recreate your problem in my installation. It turned out that I had the same problem all along. Because I had reused the auth from a long ago handshake, I hadn't discovered it yet. As soon as I've found out, how to solve the issue, I'll get back to you.

lotan commented 4 years ago

I take my last comment back.

But I had trapped myself in a feature that the original developers of this plugin have foreseen: Either using username/password or an authentication string to login.

In the Preferences dialog of the plugin: By omitting 'Username (opt)', you trigger the latter feature: authentication with an authentication string. When I entered my username along with my password, the handshake worked and songs and playlists were downloaded.

Seeing as my error message was the same as your first one, I could imagine you did the same thing: Omitting your username - which is not optional but manatory if you enter your password rather than the 'Key'/authentication string.

I admit, this dialog could be solved better. I'll think about it.

trent30 commented 4 years ago

When I entered my username along with my password, the handshake worked and songs and playlists were downloaded.

I always entered a username but I have this : [0x55ffa6aa7920] [rb_audioscrobbler_should_handshake] rb-audioscrobbler.c:839: No username set

I disable plugin, quit rhythmbox, re-enable plugin, the values (url/username/password) still here. I use strace rhythmbox 2>&1 | grep open | grep user and see the values was store in /home/user/.config/dconf/user, I remove the values with dconf-editor, I restart rhythmbox -d, re-enter username and password and I still have the same issue :

(23:38:53) [0x557cec9a0b20] [AmpacheBrowser.update] /usr/lib/rhythmbox/plugins/ampache/AmpacheBrowser.py:944: downloading handshake: https://mydomain.tld/nextcloud/apps/music/ampache/
server/xml.server.php?action=handshake&auth=secret&timestamp=1593466733&user=trent&version=350001
(23:38:53) [0x557cec9a0b20] [rb_shell_clipboard_set_source_internal] rb-shell-clipboard.c:349: selected source 0x557ceccd4e00
(23:38:53) [0x557cec9a0b20] [rb_shell_clipboard_sync] rb-shell-clipboard.c:504: syncing clipboard
(23:38:53) [0x557cec9a0b20] [rb_shell_player_set_source_internal] rb-shell-player.c:3053: selected source 0x557ceccd4e00
(23:38:53) [0x557cec9a0b20] [rb_shell_player_sync_with_selected_source] rb-shell-player.c:2347: syncing with selected source: 0x557ceccd4e00
(23:38:53) [0x557cec9a0b20] [rb_shell_player_sync_with_selected_source] rb-shell-player.c:2350: no playing source, new source is 0x557ceccd4e00
(23:38:53) [0x557cec9a0b20] [rb_shell_player_sync_with_source] rb-shell-player.c:1879: playing source: (nil), active entry: (nil)
(23:38:53) [0x557cec9a0b20] [rb_shell_set_window_title] rb-shell.c:2426: clearing title
(23:38:53) [0x557cec9a0b20] [rb_shell_player_sync_buttons] rb-shell-player.c:1971: syncing with source 0x557ceccd4e00
(23:38:53) [0x557cec9a0b20] [rb_statusbar_set_property] rb-statusbar.c:223: selected page 0x557ceccd4e00
(23:38:53) [0x557cec9a0b20] [rb_statusbar_sync_status] rb-statusbar.c:297: updating status with: 'Update songs...', '', 1,000000
(23:38:53) [0x557cec9a0b20] [rb_audioscrobbler_should_handshake] rb-audioscrobbler.c:839: No username set
(23:38:53) [0x557cec9a0b20] [rb_audioscrobbler_should_handshake] rb-audioscrobbler.c:839: No username set
Traceback (most recent call last):
  File "/usr/lib/rhythmbox/plugins/ampache/AmpacheBrowser.py", line 594, in handshake_cb
    handshake['update'][0:18],
KeyError: 'update'
lotan commented 4 years ago

We have to look no further than the handshake. If the handshake URL doesn't return any sensible data, the plugin won't work at all. So why does the handshake URL return with an error? My server is also version 4.1.1. Have you added an ACL allowing the API? rpc

trent30 commented 4 years ago

Yes I have the ACL allowing the API.