Navidrome: Playlist management + import / export

Created on 22 Mar 2020  路  30Comments  路  Source: deluan/navidrome

Hello! First of all, thanks for your work! Looks very promising.

Actually using Airsonic.

I wanted to ask if it will be possible to have a playlist management (i saw smart / dynamic playlists on the road map) but i'd like to be able to manage standarf m3u / m3u8 playlists with the ability to import - export them as mine are very precious to me :-)


Added by @deluan to track progress:

Tasks:

  • [x] Add playlist REST endpoint
  • [x] Create/Delete playlists
  • [x] Browse/Play/Add to Queue playlists
  • [x] Remove tracks
  • [x] Edit playlist details (Name, Comment, Public)
  • [x] Reorder tracks
  • [x] Import M3U/PLS files
  • [x] Export to M3U files
  • [x] One-way sync of imported playlists
  • [x] ~View as albums, artists, songs. Similar to iTunes~ Will be implemented as part of a larger overhaul of the UI
enhancement

Most helpful comment

@andrewzah Done in 28d1428. Just set AutoImportPlaylists=false (default is true)

All 30 comments

Thanks for trying out Navidrome.

Playlist management will definitely comes before smart playlists. Even though I have an issue open (#10) to track all initial work on the WebUI, I'll leave this open for eventual discussions specific about playlists.

Thanks to you!
Lookings forward for the playlists / smart playlists and vignette enhancement.
Will probably switch once this is done.
really appreciate the docker container aswell.

Anyway, many thanks again!

Just found Navidrome and it looks like a great lightweight replacement for Airsonic. Looks like I can create playlists in play:sub, just need the management capabilities in the UI. Keep up the great work!

Owing to the discussion on Discord, I also think that playlists should be kept as-is even if the M3U it was originally imported from is not found in its location. Deletion should only be handled by the user explicitly.

Adding to the idea of @arg274, it would be an easy way to make the playlist feature open to other apps if Navidrome synced the changes made back to the playlist file (M3U or else). That way one could add a track to a playlist in Navidrome and have the changes automatically visible in a standalone software like MusicBee, iTunes or DJ Software.
Since not everyone will want and expect this behaviour, it could be configured via settings.

@git1873 two-way sync is really hard to get right. What to do in case of conflicts (changes on both playlists being synched)?

I think the best approach is one way sync: Navidrome will import m3u/pls files, and will flag it as "synchronized". The imported playlist will be read-only in Navidrome, but if the m3u file it was imported from changes, it will get updated. If you want to disable the sync, you'd disable the playlist's "synchronized" flag (in the UI)

On my side, i would never use the folder to import playlists into Navidrome as it is my main player but will defininitly use it to export the playlists i've made using GUI / Dsub to another players, like Moode-audio.

@deluan You are right, you can't really build a rock-solid 2-way sync solution on a file based system without locking/transactions and conflict management in clients. I am not even sure how many users would use the feature, but i certainly would.
If only one user is accessing the same set of playlist files from different devices, getting it to sync is not really hard. Navidrome could fetch the current state of the playlist file before displaying it to the user (and before adding something to it). This way, no conflicts would occur, unless two clients write at (or depending on the other clients behaviour, load, resuting in later conflicts because client cached an older version of the file) the same time. Not a "set up and forget" solution for every user, it would just make some workflows possible.

Aside from that; the one-way sync option you proposed is still a good idea and a good thing to start with. Playlists could be configured as Navidrome either being Master oder Slave. If Slave, Navidrome can't write to a playlist, only sync its contents from a file. If Master, Navidrome can edit the Playlist and write it to a file (but not read it back).
The Master/Slave concept is not neccesarily the most clear mechanism to the user, so the Slave (Sync from file) could be presented as you laid out, and then for the Master-Mode there could be an Export function, that can be run manually by the user or automatically after every change to the playlist.

Hey @certuna, from the comment you added in the PR https://github.com/deluan/navidrome/pull/265#issuecomment-630172111, the only items not implemented yet are:

  • change the playlist order
  • see other fields than title/artist/time

All other items are already in 0.19.0 and/or in the develop build right now. Let me know if you are having trouble accessing them.

Question: What other fields do you want to see in the playlist tracks grid? Keep in mind that you can expand each row, which gives you more info about each song

Yes this all works well, now testing 0.21, I love how fast all this development is going.

I would imagine you'd want the same columns in Playlists as you have in the rest of the library, ie that you can choose to view a Playlist in Album view, Song view, Artist view. What do you think?

Ah, I got it. Yes I want to have different visualization modes for playlists, but right now there are a lot of other things that would come first, ex: smart playlists. When implementing the artist view, I may refactor all views to allow them to be reused with playlists. I'll add this to the issue's checklist, even though it will probably move to its own issue once the other items in the list are done

Eventually: Share playlist with a user, or allow a user on the server to check other's playlists and "follow" them

@Extarys Playlists can already be set as public, then all users in a server have access to it. Is it enough?

Update: Latest from master implements the playlist import. Just drop your .m3u files in any directory under your music folder, and Navidrome will parse and import it automatically on the next scan. Playlists that were imported this way will be kept in sync: Any changes to the .m3u file will update the Playlist. If you want to disable this sync after the playlist has been imported, you can edit it in the UI and disable it ("Auto-Import" switch).

To be able to use it, you'll need to get the latest develop build, and set the DevNewScanner=true config option.

Hi Deluan!
This looks perfect.

For people who want to try in docker pull navidrome:develop and add ND_DEVNEWSCANNER=true environement variable.

Tried it myself and my playlist are not imported ATM because of an error:
2020/07/18 12:11:42 OK 20200411164603_add_created_and_updated_fields_to_playlists.go 2020/07/18 12:11:42 OK 20200516140647_add_playlist_tracks_table.go 2020/07/18 12:11:42 OK 20200710211442_add_playlist_path.go time="2020-07-18T12:11:44+02:00" level=error msg="Error retrieving playlist owner" error="data not found"
Do i need to edit my playlists in any way?

FYI:
My playist is named:
"instrumental Metal"

and entries looks like:
image

Any hint?

@antipiot Thanks for helping testing this. Your playlist seems fine. The issue is related to your users. You have at least one admin user, right?

Can you change the loglevel to trace and try again?

EDIT2: sorry: this looks to be working perfectly now - do not know what was causing trouble.
Looks perfect!

Any chance to have the changes wrote in the m3u file?

Let me clarify my needs:
I'm using a script to automatically grab my playlists in a folder and "convert" them to fit in my Moode-Audio player.

I would like to generate and edit my playlists in Navidrome and be able to grab them with ease.

Export playlists come next, I've been thinking of implementing something similar to what @git1873 described in his comment:

If Master, Navidrome can edit the Playlist and write it to a file (but not read it back).

You could set a path in the Playlist Edit UI, so everytime it was changed, it auto-exports to that path...

If you don't want to wait, you could use Subsonic API with curl and parse the results with jq to grab the playlists directly from Navidrome.

EDIT: Something like this (ex. to get a list of all playlists):

$ curl -s "http://localhost:4533/rest/getPlaylists?u=<user>&p=<password>&c=curl&v=1.8.0&f=json" | jq
{
  "subsonic-response": {
    "status": "ok",
    "version": "1.10.2",
    "type": "navidrome",
    "serverVersion": "dev",
    "playlists": {
      "playlist": [
        {
          "id": "c1a00e2e-4819-4762-8358-f017a69588ee",
          "name": "Best Of Saara Saara",
          "comment": "Auto-imported from 'Best Of Saara Saara.m3u'",
          "songCount": 7,
          "duration": 1384,
          "public": false,
          "owner": "admin",
          "created": "2020-07-18T00:23:46.569445Z",
          "changed": "2020-07-18T04:16:12Z"
        },
        {
          "id": "ef69f7c0-3a1e-40e2-b2f2-62e0f7f000bc",
          "name": "test",
          "songCount": 8,
          "duration": 1954,
          "public": false,
          "owner": "admin",
          "created": "2020-07-18T04:22:56.677525Z",
          "changed": "2020-07-18T04:22:56Z"
        }
      ]
    }
  }
}

@deluan i did tried something to download playlist with m3u format on my Airsonic but couldn't get it working efficiently due to some mechanisms implied with auth token or something. Read somewhere i wasn't alone trying and facing a wall on the case.

"You could set a path in the Playlist Edit UI, so everytime it was changed, it auto-exports to that path..."
How may i set a custom path?
image

Thanks for you great work on Navidrome!

@deluan i did tried something to download playlist with m3u format on my Airsonic but couldn't get it working efficiently due to some mechanisms implied with auth token or something. Read somewhere i wasn't alone trying and facing a wall on the case.

Yes, that is hard. What I'm proposing is something different: to get the playlist in JSON, using the API and converting it to m3u in your script. If you want to try and need help, join our Discord server and I can help you with that (it is easier to chat than exchange replies here... :) )

Re: Path, in the currently implementation, you can't change the path. It is there just to let you know the origin of the imported playlist. But when implementing auto-export, this path will be configurable.

Got it!
Thanks for the clear explanation - will wait for the implementation patiently.
no need to script further if something covering the need will be available.

@deluan ,sorry to bother you:
If i'm not mistaken your the new scanner has been merged.
This scan - import should appear in logs? asking because my playlists aren't imported.
did i miss something?

Yes, from version 0.26.1, it is the default scanner.

In default info loglevel, it should show a message like this when it finds a new or changed .m3u file:

Adding synced playlist      owner=admin path="/Users/deluan/Music/Music/Media/Music/Best Of Saara Saara.m3u" playlist="Best Of Saara Saara"

You can try making a simple change to the playlist (adding a comment or something like this), and once you save it, it should picked-up in the next scan cycle. If not, repeat the process with loglevel = trace and send me the logs to try to figure out why it is not working.

@deluan , Thanks for your answer:
I do not know why but i had to remove the playlists from media folder, reboot the server, put the playlists back in and they where imported correctly.

Thanks for your great work and help!

@antipiot That's very weird. Just updating the playlists without any reboot should be enough. Well, if you can reproduce this behavior consistently, please open a new GH issue with steps on how to reproduce it, so we can discuss try to figure this out

@deluan can the importing of m3u's be made optional? For cd ripping with EAC, it's standard to include a .m3u of the album.

Hummm.... I'm not actually a fan of (and don't use any) .m3u playlists, but I can see disabling the auto-import being desired. Sure, I'll add an option in the next release

@andrewzah Done in 28d1428. Just set AutoImportPlaylists=false (default is true)

Added support for Export to M3U in https://github.com/deluan/navidrome/commit/9df405a8ce2b17e6e2554296290db23ea1b7dbb7.

Playlists support is now completed. Thanks for all the feedback.

The "View as" functionality proposed by @certuna will be part of a larger overhaul of the UI.

If you require any other functionality regarding playlists, please open a new issue.

Was this page helpful?
0 / 5 - 0 ratings