Skip to content
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

Closed
s-ol opened this issue Feb 28, 2015 · 10 comments
Closed

Allow writeable playlists to be provided #1014

s-ol opened this issue Feb 28, 2015 · 10 comments
Assignees
Labels
C-enhancement Category: A PR with an enhancement or an issue with an enhancement proposal

Comments

@s-ol
Copy link

s-ol commented Feb 28, 2015

I can't imagine this being to hard to do, there would be a minor API change (adding save() to models.Playlist and making tracks RW, or instead adding addTrack())

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

@adamcik adamcik added MPD C-enhancement Category: A PR with an enhancement or an issue with an enhancement proposal labels Mar 10, 2015
@adamcik
Copy link
Member

adamcik commented Mar 10, 2015

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).

@s-ol
Copy link
Author

s-ol commented Mar 10, 2015

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?).

@kozec
Copy link
Contributor

kozec commented May 20, 2015

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.

That being said we already have core methods for handling playlist creation, updates and deletes

@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
Copy link
Member

@kozec
Copy link
Contributor

kozec commented May 20, 2015

@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

@tkem
Copy link
Member

tkem commented May 21, 2015

@kozec in Python, you'd use something like playlist.copy(tracks=new_tracks), instead of setting .tracks directly as in JS.

@kingosticks
Copy link
Member

Sorry for that irrelevant link, didn't read this properly.

Copy is deprecated. replace is the correct API.
On 21 May 2015 06:52, "Thomas Kemmer" notifications@github.com wrote:

@kozec https://github.com/kozec in Python, you'd use something like
playlist.copy(tracks=new_tracks), instead of setting .tracks directly as
in JS.


Reply to this email directly or view it on GitHub
#1014 (comment).

@tkem
Copy link
Member

tkem commented May 21, 2015

Sorry, my bad; of course, replace should be used for Mopidy v1.1. Old habits ;-)

@kozec
Copy link
Contributor

kozec commented May 21, 2015

@kingosticks No proble, it helped me to move in right direction.
It should be done in #1187.

@jodal jodal added this to the v1.2 - Gapless milestone Oct 29, 2015
@jodal jodal self-assigned this Oct 29, 2015
@jodal jodal closed this as completed in 8aeb984 Oct 29, 2015
@jodal
Copy link
Member

jodal commented Oct 29, 2015

Fixed with the merge of #1322.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-enhancement Category: A PR with an enhancement or an issue with an enhancement proposal
Projects
None yet
Development

No branches or pull requests

6 participants