New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow writeable playlists to be provided #1014
Comments
I was fairly sure we already had at least one issue for this, so this might be a dupe, just can't seem to find the other ones. That being said we already have core methods for handling playlist creation, updates and deletes (and have rejected a previous attempt to add playlist support because it was adding more APIs instead of using the ones we had). Other than that the main issue is if we should support multibackend playlists or not. If we go for multibackend in creates quite a bit of headaches in how to expose it cleanly in the APIs, in the UIs and how to handle that some backends can only handle certain track types. The simpler, but much more limited variant is to just say you can have a single playlist provider. But then you would have to choose between using local which could handle all URI types, or spotify which could only handle itself (and technically local, but not in mopidy). |
I would think the simpler option is good enough to go with here. Synchronizing local music with spotify across devices outside of the spotify client is going to be a very weird thing anyway, and in the main playlist you could still have music from different backends (right?). |
Hi. I'm just looking over mopidy source & docs, but can't find any API related to writing tracks to playlist. It looks like M3U playlist can be saved, but there is no way how to modify list of tracks inside of it.
@adamcik Could you, please, direct me to those methods? I'd like to have this functionality, so I'm thinking of implementing it myself, but, of course, I don't want to add stuff that's already there... |
@kingosticks Thanks, but that seems to be using javascript to modify playlist.tracks directly, what is not possible in python. After some digging trough code, I managed to implement playlistmove commmand and test it with GMPC. Please, stop me if I'm abusing non-documented stuff or doing something wrong. def playlistmove(context, name, from_pos, to_pos):
# (comment stripped)
uri = context.lookup_playlist_uri_from_name(name)
playlist = uri is not None and context.core.playlists.lookup(uri).get()
if not playlist:
raise exceptions.MpdNoExistError('No such playlist')
if from_pos == to_pos:
return # Nothing to do
# Convert tracks to list and perform move
tracks = list(playlist.tracks)
track = tracks.pop(from_pos)
tracks.insert(to_pos, track)
# Replace tracks and save playlist
playlist = playlist.replace(tracks=tracks)
context.core.playlists.save(playlist)
return |
@kozec in Python, you'd use something like |
Sorry for that irrelevant link, didn't read this properly. Copy is deprecated. replace is the correct API.
|
Sorry, my bad; of course, |
@kingosticks No proble, it helped me to move in right direction. |
Fixed with the merge of #1322. |
I can't imagine this being to hard to do, there would be a minor API change (adding
save()
tomodels.Playlist
and makingtracks
RW, or instead addingaddTrack()
)Of course (mostly) only tracks from the same backend could/should be added.
This would be a very useful feature for spotify, at least IMO
The text was updated successfully, but these errors were encountered: