playlist/registry: add option "as_directory"
This allows users to disable the "CUE files as directories" feature without having to disable the CUE playlist plugin completely. This feature has been annoying some users.
This commit is contained in:
parent
d69a1f98af
commit
92a218b7a9
1
NEWS
1
NEWS
|
@ -6,6 +6,7 @@ ver 0.22.2 (2020/10/28)
|
||||||
- qobuz/tidal: fix protocol errors due to newlines in error messages
|
- qobuz/tidal: fix protocol errors due to newlines in error messages
|
||||||
- smbclient: disable by default due to libsmbclient crash bug
|
- smbclient: disable by default due to libsmbclient crash bug
|
||||||
* playlist
|
* playlist
|
||||||
|
- add option "as_directory", making CUE file expansion optional
|
||||||
- soundcloud: fix protocol errors due to newlines in error messages
|
- soundcloud: fix protocol errors due to newlines in error messages
|
||||||
* state_file: save on shutdown
|
* state_file: save on shutdown
|
||||||
|
|
||||||
|
|
|
@ -1231,6 +1231,8 @@ asx
|
||||||
|
|
||||||
Reads :file:`.asx` playlist files.
|
Reads :file:`.asx` playlist files.
|
||||||
|
|
||||||
|
.. _cue_playlist:
|
||||||
|
|
||||||
cue
|
cue
|
||||||
---
|
---
|
||||||
Reads :file:`.cue` files.
|
Reads :file:`.cue` files.
|
||||||
|
|
|
@ -500,6 +500,11 @@ The following table lists the playlist_plugin options valid for all plugins:
|
||||||
- The name of the plugin
|
- The name of the plugin
|
||||||
* - **enabled yes|no**
|
* - **enabled yes|no**
|
||||||
- Allows you to disable a playlist plugin without recompiling. By default, all plugins are enabled.
|
- Allows you to disable a playlist plugin without recompiling. By default, all plugins are enabled.
|
||||||
|
* - **as_directory yes|no**
|
||||||
|
- With this option, a playlist file of this type is parsed during
|
||||||
|
database update and converted to a virtual directory, allowing
|
||||||
|
MPD clients to access individual entries. By default, this is
|
||||||
|
only enabled for the :ref:`cue plugin <cue_playlist>`.
|
||||||
|
|
||||||
More information can be found in the :ref:`playlist_plugins`
|
More information can be found in the :ref:`playlist_plugins`
|
||||||
reference.
|
reference.
|
||||||
|
|
|
@ -95,7 +95,7 @@ UpdateWalk::UpdatePlaylistFile(Directory &directory,
|
||||||
if (plugin == nullptr)
|
if (plugin == nullptr)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (plugin->as_folder)
|
if (GetPlaylistPluginAsFolder(*plugin))
|
||||||
UpdatePlaylistFile(directory, name, info, *plugin);
|
UpdatePlaylistFile(directory, name, info, *plugin);
|
||||||
|
|
||||||
PlaylistInfo pi(name, info.mtime);
|
PlaylistInfo pi(name, info.mtime);
|
||||||
|
|
|
@ -52,7 +52,16 @@ static bool
|
||||||
HavePlaylistPluginForFilename(const char *filename) noexcept
|
HavePlaylistPluginForFilename(const char *filename) noexcept
|
||||||
{
|
{
|
||||||
const char *suffix = PathTraitsUTF8::GetFilenameSuffix(filename);
|
const char *suffix = PathTraitsUTF8::GetFilenameSuffix(filename);
|
||||||
return suffix != nullptr && playlist_suffix_supported(suffix);
|
if (suffix == nullptr)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
const auto plugin = FindPlaylistPluginBySuffix(suffix);
|
||||||
|
if (plugin == nullptr)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
/* discard the special directory if the user disables the
|
||||||
|
plugin's "as_directory" setting */
|
||||||
|
return GetPlaylistPluginAsFolder(*plugin);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
|
|
|
@ -71,6 +71,9 @@ static constexpr unsigned n_playlist_plugins =
|
||||||
/** which plugins have been initialized successfully? */
|
/** which plugins have been initialized successfully? */
|
||||||
static bool playlist_plugins_enabled[n_playlist_plugins];
|
static bool playlist_plugins_enabled[n_playlist_plugins];
|
||||||
|
|
||||||
|
/** which plugins have the "as_folder" option enabled? */
|
||||||
|
static bool playlist_plugins_as_folder[n_playlist_plugins];
|
||||||
|
|
||||||
#define playlist_plugins_for_each_enabled(plugin) \
|
#define playlist_plugins_for_each_enabled(plugin) \
|
||||||
playlist_plugins_for_each(plugin) \
|
playlist_plugins_for_each(plugin) \
|
||||||
if (playlist_plugins_enabled[playlist_plugin_iterator - playlist_plugins])
|
if (playlist_plugins_enabled[playlist_plugin_iterator - playlist_plugins])
|
||||||
|
@ -96,6 +99,10 @@ playlist_list_global_init(const ConfigData &config)
|
||||||
|
|
||||||
playlist_plugins_enabled[i] =
|
playlist_plugins_enabled[i] =
|
||||||
playlist_plugin_init(playlist_plugins[i], *param);
|
playlist_plugin_init(playlist_plugins[i], *param);
|
||||||
|
|
||||||
|
playlist_plugins_as_folder[i] =
|
||||||
|
param->GetBlockValue("as_directory",
|
||||||
|
playlist_plugins[i]->as_folder);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -106,6 +113,16 @@ playlist_list_global_finish() noexcept
|
||||||
playlist_plugin_finish(plugin);
|
playlist_plugin_finish(plugin);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool
|
||||||
|
GetPlaylistPluginAsFolder(const PlaylistPlugin &plugin) noexcept
|
||||||
|
{
|
||||||
|
/* this loop has no end condition because it must finish when
|
||||||
|
the plugin was found */
|
||||||
|
for (std::size_t i = 0;; ++i)
|
||||||
|
if (playlist_plugins[i] == &plugin)
|
||||||
|
return playlist_plugins_as_folder[i];
|
||||||
|
}
|
||||||
|
|
||||||
static std::unique_ptr<SongEnumerator>
|
static std::unique_ptr<SongEnumerator>
|
||||||
playlist_list_open_uri_scheme(const char *uri, Mutex &mutex,
|
playlist_list_open_uri_scheme(const char *uri, Mutex &mutex,
|
||||||
bool *tried)
|
bool *tried)
|
||||||
|
|
|
@ -59,6 +59,14 @@ public:
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Shall this playlists supported by this plugin be represented as
|
||||||
|
* directories in the database?
|
||||||
|
*/
|
||||||
|
gcc_const
|
||||||
|
bool
|
||||||
|
GetPlaylistPluginAsFolder(const PlaylistPlugin &plugin) noexcept;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Opens a playlist by its URI.
|
* Opens a playlist by its URI.
|
||||||
*/
|
*/
|
||||||
|
|
Loading…
Reference in New Issue