Fix duplicate being added to the db.

This commit is contained in:
ArabCoders 2023-11-28 13:55:18 +03:00
parent 215b9e2fdd
commit 6bc50a3bc0
2 changed files with 8 additions and 2 deletions

View file

@ -69,8 +69,12 @@ class DataStore:
return items
def put(self, value: Download) -> None:
_id: str = value.info._id
self.dict[_id] = value
for key in self.dict:
if self.dict[key].info.url == value.info.url:
value.info._id = key
return
self.dict[value.info._id] = value
self._updateStoreItem(self.type, value.info)
def delete(self, key: str) -> None:

View file

@ -2,6 +2,7 @@ import asyncio
from email.utils import formatdate
import logging
import os
import time
import yt_dlp
from sqlite3 import Connection
from src.Config import Config
@ -104,6 +105,7 @@ class DownloadQueue:
ytdlp_cookies=ytdlp_cookies,
ytdlp_config=ytdlp_config,
output_template=output_template if output_template else self.config.output_template,
datetime=formatdate(time.time()),
error=error,
is_live=entry['is_live'] if 'is_live' in entry else None,
)