It's now possible to cancel spotify playlist conversion

This commit is contained in:
RemixDev 2020-08-19 17:16:39 +02:00
parent 2a662928f9
commit 00885ae674
2 changed files with 13 additions and 10 deletions

View File

@ -104,16 +104,17 @@ class DownloadJob:
self.playlistURLs = []
def start(self):
if isinstance(self.queueItem, QISingle):
result = self.downloadWrapper(self.queueItem.single)
if result:
self.singleAfterDownload(result)
elif isinstance(self.queueItem, QICollection):
tracks = [None] * len(self.queueItem.collection)
with ThreadPoolExecutor(self.settings['queueConcurrency']) as executor:
for pos, track in enumerate(self.queueItem.collection, start=0):
tracks[pos] = executor.submit(self.downloadWrapper, track)
self.collectionAfterDownload(tracks)
if not self.queueItem.cancel:
if isinstance(self.queueItem, QISingle):
result = self.downloadWrapper(self.queueItem.single)
if result:
self.singleAfterDownload(result)
elif isinstance(self.queueItem, QICollection):
tracks = [None] * len(self.queueItem.collection)
with ThreadPoolExecutor(self.settings['queueConcurrency']) as executor:
for pos, track in enumerate(self.queueItem.collection, start=0):
tracks[pos] = executor.submit(self.downloadWrapper, track)
self.collectionAfterDownload(tracks)
if self.interface:
if self.queueItem.cancel:
self.interface.send('currentItemCancelled', self.queueItem.uuid)

View File

@ -237,6 +237,8 @@ class SpotifyHelper:
interface.send("startConversion", queueItem.uuid)
collection = []
for pos, track in enumerate(queueItem.extra['unconverted'], start=1):
if queueItem.cancel:
return
if str(track['id']) in cache['tracks']:
trackID = cache['tracks'][str(track['id'])]
else: