Skip to content

Commit

Permalink
fix: don't fail on missing playlist configuration
Browse files Browse the repository at this point in the history
Don't fail but log a warning when the smartplaylist is not enabled and the `playlist_dir` configuration option was not specified.
  • Loading branch information
mgoltzsche committed Apr 11, 2024
1 parent 6c5a89a commit d09d794
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 2 deletions.
5 changes: 4 additions & 1 deletion beetsplug/beetstream/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,10 @@ def func(lib, opts, args):
app.config['never_transcode'] = self.config['never_transcode']
playlist_dir = self.config['playlist_dir']
if not playlist_dir:
playlist_dir = config['smartplaylist']['playlist_dir'].get()
try:
playlist_dir = config['smartplaylist']['playlist_dir'].get()
except:
pass
app.config['playlist_dir'] = playlist_dir

# Enable CORS if required.
Expand Down
2 changes: 2 additions & 0 deletions beetsplug/beetstream/playlistprovider.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ def _refresh(self):
app.logger.debug(f"Loaded {len(self._playlists)} playlists")

def _load_playlists(self):
if not self.dir:
return
paths = glob.glob(os.path.join(self.dir, "**.m3u8"))
paths += glob.glob(os.path.join(self.dir, "**.m3u"))
paths.sort()
Expand Down
5 changes: 4 additions & 1 deletion beetsplug/beetstream/playlists.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,5 +49,8 @@ def _song(id):
return map_song(g.lib.get_item(int(id)))

def playlist_provider():
_playlist_provider.dir = app.config['playlist_dir']
if 'playlist_dir' in app.config:
_playlist_provider.dir = app.config['playlist_dir']
if not _playlist_provider.dir:
app.logger.warning('No playlist_dir configured')
return _playlist_provider

0 comments on commit d09d794

Please sign in to comment.