Can now browse by directorie in the Subsonic API, ref #474

This commit is contained in:
emeric
2024-07-13 14:22:19 +02:00
parent 9292b05732
commit 980709dbcf
20 changed files with 613 additions and 224 deletions
+21
View File
@@ -31,6 +31,11 @@ namespace lms::api::subsonic
return "ar-" + id.toString();
}
std::string idToString(db::DirectoryId id)
{
return "dir-" + id.toString();
}
std::string idToString(db::MediaLibraryId id)
{
// No need to prefix as this is only used at well known places
@@ -76,6 +81,22 @@ namespace lms::core::stringUtils
return std::nullopt;
}
template<>
std::optional<db::DirectoryId> readAs(std::string_view str)
{
std::vector<std::string_view> values{ core::stringUtils::splitString(str, '-') };
if (values.size() != 2)
return std::nullopt;
if (values[0] != "dir")
return std::nullopt;
if (const auto value{ core::stringUtils::readAs<db::DirectoryId::ValueType>(values[1]) })
return db::DirectoryId{ *value };
return std::nullopt;
}
template<>
std::optional<db::MediaLibraryId> readAs(std::string_view str)
{