From 6bc50a3bc0f30ab207dbd7dc47f2485da05fc407 Mon Sep 17 00:00:00 2001 From: ArabCoders Date: Tue, 28 Nov 2023 13:55:18 +0300 Subject: [PATCH] Fix duplicate being added to the db. --- app/src/DataStore.py | 8 ++++++-- app/src/DownloadQueue.py | 2 ++ 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/app/src/DataStore.py b/app/src/DataStore.py index 1a673fbf..8827fa4d 100644 --- a/app/src/DataStore.py +++ b/app/src/DataStore.py @@ -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: diff --git a/app/src/DownloadQueue.py b/app/src/DownloadQueue.py index 42949b5f..a2b3070d 100644 --- a/app/src/DownloadQueue.py +++ b/app/src/DownloadQueue.py @@ -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, )