mirror of
https://github.com/beetbox/beets.git
synced 2025-12-25 01:53:31 +01:00
Merge pull request #5053 from mgoltzsche/change-smartplaylist-extm3u-option
smartplaylist: change option --extm3u to --output
This commit is contained in:
commit
adf4b9779a
4 changed files with 19 additions and 20 deletions
|
|
@ -49,7 +49,7 @@ class SmartPlaylistPlugin(BeetsPlugin):
|
|||
"prefix": "",
|
||||
"urlencode": False,
|
||||
"pretend_paths": False,
|
||||
"extm3u": False,
|
||||
"output": "m3u",
|
||||
}
|
||||
)
|
||||
|
||||
|
|
@ -91,7 +91,7 @@ class SmartPlaylistPlugin(BeetsPlugin):
|
|||
dest="relative_to",
|
||||
metavar="PATH",
|
||||
type="string",
|
||||
help="Generate playlist item paths relative to this path.",
|
||||
help="generate playlist item paths relative to this path.",
|
||||
)
|
||||
spl_update.parser.add_option(
|
||||
"--prefix",
|
||||
|
|
@ -102,7 +102,7 @@ class SmartPlaylistPlugin(BeetsPlugin):
|
|||
"--forward-slash",
|
||||
action="store_true",
|
||||
dest="forward_slash",
|
||||
help="Force forward slash in paths within playlists.",
|
||||
help="force forward slash in paths within playlists.",
|
||||
)
|
||||
spl_update.parser.add_option(
|
||||
"--urlencode",
|
||||
|
|
@ -110,15 +110,9 @@ class SmartPlaylistPlugin(BeetsPlugin):
|
|||
help="URL-encode all paths.",
|
||||
)
|
||||
spl_update.parser.add_option(
|
||||
"--extm3u",
|
||||
action="store_true",
|
||||
help="generate extm3u/m3u8 playlists.",
|
||||
)
|
||||
spl_update.parser.add_option(
|
||||
"--no-extm3u",
|
||||
action="store_false",
|
||||
dest="extm3u",
|
||||
help="generate extm3u/m3u8 playlists.",
|
||||
"--output",
|
||||
type="string",
|
||||
help="specify the playlist format: m3u|m3u8.",
|
||||
)
|
||||
spl_update.func = self.update_cmd
|
||||
return [spl_update]
|
||||
|
|
@ -299,9 +293,14 @@ class SmartPlaylistPlugin(BeetsPlugin):
|
|||
os.path.join(playlist_dir, bytestring_path(m3u))
|
||||
)
|
||||
mkdirall(m3u_path)
|
||||
extm3u = self.config["extm3u"]
|
||||
pl_format = self.config["output"].get()
|
||||
if pl_format != "m3u" and pl_format != "m3u8":
|
||||
msg = "Unsupported output format '{}' provided! "
|
||||
msg += "Supported: m3u, m3u8"
|
||||
raise Exception(msg.format(pl_format))
|
||||
m3u8 = pl_format == "m3u8"
|
||||
with open(syspath(m3u_path), "wb") as f:
|
||||
if extm3u:
|
||||
if m3u8:
|
||||
f.write(b"#EXTM3U\n")
|
||||
for entry in m3us[m3u]:
|
||||
path = entry["path"]
|
||||
|
|
@ -311,7 +310,7 @@ class SmartPlaylistPlugin(BeetsPlugin):
|
|||
if self.config["urlencode"]:
|
||||
path = bytestring_path(pathname2url(path))
|
||||
comment = ""
|
||||
if extm3u:
|
||||
if m3u8:
|
||||
comment = "#EXTINF:{},{} - {}\n".format(
|
||||
int(item.length), item.artist, item.title
|
||||
)
|
||||
|
|
|
|||
|
|
@ -148,7 +148,7 @@ New features:
|
|||
`synced` option to prefer synced lyrics over plain lyrics.
|
||||
* :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`: Add new config option `smartplaylist.output`.
|
||||
* :doc:`/plugins/smartplaylist`: Expose config options as CLI options.
|
||||
|
||||
Bug fixes:
|
||||
|
|
|
|||
|
|
@ -118,9 +118,9 @@ other configuration options are:
|
|||
- **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``.
|
||||
- **output**: Specify the playlist format: m3u|m3u8. Default ``m3u``.
|
||||
|
||||
For many configuration options, there is a corresponding CLI option, e.g.
|
||||
``--playlist-dir``, ``--relative-to``, ``--prefix``, ``--forward-slash``,
|
||||
``--urlencode``, ``--extm3u``, ``--pretend-paths``.
|
||||
``--urlencode``, ``--output``, ``--pretend-paths``.
|
||||
CLI options take precedence over those specified within the configuration file.
|
||||
|
|
|
|||
|
|
@ -191,7 +191,7 @@ class SmartPlaylistTest(_common.TestCase):
|
|||
|
||||
self.assertEqual(content, b"/tagada.mp3\n")
|
||||
|
||||
def test_playlist_update_extm3u(self):
|
||||
def test_playlist_update_output_m3u8(self):
|
||||
spl = SmartPlaylistPlugin()
|
||||
|
||||
i = MagicMock()
|
||||
|
|
@ -215,7 +215,7 @@ class SmartPlaylistTest(_common.TestCase):
|
|||
spl._matched_playlists = [pl]
|
||||
|
||||
dir = bytestring_path(mkdtemp())
|
||||
config["smartplaylist"]["extm3u"] = True
|
||||
config["smartplaylist"]["output"] = "m3u8"
|
||||
config["smartplaylist"]["prefix"] = "http://beets:8337/files"
|
||||
config["smartplaylist"]["relative_to"] = False
|
||||
config["smartplaylist"]["playlist_dir"] = py3_path(dir)
|
||||
|
|
|
|||
Loading…
Reference in a new issue