Closed YodaEmbedding closed 5 years ago
Ooph, well that's fun. I guess as a hack we can just check for time
assuming the key duration
isn't available, but that could be an issue later. Is it like this with all tracks reported by mopidy?
Edit: Okay, for some odd reason Mopidy is using an older version of the mpd protocol as it's using time
as opposed to duration
, and using time
is deprecated.
I'll add a little hack there (later today) for mopidy so it works, but you should definitely go wag your finger at them :D they should be sending a duration
parameter
Edit 2: Yep, here's where Mopidy's doing the no-bueno
Edit 3: In certain places I'm also using time
as opposed to duration
. Welp, guess I'll change those, too.
Edit 4: time
is the deprecated form of elapsed
in status
/currentsong
calls? But when querying for metadata via lsinfo
, time
is then the deprecated form of duration
?
And for some reason the MPD python client is returning the latter when querying the former? The fun never stops around here, I tell you.
Fixed with https://github.com/Berulacks/yams/commit/65e8ab8b7bf004677cab6f6b40668f6c89347d9f
Could you try running from master
and let me know if it works for you? I'll prepare a release accordingly.
Looks like it works.
Separate issue I encountered while installing via setup.py
, but the latest version of PyYAML is 5.1.1 and requests is 2.21.0.
Any reason to upgrade PyYAML or requests? I tend to keep dependencies' versions stable unless I have a need to update.
Regardless, closing this issue as it seems sorted!
So yams was running fine for a few days until this happened:
$ systemctl --user status --no-pager yams.service
Nov 05 06:14:02 PC-Mordor-Arch yams[2728]: 2019-11-05 06:14:02,785 - yams - INFO - Playing Rubylove, 0/157s (0.0%)
Nov 05 06:14:08 PC-Mordor-Arch yams[2728]: 2019-11-05 06:14:07,927 - yams - ERROR - Something went very wrong!
Nov 05 06:14:08 PC-Mordor-Arch yams[2728]: Traceback (most recent call last):
Nov 05 06:14:08 PC-Mordor-Arch yams[2728]: File "/usr/lib/python3.7/site-packages/yams/scrobble.py", line 841, in cli_run
Nov 05 06:14:08 PC-Mordor-Arch yams[2728]: mpd_watch_track(client,session,config)
Nov 05 06:14:08 PC-Mordor-Arch yams[2728]: File "/usr/lib/python3.7/site-packages/yams/scrobble.py", line 622, in mpd_watch_track
Nov 05 06:14:08 PC-Mordor-Arch yams[2728]: song_duration = float(song["duration"] if "duration" in song else song["time"])
Nov 05 06:14:08 PC-Mordor-Arch yams[2728]: KeyError: 'time'
Nov 05 06:14:08 PC-Mordor-Arch yams[2728]: 2019-11-05 06:14:08,100 - yams - INFO - Shutting down...
Nov 05 06:14:09 PC-Mordor-Arch systemd[679]: yams.service: Succeeded.
Not entirely sure what caused it, since yams started working again after restarting yams.service
.
That's really weird because the line "Playing Rubylove, 0/157s" uses the same float(song["duration"] if "duration" in song else song["time"])
code to grab the song's duration (157 seconds) in mpd_wait_for_play()
. So it seems that something broke between both calls.
I wonder why the song would have been passed without a duration variable? Perhaps an mpd error?
Let me know if it happens again and I'll add some aggressive debug logging to that area, but I think it was most likely a Mopidy/MPD issue.
That's really weird because the line "Playing Rubylove, 0/157s" uses the same
float(song["duration"] if "duration" in song else song["time"])
code to grab the song's duration (157 seconds) inmpd_wait_for_play()
. So it seems that something broke between both calls.I wonder why the song would have been passed without a duration variable? Perhaps an mpd error?
Let me know if it happens again and I'll add some aggressive debug logging to that area, but I think it was most likely a Mopidy/MPD issue.
I repeatedly have issues where a song is passed without "duration" or "time" but have tracked it to occasions where I'm listening to podcasts. I don't know much about the mpd protocol, but it seems like there isn't necessarily a duration associated with a stream.
I'm using mpd v0.22
Yeah, you're right, you can have MPD streams that don't have a duration associated with it (online radio, podcasts). Helpfully, MPD provides a player status
with a time
value that is always present (it holds a value of 0 if there is no duration). Pull requests #6 and #5 use this to calculate progression through a song, so internet streams can be played without crashing yams (but they still can't be scrobbled as we can't see how long it is). There hasn't been a release since they were merged though, so you'd have to install manually from github in order to use the fix.
Yes, that's my bad - I'll make a release!
Okay, the PyPi and AUR packages have been updated to the new release (0.7.3), feel free to update and try again @WurdahMekanik
Seems to work for me!
With Mopidy-Gmusic, I get the following error:
Investigating a bit, I tried the following in my REPL:
Looks like the key
'time'
holds the duration value. Changing'duration'
to'time'
seems to fix things.