[gnome-music/freeze-break: 82/107] playlists: Implement method for adding tracks to playlist



commit 73902d6009db17d81f89ceb840821adb3defffb8
Author: Arnel A. Borja <arnelborja src gnome org>
Date:   Sat Sep 7 00:18:05 2013 +0800

    playlists: Implement method for adding tracks to playlist

 gnomemusic/playlists.py |   10 ++++++++--
 1 files changed, 8 insertions(+), 2 deletions(-)
---
diff --git a/gnomemusic/playlists.py b/gnomemusic/playlists.py
index 06125bc..8bacd9d 100644
--- a/gnomemusic/playlists.py
+++ b/gnomemusic/playlists.py
@@ -43,8 +43,14 @@ class Playlists:
             playlist_names.append(name)
         return playlist_names
 
-    def add_to_playlist(self, playlist_name):
-        pass
+    def add_to_playlist(self, playlist_name, uris):
+        parser = TotemPlParser.Parser()
+        playlist = TotemPlParser.Playlist()
+        pl_file = Gio.file_new_for_path(self.get_path_to_playlist(playlist_name))
+        for uri in uris:
+            _iter = playlist.append()
+            playlist.set_value(_iter, TotemPlParser.PARSER_FIELD_URI, uri)
+        parser.save(playlist, pl_file, playlist_name, TotemPlParser.ParserType.PLS)
 
     def delete_playlist(self, playlist_name):
         pass


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]