Re: [Rhythmbox-devel] Accessing Playlist Data
- From: Jonathan Matthew <jonathan d14n org>
- To: Gayan Weerakutti <gayan linuxdeveloper space>
- Cc: "rhythmbox-devel gnome org" <rhythmbox-devel gnome org>
- Subject: Re: [Rhythmbox-devel] Accessing Playlist Data
- Date: Sun, 15 May 2016 18:26:45 +1000
On Mon, Apr 25, 2016 at 05:29:34PM +0000, Gayan Weerakutti wrote:
Hi there,
I'm writing a plugin that enable users to export music files of the selected playlist which is quite
similar to the sendto plugin but let you save files directly to the disk.
But I can't find a way to get a reference to the currently selected playlist item.
I did get the reference to the playlist header item as:
display_page_model = shell.props.display_page_model.props.child_model
playlist = [x for x in display_page_model if x[1].props.id == "playlists"][0]
playlist_iter = playlist.iterchildren()
for i in playlist_iter:
playlist_source = i[1]
Here I see AutoPlaylistSource, StaticPlaylistSource objects which seems to be not iterable. I think I'd
need to get an array of playback URIs of songs in the selected playlist.
Sources contains query models, which are gtk tree models that contains one row
for each track in the source. For exporting the contents of a playlist,
you'd probably want the base query model, which includes all tracks in the
playlist regardless of whether they're currently filtered out by search terms
or album/artist/genre browser selections. You access this using the
'base-query-model' property on the source object, so in python that would be:
qm = playlist_source.props.base_query_model
query models contain rhythmdb entry items, so you'd then get the location
for each entry and then copy that, or whatever.
[Date Prev][Date Next] [Thread Prev][Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]