mirror of
https://github.com/beetbox/beets.git
synced 2026-01-15 20:51:38 +01:00
Fix optional relative_to
This commit is contained in:
parent
4312fd3914
commit
70240bf4b1
1 changed files with 10 additions and 4 deletions
|
|
@ -2,7 +2,7 @@ from __future__ import print_function
|
|||
|
||||
from beets.plugins import BeetsPlugin
|
||||
from beets import config, ui
|
||||
from beets.util import syspath
|
||||
from beets.util import normpath, syspath
|
||||
import os
|
||||
|
||||
database_changed = False
|
||||
|
|
@ -12,10 +12,16 @@ library = None
|
|||
def update_playlists(lib):
|
||||
playlists = config['smartplaylist']['playlists'].get(list)
|
||||
playlist_dir = config['smartplaylist']['playlist_dir'].get(unicode)
|
||||
relative_to = config['smartplaylist']['relative_to'].get(unicode)
|
||||
relative_to = config['smartplaylist']['relative_to'].get()
|
||||
if relative_to:
|
||||
relative_to = normpath(relative_to)
|
||||
|
||||
for playlist in playlists:
|
||||
items = lib.items(playlist['query'])
|
||||
paths = [os.path.relpath(item.path, relative_to) for item in items]
|
||||
if relative_to:
|
||||
paths = [os.path.relpath(item.path, relative_to) for item in items]
|
||||
else:
|
||||
paths = [item.path for item in items]
|
||||
basename = playlist['name'].encode('utf8')
|
||||
m3u_path = os.path.join(playlist_dir, basename)
|
||||
with open(syspath(m3u_path), 'w') as f:
|
||||
|
|
@ -27,7 +33,7 @@ class SmartPlaylistPlugin(BeetsPlugin):
|
|||
def __init__(self):
|
||||
super(SmartPlaylistPlugin, self).__init__()
|
||||
self.config.add({
|
||||
'mpd_music_dir': u'',
|
||||
'relative_to': None,
|
||||
'playlists': []
|
||||
})
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue