Allow range in listplaylist and listplaylistinfo

This commit is contained in:
jcorporation
2024-02-08 21:26:28 +01:00
parent c71e586c53
commit a3794f8c3b
6 changed files with 37 additions and 13 deletions
+19 -4
View File
@@ -18,14 +18,25 @@ static void
playlist_provider_print(Response &r,
const SongLoader &loader,
const char *uri,
SongEnumerator &e, bool detail) noexcept
SongEnumerator &e,
unsigned start_index,
unsigned end_index,
bool detail) noexcept
{
const auto base_uri = uri != nullptr
? PathTraitsUTF8::GetParent(uri)
: ".";
std::unique_ptr<DetachedSong> song;
while ((song = e.NextSong()) != nullptr) {
for (unsigned i = 0;
i < end_index && (song = e.NextSong()) != nullptr;
++i) {
if (i < start_index) {
/* skip songs before the start index */
continue;
}
if (playlist_check_translate_song(*song, base_uri,
loader) &&
detail)
@@ -40,7 +51,10 @@ playlist_provider_print(Response &r,
bool
playlist_file_print(Response &r, Partition &partition,
const SongLoader &loader,
const LocatedUri &uri, bool detail)
const LocatedUri &uri,
unsigned start_index,
unsigned end_index,
bool detail)
{
Mutex mutex;
@@ -56,6 +70,7 @@ playlist_file_print(Response &r, Partition &partition,
if (playlist == nullptr)
return false;
playlist_provider_print(r, loader, uri.canonical_uri, *playlist, detail);
playlist_provider_print(r, loader, uri.canonical_uri, *playlist,
start_index, end_index, detail);
return true;
}
+3 -1
View File
@@ -18,6 +18,8 @@ struct Partition;
bool
playlist_file_print(Response &r, Partition &partition,
const SongLoader &loader,
const LocatedUri &uri, bool detail);
const LocatedUri &uri,
unsigned start_index, unsigned end_index,
bool detail);
#endif