File tree Expand file tree Collapse file tree 3 files changed +20
-1
lines changed Expand file tree Collapse file tree 3 files changed +20
-1
lines changed Original file line number Diff line number Diff line change 28
28
import os
29
29
import six
30
30
31
+ try :
32
+ from urllib .request import pathname2url
33
+ except ImportError :
34
+ # python2 is a bit different
35
+ from urllib import pathname2url
36
+
31
37
32
38
class SmartPlaylistPlugin (BeetsPlugin ):
33
39
@@ -39,8 +45,11 @@ def __init__(self):
39
45
'auto' : True ,
40
46
'playlists' : [],
41
47
'forward_slash' : False ,
48
+ 'prefix' : u'' ,
49
+ 'urlencode' : False ,
42
50
})
43
51
52
+ self .config ['prefix' ].redact = True # May contain username/password.
44
53
self ._matched_playlists = None
45
54
self ._unmatched_playlists = None
46
55
@@ -201,6 +210,7 @@ def update_playlists(self, lib):
201
210
if item_path not in m3us [m3u_name ]:
202
211
m3us [m3u_name ].append (item_path )
203
212
213
+ prefix = bytestring_path (self .config ['prefix' ].as_str ())
204
214
# Write all of the accumulated track lists to files.
205
215
for m3u in m3us :
206
216
m3u_path = normpath (os .path .join (playlist_dir ,
@@ -210,6 +220,8 @@ def update_playlists(self, lib):
210
220
for path in m3us [m3u ]:
211
221
if self .config ['forward_slash' ].get ():
212
222
path = path_as_posix (path )
213
- f .write (path + b'\n ' )
223
+ if self .config ['urlencode' ]:
224
+ path = bytestring_path (pathname2url (path ))
225
+ f .write (prefix + path + b'\n ' )
214
226
215
227
self ._log .info (u"{0} playlists updated" , len (self ._matched_playlists ))
Original file line number Diff line number Diff line change @@ -2166,6 +2166,9 @@ And many little fixes and improvements:
2166
2166
* When there's a parse error in a query (for example, when you type a
2167
2167
malformed date in a :ref: `date query <datequery >`), beets now stops with an
2168
2168
error instead of silently ignoring the query component.
2169
+ * :doc: `/plugins/smartplaylist `: Stream-friendly smart playlists.
2170
+ The ``splupdate `` command can now also add a URL-encodable prefix to every
2171
+ path in the playlist file.
2169
2172
2170
2173
For developers:
2171
2174
Original file line number Diff line number Diff line change @@ -101,3 +101,7 @@ other configuration options are:
101
101
If you intend to use this plugin to generate playlists for MPD on
102
102
Windows, set this to yes.
103
103
Default: Use system separator.
104
+ - **prefix **: Prepend this string to every path in the playlist file. For
105
+ example, you could use the URL for a server where the music is stored.
106
+ Default: empty string.
107
+ - **urlencoded **: URL-encode all paths. Default: ``no ``.
You can’t perform that action at this time.
0 commit comments