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,7 +53,11 @@ 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 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()
@ -61,17 +65,6 @@ class PlaylistEngine:
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)
logger.info(f'adding {param.source_type.__name__} source')
if processors:
for processor in processors: