aboutsummaryrefslogtreecommitdiffstats
path: root/src/playlist_print.c
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2010-02-08 10:19:43 +0100
committerMax Kellermann <max@duempel.org>2010-02-08 11:11:43 +0100
commit059d1dc7f252f933ba1c6a9b69116d3eb53c9771 (patch)
tree8ca576486860e041023687df91376f9524afe008 /src/playlist_print.c
parent7fbb856eee2007570e776ddedf591de65f06aefb (diff)
downloadmpd-059d1dc7f252f933ba1c6a9b69116d3eb53c9771.tar.gz
mpd-059d1dc7f252f933ba1c6a9b69116d3eb53c9771.tar.xz
mpd-059d1dc7f252f933ba1c6a9b69116d3eb53c9771.zip
command: "listplaylist" dumps playlist files
Same for "listplaylistinfo".
Diffstat (limited to '')
-rw-r--r--src/playlist_print.c37
1 files changed, 37 insertions, 0 deletions
diff --git a/src/playlist_print.c b/src/playlist_print.c
index 97d0e2523..020b0fa87 100644
--- a/src/playlist_print.c
+++ b/src/playlist_print.c
@@ -19,6 +19,10 @@
#include "config.h"
#include "playlist_print.h"
+#include "playlist_list.h"
+#include "playlist_plugin.h"
+#include "playlist_mapper.h"
+#include "playlist_song.h"
#include "queue_print.h"
#include "stored_playlist.h"
#include "song_print.h"
@@ -139,3 +143,36 @@ spl_print(struct client *client, const char *name_utf8, bool detail)
spl_free(list);
return true;
}
+
+static void
+playlist_provider_print(struct client *client, const char *uri,
+ struct playlist_provider *playlist, bool detail)
+{
+ struct song *song;
+ char *base_uri = uri != NULL ? g_path_get_dirname(uri) : NULL;
+
+ while ((song = playlist_plugin_read(playlist)) != NULL) {
+ song = playlist_check_translate_song(song, base_uri);
+ if (song == NULL)
+ continue;
+
+ if (detail)
+ song_print_info(client, song);
+ else
+ song_print_uri(client, song);
+ }
+
+ g_free(base_uri);
+}
+
+bool
+playlist_file_print(struct client *client, const char *uri, bool detail)
+{
+ struct playlist_provider *playlist = playlist_mapper_open(uri);
+ if (playlist == NULL)
+ return false;
+
+ playlist_provider_print(client, uri, playlist, detail);
+ playlist_plugin_close(playlist);
+ return true;
+}