jaseg / python-mpv

Python interface to the awesome mpv media player
https://git.jaseg.de/python-mpv.git
Other
554 stars 69 forks source link

Playlist Information #21

Closed hatzel closed 7 years ago

hatzel commented 7 years ago

This pull request adds some methods for retrieving information on the playlist in mpv. I needed this for a project I am using this in a project and it works very well (for me :smiley: ).

Let me know if there are any changes you would like me to make.

jaseg commented 7 years ago

Still thanks for the PR :)

hatzel commented 7 years ago

Okay, these all make sense and I made changes as you suggested (unless I missed something). Thanks for pointing out the problems and feel free to request any other changes.

jaseg commented 7 years ago

Looks good to me. Thank you very much!

I have squashed the four commits into one.

McSinyx commented 7 years ago

Hi, not related to the code changes but how to use the playlists? The docstrings aren't quite clear, should that be a dict or list or str, and what is the data format?

Also could you add the copyright header to mpv.py @jaseg? As you suggest just to download and use the module, it'd be a lot easier to credit you and clarify licensing information, although AGPLv3 doesn't require header in sources (?). And please update the license in your setup.py, it is still AGLv2 (and maybe move to use distutils and add classifiers, please?).

jaseg commented 7 years ago

I pushed a commit adding a license header to mpv.py and fixed setup.py. Thank you, this is probably a good idea.

About python packaging in general and distutils in particular I don't understand a lot and generally I don't really enjoy fiddling with it, so atm I think I'll leave it as-is as it seems to work. I'm open to PRs, though.

I just pushed a small example on playlist usage in README.md. Basically, you get a list of dicts out of player.playlist indicating the playlist's contents (file paths, titles and, if available, the currently playing item). To modify the playlist, atm you have to use playlist_move, playlist_remove and loadfile(..., 'append') (now aliased to playlist_append) since the mpv backend only exposes these and a readonly playlist node property.

A future possibility would be to have some kind of proxy object returned from player.playlist that will call the backend modifier functions as appropriate. However, IMHO that would be overkill as it would introduce a lot of playlist-specific code and most users of this module can probably just implement playlists themselves in three lines of code. Using mpv's playlist feature IMHO really only provides value for very simple use cases or when its playlist file parsing is needed.

Thank you for your feedback. Feel free to just open an issue or two if you have any further questions. That makes your questions more easily searchable for others.