db/update: scan CUE playlist contents

This commit adds a PlaylistPlugin attribute "as_folder" which for now
is only enabled in the "CUE" playlist plugin (which handles separate
"*.cue" files).  If a playlist with this flag set is being scanned
during database update, it will be parsed and its contents will be
added to the database.  This allows clients to inspect them like
directories and its contents will be searchable.

Closes https://github.com/MusicPlayerDaemon/MPD/issues/39
This commit is contained in:
Max Kellermann
2019-09-02 20:01:30 +02:00
parent 5fdb804a50
commit d63e2c2641
7 changed files with 100 additions and 1 deletions

View File

@@ -69,6 +69,12 @@ struct PlaylistPlugin {
const char *const*suffixes = nullptr;
const char *const*mime_types = nullptr;
/**
* If true, then playlists of this type are shown in the
* database as folders.
*/
bool as_folder = false;
constexpr PlaylistPlugin(const char *_name,
std::unique_ptr<SongEnumerator> (*_open_uri)(const char *uri,
Mutex &mutex)) noexcept
@@ -104,6 +110,12 @@ struct PlaylistPlugin {
return copy;
}
constexpr auto WithAsFolder(bool value=true) noexcept {
auto copy = *this;
copy.as_folder = value;
return copy;
}
/**
* Does the plugin announce the specified URI scheme?
*/

View File

@@ -72,5 +72,6 @@ static const char *const cue_playlist_mime_types[] = {
const PlaylistPlugin cue_playlist_plugin =
PlaylistPlugin("cue", cue_playlist_open_stream)
.WithAsFolder()
.WithSuffixes(cue_playlist_suffixes)
.WithMimeTypes(cue_playlist_mime_types);