Fix deleted playlist videos being re-queued during add

When adding a playlist, deleting a video from the queue causes it to be
re-added on the next loop iteration because queue.exists() returns False
for the deleted key. Track canceled URLs in a set so __add_entry skips
them.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
ddmoney420
2026-03-02 16:17:50 -07:00
parent 1915bdfc46
commit 3587098e80

View File

@@ -527,6 +527,7 @@ class DownloadQueue:
self.semaphore = asyncio.Semaphore(int(self.config.MAX_CONCURRENT_DOWNLOADS))
self.done.load()
self._add_generation = 0
self._canceled_urls = set() # URLs canceled during current playlist add
def cancel_add(self):
self._add_generation += 1
@@ -730,6 +731,9 @@ class DownloadQueue:
elif etype == 'video' or (etype.startswith('url') and 'id' in entry and 'title' in entry):
log.debug('Processing as a video')
key = entry.get('webpage_url') or entry['url']
if key in self._canceled_urls:
log.info(f'Skipping canceled URL: {entry.get("title") or key}')
return {'status': 'ok'}
if not self.queue.exists(key):
dl = DownloadInfo(
entry['id'],
@@ -776,6 +780,7 @@ class DownloadQueue:
)
if already is None:
_add_gen = self._add_generation
self._canceled_urls.clear()
already = set() if already is None else already
if url in already:
log.info('recursion detected, skipping')
@@ -816,6 +821,8 @@ class DownloadQueue:
async def cancel(self, ids):
for id in ids:
# Track URL so playlist add loop won't re-queue it
self._canceled_urls.add(id)
if self.pending.exists(id):
self.pending.delete(id)
await self.notifier.canceled(id)