This commit is contained in:
Evan G 2026-02-03 03:27:13 +10:00 committed by GitHub
commit 5d74c9a259
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 15 additions and 1 deletions

View file

@ -267,7 +267,7 @@ class SmartPlaylistPlugin(BeetsPlugin):
tpl = self.config["uri_format"].get()
prefix = bytestring_path(self.config["prefix"].as_str())
relative_to = self.config["relative_to"].get()
if relative_to:
if relative_to != "m3u":
relative_to = normpath(relative_to)
# Maps playlist filenames to lists of track filenames.
@ -316,6 +316,8 @@ class SmartPlaylistPlugin(BeetsPlugin):
item_uri = item.path
if tpl:
item_uri = tpl.replace("$id", str(item.id)).encode("utf-8")
if relative_to == "m3u":
item_uri = "m3u"
else:
if relative_to:
item_uri = os.path.relpath(item_uri, relative_to)
@ -354,6 +356,17 @@ class SmartPlaylistPlugin(BeetsPlugin):
f.write(b"#EXTM3U\n")
for entry in m3us[m3u]:
item = entry.item
if entry.uri == "m3u":
entry.uri = os.path.relpath(
item.path, os.path.dirname(m3u_path)
)
if self.config["forward_slash"].get():
entry.uri = path_as_posix(entry.uri)
if self.config["urlencode"]:
entry.uri = bytestring_path(
pathname2url(entry.uri)
)
entry.uri = prefix + entry.uri
comment = ""
if extm3u:
attr = [(k, entry.item[k]) for k in keys]

View file

@ -552,6 +552,7 @@ New features:
from the match. It is thus possible to create more general rules, applying to
many different artists at once.
* Ability to use relative_to as "m3u" to set playlist files as relative to where each playlist is at, including subdirectories.
Bug fixes:
- Check if running python from the Microsoft Store and provide feedback to