Fixes.
This commit is contained in:
parent
6e05c78664
commit
d533ef3a5a
2 changed files with 15 additions and 5 deletions
|
|
@ -3,7 +3,6 @@ import copy
|
|||
from datetime import datetime, timezone
|
||||
from email.utils import formatdate
|
||||
import json
|
||||
import logging
|
||||
import sqlite3
|
||||
from src.Utils import calcDownloadPath
|
||||
from src.Config import Config
|
||||
|
|
@ -13,7 +12,7 @@ from src.DTO.ItemDTO import ItemDTO
|
|||
|
||||
class DataStore:
|
||||
"""
|
||||
Persistent queue using shelve.
|
||||
Persistent queue.
|
||||
"""
|
||||
type: str = None
|
||||
db_file: str = None
|
||||
|
|
@ -119,7 +118,7 @@ class DataStore:
|
|||
sqlStatement = """
|
||||
INSERT INTO "history" ("id", "type", "url", "data")
|
||||
VALUES (?, ?, ?, ?)
|
||||
ON CONFLICT DO UPDATE SET "type" = ?, "url" = ?, "data" = ?
|
||||
ON CONFLICT DO UPDATE SET "type" = ?, "url" = ?, "data" = ?, created_at = ?
|
||||
"""
|
||||
|
||||
stored = copy.deepcopy(item)
|
||||
|
|
@ -139,6 +138,7 @@ class DataStore:
|
|||
type,
|
||||
stored.url,
|
||||
stored.json(),
|
||||
datetime.now(timezone.utc).strftime('%Y-%m-%d %H:%M:%S')
|
||||
))
|
||||
|
||||
def _deleteStoreItem(self, key: str) -> None:
|
||||
|
|
|
|||
|
|
@ -95,12 +95,21 @@ class DownloadQueue:
|
|||
return {'status': 'ok'}
|
||||
elif (etype == 'video' or etype.startswith('url')) and 'id' in entry and 'title' in entry:
|
||||
|
||||
logging.debug(
|
||||
f"entry: {entry.get('id', None)} - {entry.get('webpage_url', None)} - {entry.get('url', None) }")
|
||||
|
||||
if self.done.exists(key=entry['id'], url=entry.get('webpage_url') or entry['url']):
|
||||
item = self.done.get(key=entry['id'], url=entry.get(
|
||||
'webpage_url') or entry['url'])
|
||||
self.clear([item.info._id])
|
||||
|
||||
logging.debug(
|
||||
f'Item [{item.info.title}] already downloaded. Removing from history.')
|
||||
|
||||
await self.clear([item.info._id])
|
||||
|
||||
if self.queue.exists(key=entry['id'], url=entry.get('webpage_url') or entry['url']):
|
||||
logging.info(
|
||||
f'Item [{item.info.title}] already in download queue')
|
||||
return {'status': 'error', 'msg': 'Link already queued for downloading.'}
|
||||
|
||||
dl = ItemDTO(
|
||||
|
|
@ -265,7 +274,8 @@ class DownloadQueue:
|
|||
self.event.clear()
|
||||
|
||||
id, entry = self.queue.next()
|
||||
log.info(f'downloading {id=} - {entry.info.title}')
|
||||
log.info(
|
||||
f'downloading {id=} - {entry.info.title=} - {entry.info.url=} - {entry.info.folder=}')
|
||||
|
||||
await entry.start(self.notifier)
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue