mirror of
https://github.com/beetbox/beets.git
synced 2026-01-30 12:02:41 +01:00
Merge pull request #5047 from mgoltzsche/expose-smartplaylist-cli-opts
smartplaylist: expose config as CLI options
This commit is contained in:
commit
618af1511e
3 changed files with 55 additions and 6 deletions
|
|
@ -72,16 +72,53 @@ class SmartPlaylistPlugin(BeetsPlugin):
|
|||
action="store_true",
|
||||
help="display query results but don't write playlist files.",
|
||||
)
|
||||
spl_update.parser.add_option(
|
||||
"--pretend-paths",
|
||||
action="store_true",
|
||||
dest="pretend_paths",
|
||||
help="in pretend mode, log the playlist item URIs/paths.",
|
||||
)
|
||||
spl_update.parser.add_option(
|
||||
"-d",
|
||||
"--playlist-dir",
|
||||
dest="playlist_dir",
|
||||
metavar="PATH",
|
||||
type="string",
|
||||
help="directory to write the generated playlist files to.",
|
||||
)
|
||||
spl_update.parser.add_option(
|
||||
"--relative-to",
|
||||
dest="relative_to",
|
||||
metavar="PATH",
|
||||
type="string",
|
||||
help="Generate playlist item paths relative to this path.",
|
||||
)
|
||||
spl_update.parser.add_option(
|
||||
"--prefix",
|
||||
type="string",
|
||||
help="prepend string to every path in the playlist file.",
|
||||
)
|
||||
spl_update.parser.add_option(
|
||||
"--forward-slash",
|
||||
action="store_true",
|
||||
dest="forward_slash",
|
||||
help="Force forward slash in paths within playlists.",
|
||||
)
|
||||
spl_update.parser.add_option(
|
||||
"--urlencode",
|
||||
action="store_true",
|
||||
help="URL-encode all paths.",
|
||||
)
|
||||
spl_update.parser.add_option(
|
||||
"--extm3u",
|
||||
action="store_true",
|
||||
help="add artist/title as m3u8 comments to playlists.",
|
||||
help="generate extm3u/m3u8 playlists.",
|
||||
)
|
||||
spl_update.parser.add_option(
|
||||
"--no-extm3u",
|
||||
action="store_false",
|
||||
dest="extm3u",
|
||||
help="do not add artist/title as extm3u comments to playlists.",
|
||||
help="generate extm3u/m3u8 playlists.",
|
||||
)
|
||||
spl_update.func = self.update_cmd
|
||||
return [spl_update]
|
||||
|
|
@ -111,7 +148,13 @@ class SmartPlaylistPlugin(BeetsPlugin):
|
|||
else:
|
||||
self._matched_playlists = self._unmatched_playlists
|
||||
|
||||
self.update_playlists(lib, opts.extm3u, opts.pretend)
|
||||
self.__apply_opts_to_config(opts)
|
||||
self.update_playlists(lib, opts.pretend)
|
||||
|
||||
def __apply_opts_to_config(self, opts):
|
||||
for k, v in opts.__dict__.items():
|
||||
if v is not None and k in self.config:
|
||||
self.config[k] = v
|
||||
|
||||
def build_queries(self):
|
||||
"""
|
||||
|
|
@ -197,7 +240,7 @@ class SmartPlaylistPlugin(BeetsPlugin):
|
|||
|
||||
self._unmatched_playlists -= self._matched_playlists
|
||||
|
||||
def update_playlists(self, lib, extm3u=None, pretend=False):
|
||||
def update_playlists(self, lib, pretend=False):
|
||||
if pretend:
|
||||
self._log.info(
|
||||
"Showing query results for {0} smart playlists...",
|
||||
|
|
@ -256,7 +299,7 @@ class SmartPlaylistPlugin(BeetsPlugin):
|
|||
os.path.join(playlist_dir, bytestring_path(m3u))
|
||||
)
|
||||
mkdirall(m3u_path)
|
||||
extm3u = extm3u is None and self.config["extm3u"] or extm3u
|
||||
extm3u = self.config["extm3u"]
|
||||
with open(syspath(m3u_path), "wb") as f:
|
||||
if extm3u:
|
||||
f.write(b"#EXTM3U\n")
|
||||
|
|
|
|||
|
|
@ -149,6 +149,7 @@ New features:
|
|||
* :ref:`import-cmd`: Expose import.quiet_fallback as CLI option.
|
||||
* :ref:`import-cmd`: Expose `import.incremental_skip_later` as CLI option.
|
||||
* :doc:`/plugins/smartplaylist`: Add new config option `smartplaylist.extm3u`.
|
||||
* :doc:`/plugins/smartplaylist`: Expose config options as CLI options.
|
||||
|
||||
Bug fixes:
|
||||
|
||||
|
|
|
|||
|
|
@ -115,7 +115,12 @@ other configuration options are:
|
|||
- **prefix**: Prepend this string to every path in the playlist file. For
|
||||
example, you could use the URL for a server where the music is stored.
|
||||
Default: empty string.
|
||||
- **urlencoded**: URL-encode all paths. Default: ``no``.
|
||||
- **urlencode**: URL-encode all paths. Default: ``no``.
|
||||
- **pretend_paths**: When running with ``--pretend``, show the actual file
|
||||
paths that will be written to the m3u file. Default: ``false``.
|
||||
- **extm3u**: Generate extm3u/m3u8 playlists. Default ``ǹo``.
|
||||
|
||||
For many configuration options, there is a corresponding CLI option, e.g.
|
||||
``--playlist-dir``, ``--relative-to``, ``--prefix``, ``--forward-slash``,
|
||||
``--urlencode``, ``--extm3u``, ``--pretend-paths``.
|
||||
CLI options take precedence over those specified within the configuration file.
|
||||
|
|
|
|||
Loading…
Reference in a new issue