Use network drive for Jukebox Music

That’s Dinkum, right?

Is the Jukebox skill documented, and is it open source? I can’t seem to find it on the Internet.

Thanks.

-Mike Mac

hey Brian.
Got the nfs mount to work. After installing nfs-common it wouldn’t do the mount, however (on other pi’s) had to install nfs-kernel-server package. After I did that the mount worked fine.
Mounted it at /media/lms then restarted mpd. The logs showed all the tag info being loaded, all looked good. Also checked the
/var/lib/mpd/tag_cache file and again it had all the entries in.
tried a play “brown sugar” but got the sorry I can’t find that message.
Gonna try with a regular usb to see what journalctl messages are different. Also may try mounting it somewhere else and changing the default mpd conf file to another area. But now world cup again …

2 Likes
2 Likes

@goldyfruit Thank you!

-Mike Mac
1 Like

I’ve been playing with the “play jukebox” command, and its been falling over on some .mid files that I have with this:

Nov 26 08:41:06 localhost.localdomain python[625]: ERROR:play-music.mark2:Can't find local music with MPD
Nov 26 08:41:06 localhost.localdomain python[625]: Traceback (most recent call last):
Nov 26 08:41:06 localhost.localdomain python[625]:   File "/opt/mycroft-dinkum/skills/play-music.mark2/__init__.py", line 87, in handle_play_jukebox
Nov 26 08:41:06 localhost.localdomain python[625]:     self._mpd_playlist = list(self.mpd_client.random_play())
Nov 26 08:41:06 localhost.localdomain python[625]:   File "/opt/mycroft-dinkum/skills/play-music.mark2/skill/__init__.py", line 77, in random_play
Nov 26 08:41:06 localhost.localdomain python[625]:     duration_sec=self._time_to_seconds(time_str),
Nov 26 08:41:06 localhost.localdomain python[625]:   File "/opt/mycroft-dinkum/skills/play-music.mark2/skill/__init__.py", line 139, in _time_to_seconds
Nov 26 08:41:06 localhost.localdomain python[625]:     seconds = int(parts[0])
Nov 26 08:41:06 localhost.localdomain python[625]: ValueError: invalid literal for int() with base 10: ''

The problem is that mpd has not analysed those files and posted a time for them. And for some reason it always chose one of those!

I’ve removed those files from my library now and the random play “play jukebox” now seems to work.

Suggest the code checks for a null time_str and sets a default either in the procedure or before. Not sure that mpd can play mid files, so perhaps there ought to be some sort of check for valid file types?

I’m still unable to request a specific track though I’ll try that next.

1 Like

Still not able to get it to play a single track, only the “play jukebox” seems to work.

I can see from the DEBUG messages in the journal that mpc return the correct track.

Only (multiple) Error message is this:

Nov 27 12:46:28 localhost.localdomain startx[690]: Invalid skill_id in mycroft.session.set: "play-music.mark2.audio_player_mark_ii.qml"

It looks the major moving part is found here on: mycroft-dinkum/skills/play-music.mark2/skill/__init__.py at master · MycroftAI/mycroft-dinkum · GitHub

 def search(self, query: str):
        """Searches by artist, album, then song title.
        """
        command_type = "search"
        for query_type in ["artist", "album", "title"]:
            results = self._search(command_type, query_type, query)
            for artist, album, title, time_str, relative_path in results:
                song_path = self.music_dir / relative_path
                if song_path.is_file():
                    yield Song(
                        artist=artist,
                        album=album,
                        title=title,
                        duration_sec=self._time_to_seconds(time_str),
                        file_path=song_path,
                    )
                else:
                    LOG.warning("Missing file: %s", song_path)

So the code checks if the ${music_name} passed in is the name of an artist, album or track.
But those keywords aren’t parsed out. So if you say “Play album Abbey Road”, I believe the word “album” will also be searched for - if so, not good.

The Emby skill did parse some of those keywords, but not quite so many. I forked it, added more extensive parsing, and wrote much more code for playlists, here: https://github.com/mike99mac/emby-skill-mike99mac

I did a couple of videos too: https://www.youtube.com/watch?v=Crre3LWnQ0Q and https://www.youtube.com/watch?v=udE66fLkNxY

I’m wondering if that skill can be modified to use mpc/mpd rather than Emby (mpc may be easier, and also, Emby is no longer FOSS :frowning_face:).

Thoughts?

-Mike Mac

The code offers the last part of the query string (it strips of the "play or “listen”) to the mpc search routine up to 3 times, once as an artist, once as an album and once as a title. It returns (yields) the result(s) which are valid files. This means that “play the beatles” should return a list of beatles tracks across multiple albums . “Play Abbey Road” should return a set of tracks from that album and “play Silver” should just return one track. You can run mpc from the command line to see that. Also the code higher up logs the Result of the call and shows that it is working thus far. However after that it fails silently and mysteriously to play anything. “play jukebox” on the other hand plays a stream of random selections successfully.

My very first try used a USB key onto which I loaded just a couple of albums. This seemed to work fine, playing individual tracks and also selections from a specific Artist and specific Album. After I loaded all my music onto the USB drive it failed to work. Since then I’ve found that it fails on .mid files (see above) and also zip files containing music files, which probably accounts for why the full USB drive failed to work. I guess I should return to a full USB Drive and see if that works now, which would indicate that the problem is with the NFS drive characteristics and not the skill itself. I’ve done my best to compare the code used to play the “play jukebox” versus “play the beatles” and though I can see that the correct tracks are returned from mpc/mpd in both cases I cannot determine why the not jukebox command does not work!!

Your comments about the emby skill are very relevant and I certainly would like to see those enhancements in this skill. However until I can get it to play in the current mode I think we would be wasting our time enhancing it.

My main reason for paying silly money (inc the extra UK VAT!) for this device was exactly to be able to pull up music tracks to play!

PS - the version of mpd in use is 0.21, a version which is no longer supported by the developers. Another of my plans is to update to 0.23 (available from the debian unstable repo).

I’ve gone back to a USB loaded set of music, and the skill works fine, loading up individual tracks or complete Albums as expected.

When I do the same on the NFS share, the logs show mpc/mpd working as expected, but the resultant music files are silently ignored.

Just to remind readers - the “Play jukebox” command works fine on the NFS share, so the issue is not just with the NFS share, but a combination of the share plus the logic in the play-music.mark2 skill or what it calls.

I can provide logs if there is someone who would be interested?

This is great, I will set up my network share as you describe above. “play Jukebox” will be better than I have now, and I have no .mid files to mess things up. Thanks for the attention to this, I agree that this ability is the most commonly used function on a smart speaker so it’s getting closer! I’d help with the log files but I’m not capable of fixing it myself…

Great!. just having someone else to try things out might help to identify the problem (and solution).

I think the problem with the mid files was the lack of any tags (they came direct from the player).