From aae0260484a568466fca4e316fa72fc661524031 Mon Sep 17 00:00:00 2001 From: Pierre Ayoub Date: Sat, 8 Feb 2025 21:02:15 +0100 Subject: [PATCH] [beetsplug/spl] Add the dest_regen/dest-regen option --- beetsplug/smartplaylist.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/beetsplug/smartplaylist.py b/beetsplug/smartplaylist.py index ff5e25612..146cbf6ee 100644 --- a/beetsplug/smartplaylist.py +++ b/beetsplug/smartplaylist.py @@ -53,6 +53,7 @@ class SmartPlaylistPlugin(BeetsPlugin): super().__init__() self.config.add( { + "dest_regen": False, "relative_to": None, "playlist_dir": ".", "auto": True, @@ -100,6 +101,12 @@ class SmartPlaylistPlugin(BeetsPlugin): type="string", help="directory to write the generated playlist files to.", ) + spl_update.parser.add_option( + "--dest-regen", + action="store_true", + dest="dest_regen", + help="regenerate the destination path as 'move' or 'convert' commands would do.", + ) spl_update.parser.add_option( "--relative-to", dest="relative_to", @@ -267,6 +274,7 @@ class SmartPlaylistPlugin(BeetsPlugin): ) tpl = self.config["uri_format"].get() prefix = bytestring_path(self.config["prefix"].as_str()) + dest_regen = self.config["dest_regen"].get() relative_to = self.config["relative_to"].get() if relative_to: relative_to = normpath(relative_to) @@ -318,6 +326,8 @@ class SmartPlaylistPlugin(BeetsPlugin): if tpl: item_uri = tpl.replace("$id", str(item.id)).encode("utf-8") else: + if dest_regen is True: + item_uri = item.destination() if relative_to: item_uri = os.path.relpath(item_uri, relative_to) if self.config["forward_slash"].get():