summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authornath@dp7510 <nathdwek@outlook.com>2017-10-29 22:56:57 +0100
committernath@dp7510 <nathdwek@outlook.com>2017-10-29 22:56:57 +0100
commitde7c5afb0a4fc2fa7f5f1d7ba86dd87072e46dc4 (patch)
tree0ab684efef285510459b04a87d45724a17b6baf5
parentf7295deb470ecdba2021179f47f476132c119a1d (diff)
smartplaylist: Change base directory for exported pathssmartplaylist-base-dir
An attempt at solving #2547 Add the config option which, if enabled replaces the beetsdir part of the paths with its value.
-rw-r--r--beetsplug/smartplaylist.py8
1 files changed, 8 insertions, 0 deletions
diff --git a/beetsplug/smartplaylist.py b/beetsplug/smartplaylist.py
index 3c3dd6a84..6678ab068 100644
--- a/beetsplug/smartplaylist.py
+++ b/beetsplug/smartplaylist.py
@@ -37,6 +37,7 @@ class SmartPlaylistPlugin(BeetsPlugin):
super(SmartPlaylistPlugin, self).__init__()
self.config.add({
'relative_to': None,
+ 'target_dir': None,
'playlist_dir': u'.',
'auto': True,
'playlists': []
@@ -174,6 +175,10 @@ class SmartPlaylistPlugin(BeetsPlugin):
if relative_to:
relative_to = normpath(relative_to)
+ target_dir = self.config['target_dir'].get()
+ if target_dir:
+ target_dir = normpath(target_dir)
+ beetsdir = normpath(config['directory'].get())
# Maps playlist filenames to lists of track filenames.
m3us = {}
@@ -198,6 +203,9 @@ class SmartPlaylistPlugin(BeetsPlugin):
item_path = item.path
if relative_to:
item_path = os.path.relpath(item.path, relative_to)
+ elif target_dir:
+ item_path = os.path.relpath(item.path, beetsdir)
+ item_path = os.path.join(target_dir, item_path)
if item_path not in m3us[m3u_name]:
m3us[m3u_name].append(item_path)