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 = [] self.playlistURLs = []
def start(self): def start(self):
if isinstance(self.queueItem, QISingle): if not self.queueItem.cancel:
result = self.downloadWrapper(self.queueItem.single) if isinstance(self.queueItem, QISingle):
if result: result = self.downloadWrapper(self.queueItem.single)
self.singleAfterDownload(result) if result:
elif isinstance(self.queueItem, QICollection): self.singleAfterDownload(result)
tracks = [None] * len(self.queueItem.collection) elif isinstance(self.queueItem, QICollection):
with ThreadPoolExecutor(self.settings['queueConcurrency']) as executor: tracks = [None] * len(self.queueItem.collection)
for pos, track in enumerate(self.queueItem.collection, start=0): with ThreadPoolExecutor(self.settings['queueConcurrency']) as executor:
tracks[pos] = executor.submit(self.downloadWrapper, track) for pos, track in enumerate(self.queueItem.collection, start=0):
self.collectionAfterDownload(tracks) tracks[pos] = executor.submit(self.downloadWrapper, track)
self.collectionAfterDownload(tracks)
if self.interface: if self.interface:
if self.queueItem.cancel: if self.queueItem.cancel:
self.interface.send('currentItemCancelled', self.queueItem.uuid) self.interface.send('currentItemCancelled', self.queueItem.uuid)

View File

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