New command playlistlength
Count the number of songs and their total playtime in the playlist.
This commit is contained in:
@@ -148,6 +148,7 @@ static constexpr struct command commands[] = {
|
||||
{ "playlistfind", PERMISSION_READ, 1, -1, handle_playlistfind },
|
||||
{ "playlistid", PERMISSION_READ, 0, 1, handle_playlistid },
|
||||
{ "playlistinfo", PERMISSION_READ, 0, 1, handle_playlistinfo },
|
||||
{ "playlistlength", PERMISSION_READ, 1, 1, handle_playlistlength },
|
||||
{ "playlistmove", PERMISSION_CONTROL, 3, 3, handle_playlistmove },
|
||||
{ "playlistsearch", PERMISSION_READ, 1, -1, handle_playlistsearch },
|
||||
{ "plchanges", PERMISSION_READ, 1, 2, handle_plchanges },
|
||||
|
@@ -17,6 +17,7 @@
|
||||
#include "SongLoader.hxx"
|
||||
#include "song/DetachedSong.hxx"
|
||||
#include "BulkEdit.hxx"
|
||||
#include "playlist/Length.hxx"
|
||||
#include "playlist/PlaylistQueue.hxx"
|
||||
#include "playlist/Print.hxx"
|
||||
#include "TimePrint.hxx"
|
||||
@@ -149,6 +150,23 @@ handle_listplaylistinfo(Client &client, Request args, Response &r)
|
||||
throw PlaylistError::NoSuchList();
|
||||
}
|
||||
|
||||
CommandResult
|
||||
handle_playlistlength(Client &client, Request args, Response &r)
|
||||
{
|
||||
const auto name = LocateUri(UriPluginKind::PLAYLIST, args.front(),
|
||||
&client
|
||||
#ifdef ENABLE_DATABASE
|
||||
, nullptr
|
||||
#endif
|
||||
);
|
||||
|
||||
if (playlist_file_length(r, client.GetPartition(), SongLoader(client),
|
||||
name))
|
||||
return CommandResult::OK;
|
||||
|
||||
throw PlaylistError::NoSuchList();
|
||||
}
|
||||
|
||||
CommandResult
|
||||
handle_rm([[maybe_unused]] Client &client, Request args, [[maybe_unused]] Response &r)
|
||||
{
|
||||
|
@@ -26,6 +26,9 @@ handle_listplaylist(Client &client, Request request, Response &response);
|
||||
CommandResult
|
||||
handle_listplaylistinfo(Client &client, Request request, Response &response);
|
||||
|
||||
CommandResult
|
||||
handle_playlistlength(Client &client, Request request, Response &response);
|
||||
|
||||
CommandResult
|
||||
handle_rm(Client &client, Request request, Response &response);
|
||||
|
||||
|
Reference in New Issue
Block a user