mirror of
https://github.com/beetbox/beets.git
synced 2025-12-06 08:39:17 +01:00
Merge branch 'master' into importer-typehints-and-refactor
This commit is contained in:
commit
918fd863f3
4 changed files with 11 additions and 10 deletions
|
|
@ -14,8 +14,8 @@
|
|||
|
||||
"""Generates smart playlists based on beets queries."""
|
||||
|
||||
import json
|
||||
import os
|
||||
from urllib.parse import quote
|
||||
from urllib.request import pathname2url
|
||||
|
||||
from beets import ui
|
||||
|
|
@ -327,7 +327,8 @@ class SmartPlaylistPlugin(BeetsPlugin):
|
|||
if extm3u:
|
||||
attr = [(k, entry.item[k]) for k in keys]
|
||||
al = [
|
||||
f" {a[0]}={json.dumps(str(a[1]))}" for a in attr
|
||||
f" {key}=\"{quote(str(value), safe='/:')}\""
|
||||
for key, value in attr
|
||||
]
|
||||
attrs = "".join(al)
|
||||
comment = "#EXTINF:{}{},{} - {}\n".format(
|
||||
|
|
|
|||
|
|
@ -88,6 +88,8 @@ Other changes:
|
|||
:bug:`5539`
|
||||
* Added some typehints: ImportSession and Pipeline have typehints now. Should
|
||||
improve useability for new developers.
|
||||
* :doc:`/plugins/smartplaylist`: URL-encode additional item `fields` within generated
|
||||
EXTM3U playlists instead of JSON-encoding them.
|
||||
|
||||
2.2.0 (December 02, 2024)
|
||||
-------------------------
|
||||
|
|
|
|||
|
|
@ -97,27 +97,25 @@ In case you want to export additional fields from the beets database into the
|
|||
generated playlists, you can do so by specifying them within the ``fields``
|
||||
configuration option and setting the ``output`` option to ``extm3u``.
|
||||
For instance the following configuration exports the ``id`` and ``genre``
|
||||
fields:
|
||||
fields::
|
||||
|
||||
smartplaylist:
|
||||
playlist_dir: /data/playlists
|
||||
relative_to: /data/playlists
|
||||
output: extm3u
|
||||
fields:
|
||||
|
||||
- id
|
||||
- genre
|
||||
|
||||
playlists:
|
||||
|
||||
- name: all.m3u
|
||||
query: ''
|
||||
|
||||
A resulting ``all.m3u`` file could look as follows:
|
||||
Values of additional fields are URL-encoded.
|
||||
A resulting ``all.m3u`` file could look as follows::
|
||||
|
||||
#EXTM3U
|
||||
#EXTINF:805 id="1931" genre="Jazz",Miles Davis - Autumn Leaves
|
||||
../music/Albums/Miles Davis/Autumn Leaves/02 Autumn Leaves.mp3
|
||||
#EXTINF:805 id="1931" genre="Progressive%20Rock",Led Zeppelin - Stairway to Heaven
|
||||
../music/singles/Led Zeppelin/Stairway to Heaven.mp3
|
||||
|
||||
To give a usage example, the `webm3u`_ and `Beetstream`_ plugins read the
|
||||
exported ``id`` field, allowing you to serve your local m3u playlists via HTTP.
|
||||
|
|
|
|||
|
|
@ -283,7 +283,7 @@ class SmartPlaylistTest(BeetsTestCase):
|
|||
assert (
|
||||
content
|
||||
== b"#EXTM3U\n"
|
||||
+ b'#EXTINF:300 id="456" genre="Fake Genre",Fake Artist - fake Title\n'
|
||||
+ b'#EXTINF:300 id="456" genre="Fake%20Genre",Fake Artist - fake Title\n'
|
||||
+ b"/tagada.mp3\n"
|
||||
)
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue