beets icon indicating copy to clipboard operation
beets copied to clipboard

smartplaylist: Change base directory for exported paths

Open duckpuppy opened this issue 8 years ago • 6 comments

Problem

I run a Subsonic server on a different machine than the one I use for managing my music library. Both access the same music library, but they differ between machines (in fact, one is a Windows machine sharing a local path and one is Linux mounting that share). Subsonic requires playlists to have absolute paths as well, so I can't just use relative paths. I would like to be able to supply a playlist with a "from" and "to" mapping such that the written path has the "from" string replaced with the "to" string.

ex:

map_from: /mnt/music/
map_to: G:/Music/

would write G:/Music/Artist/Album/01 - track.mp3 into the m3u for a file located at /mnt/music/Artist/Album/01 - track.mp3.

duckpuppy avatar May 03 '17 19:05 duckpuppy

Huh, that is an interesting setup. One other solution you could consider would be to do a little bit of post-processing on the generated m3u files—a quick pipe through sed s/\/mnt\/music\//G:\/Music\// would do the trick.

sampsyo avatar May 04 '17 03:05 sampsyo

It's not that strange a setup - except maybe the Windows server part for beets users - and a common support request for users of both Subsonic and Logitech Media Server is how to make whatever library manager they're using export proper absolute paths in their playlist. Using sed is certainly possible (and what I do now), but not so automated unless I wrap beets in a shell script. And I'm using beets because it already automates most of what I need for library management.

It's not so out of the ordinary for people using a NAS that's also running Subsonic or Logitech Media Server (which also wants absolute paths in playlists - relative paths are seen as a security concern for both since they could point to files outside the configured music folders) to have the same issue - the path to the files on the NAS where the music server is running will be different from the path they mount the library to for managing with beets.

I've seen this feature in a couple of other library managers that allow exporting a playlist to a file with path replacement, but they're all GUI managers and I live mostly on the command line.

All-in-all, I think this is a low risk feature that also shouldn't be difficult to implement looking at the existing code for the plugin, though python is not one of my go-to languages.

duckpuppy avatar May 04 '17 11:05 duckpuppy

@sampsyo would it be possible for the plugin to emit a (new) smartplaylist_written event so the sed command can be plugged to it using the hook mechanism ?

Kraymer avatar May 04 '17 12:05 Kraymer

OK; thanks for clarifying. I'll mark this as a feature request. What would you think of a slightly simpler version that just replaces the directory from your library configuration value, instead of requiring an explicit map_from?

sampsyo avatar May 04 '17 13:05 sampsyo

That would be OK in my case, and I can't think of a use case right now that wouldn't be covered by that. The library path as an implicit "from" sounds great.

duckpuppy avatar May 04 '17 15:05 duckpuppy

That would be great because now I have to sed my playlists from time to time to be usable with airsonic

Savanta avatar Aug 08 '24 10:08 Savanta