more succinct processing function

This commit is contained in:
aj 2020-04-10 16:51:11 +01:00
parent 7119fa481e
commit e498e97cc0

View File

@ -53,26 +53,19 @@ class PlaylistEngine:
for param in params:
source = next((i for i in self.sources if isinstance(i, param.source_type)), None)
if source:
if source.loaded is False:
source.load()
if isinstance(source, RecommendationSource) and isinstance(param, RecommendationSource.Params):
tracks += source.process(params=param, uris=[i.uri for i in tracks])
else:
tracks += source.process(params=param)
else:
new_source = param.source_type(net=self.net)
new_source.load()
self.sources.append(new_source)
if isinstance(new_source, RecommendationSource) and isinstance(param, RecommendationSource.Params):
tracks += new_source.process(params=param, uris=[i.uri for i in tracks])
else:
tracks += new_source.process(params=param)
if source is None:
source = param.source_type(net=self.net)
self.sources.append(source)
logger.info(f'adding {param.source_type.__name__} source')
if source.loaded is False:
source.load()
if isinstance(source, RecommendationSource) and isinstance(param, RecommendationSource.Params):
tracks += source.process(params=param, uris=[i.uri for i in tracks])
else:
tracks += source.process(params=param)
if processors:
for processor in processors:
tracks = processor.process(tracks)