From a01b449325c9cbef210f178d6fee2c0e3b675d78 Mon Sep 17 00:00:00 2001 From: aj Date: Mon, 4 May 2020 22:03:06 +0100 Subject: [PATCH] fixed enum error on fmchart playlists --- music/tasks/run_user_playlist.py | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/music/tasks/run_user_playlist.py b/music/tasks/run_user_playlist.py index bda67ff..100f150 100644 --- a/music/tasks/run_user_playlist.py +++ b/music/tasks/run_user_playlist.py @@ -7,11 +7,12 @@ from spotframework.engine.playlistengine import PlaylistEngine, PlaylistSource, from spotframework.engine.processor.shuffle import Shuffle from spotframework.engine.processor.sort import SortReleaseDate from spotframework.engine.processor.deduplicate import DeduplicateByName - from spotframework.model.uri import Uri from spotfm.engine.chart_source import ChartSource +from fmframework.net.network import Network + import music.db.database as database from music.db.part_generator import PartGenerator from music.model.user import User @@ -70,8 +71,16 @@ def run_user_playlist(username, playlist_name): if user.lastfm_username is None: logger.error(f'{username} has no associated last.fm username, chart source skipped') else: + + chart_range = Network.Range.MONTH + try: + chart_range = Network.Range[playlist.chart_range] + except KeyError: + logger.error(f'invalid last.fm chart range found for ' + f'{playlist_name}/{username} {playlist.chart_range}, defaulting to 1 month') + engine.sources.append(ChartSource(spotnet=net, fmnet=database.get_authed_lastfm_network(user))) - params.append(ChartSource.Params(chart_range=playlist.chart_range, limit=playlist.chart_limit)) + params.append(ChartSource.Params(chart_range=chart_range, limit=playlist.chart_limit)) else: # INCLUDE SORT METHOD (no sorting for last.fm chart playlist)