aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/command.c6
-rw-r--r--src/playlist_print.c37
-rw-r--r--src/playlist_print.h11
3 files changed, 54 insertions, 0 deletions
diff --git a/src/command.c b/src/command.c
index 5b94cbe7f..e591d06e3 100644
--- a/src/command.c
+++ b/src/command.c
@@ -733,6 +733,9 @@ handle_load(struct client *client, G_GNUC_UNUSED int argc, char *argv[])
static enum command_return
handle_listplaylist(struct client *client, G_GNUC_UNUSED int argc, char *argv[])
{
+ if (playlist_file_print(client, argv[1], false))
+ return COMMAND_RETURN_OK;
+
bool ret;
ret = spl_print(client, argv[1], false);
@@ -748,6 +751,9 @@ static enum command_return
handle_listplaylistinfo(struct client *client,
G_GNUC_UNUSED int argc, char *argv[])
{
+ if (playlist_file_print(client, argv[1], true))
+ return COMMAND_RETURN_OK;
+
bool ret;
ret = spl_print(client, argv[1], true);
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;
+}
diff --git a/src/playlist_print.h b/src/playlist_print.h
index bbb2e8adc..b3a0446ed 100644
--- a/src/playlist_print.h
+++ b/src/playlist_print.h
@@ -101,4 +101,15 @@ playlist_print_changes_position(struct client *client,
bool
spl_print(struct client *client, const char *name_utf8, bool detail);
+/**
+ * Send the playlist file to the client.
+ *
+ * @param client the client which requested the playlist
+ * @param uri the URI of the playlist file in UTF-8 encoding
+ * @param detail true if all details should be printed
+ * @return true on success, false if the playlist does not exist
+ */
+bool
+playlist_file_print(struct client *client, const char *uri, bool detail);
+
#endif