Skip to content

Commit 369b28a

Browse files
committed
fix: don't fail on missing playlist configuration
Don't fail but log a warning when the smartplaylist beets plugin is not enabled and the `playlist_dir` configuration option was not specified.
1 parent 6c5a89a commit 369b28a

File tree

3 files changed

+10
-2
lines changed

3 files changed

+10
-2
lines changed

beetsplug/beetstream/__init__.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,10 @@ def func(lib, opts, args):
8080
app.config['never_transcode'] = self.config['never_transcode']
8181
playlist_dir = self.config['playlist_dir']
8282
if not playlist_dir:
83-
playlist_dir = config['smartplaylist']['playlist_dir'].get()
83+
try:
84+
playlist_dir = config['smartplaylist']['playlist_dir'].get()
85+
except:
86+
pass
8487
app.config['playlist_dir'] = playlist_dir
8588

8689
# Enable CORS if required.

beetsplug/beetstream/playlistprovider.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ def _refresh(self):
2020
app.logger.debug(f"Loaded {len(self._playlists)} playlists")
2121

2222
def _load_playlists(self):
23+
if not self.dir:
24+
return
2325
paths = glob.glob(os.path.join(self.dir, "**.m3u8"))
2426
paths += glob.glob(os.path.join(self.dir, "**.m3u"))
2527
paths.sort()

beetsplug/beetstream/playlists.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,5 +49,8 @@ def _song(id):
4949
return map_song(g.lib.get_item(int(id)))
5050

5151
def playlist_provider():
52-
_playlist_provider.dir = app.config['playlist_dir']
52+
if 'playlist_dir' in app.config:
53+
_playlist_provider.dir = app.config['playlist_dir']
54+
if not _playlist_provider.dir:
55+
app.logger.warning('No playlist_dir configured')
5356
return _playlist_provider

0 commit comments

Comments
 (0)