Bulk asynchronous downloader for multiple file hosts
Python asynciobunkrcyberdropdownloaderdropboxfilestergofilegoogle-drivemediafiremegamega-nzonedrivepatreonpawchivepinterestpixeldraintransfer-ittwitchtwittervk
Fix download repeats.
Jules-WinnfieldXbdcc3e0cb5db
diff --git a/cyberdrop_dl/__init__.py b/cyberdrop_dl/__init__.pyindex 09bbcd733..e8c142d2c 100644--- a/cyberdrop_dl/__init__.py+++ b/cyberdrop_dl/__init__.py@@ -1 +1 @@-__version__ = "5.1.13"+__version__ = "5.1.14"diff --git a/cyberdrop_dl/utils/database/table_definitions.py b/cyberdrop_dl/utils/database/table_definitions.pyindex 2818a33de..715488ceb 100644--- a/cyberdrop_dl/utils/database/table_definitions.py+++ b/cyberdrop_dl/utils/database/table_definitions.py@@ -5,7 +5,17 @@ create_history = """CREATE TABLE IF NOT EXISTS media (domain TEXT,download_filename TEXT,original_filename TEXT,completed INTEGER NOT NULL,- PRIMARY KEY (url_path, original_filename)+ PRIMARY KEY (domain, url_path, original_filename)+ );"""++create_fixed_history = """CREATE TABLE IF NOT EXISTS media_copy (domain TEXT,+ url_path TEXT,+ referer TEXT,+ download_path TEXT,+ download_filename TEXT,+ original_filename TEXT,+ completed INTEGER NOT NULL,+ PRIMARY KEY (domain, url_path, original_filename));"""create_temp = """CREATE TABLE IF NOT EXISTS temp (downloaded_filename TEXT);"""diff --git a/cyberdrop_dl/utils/database/tables/history_table.py b/cyberdrop_dl/utils/database/tables/history_table.pyindex c4151dff2..7669fc491 100644--- a/cyberdrop_dl/utils/database/tables/history_table.py+++ b/cyberdrop_dl/utils/database/tables/history_table.py@@ -6,7 +6,7 @@ import aiosqlitefrom typing import TYPE_CHECKING, Iterablefrom yarl import URL-from cyberdrop_dl.utils.database.table_definitions import create_history+from cyberdrop_dl.utils.database.table_definitions import create_history, create_fixed_historyif TYPE_CHECKING:from cyberdrop_dl.utils.dataclasses.url_objects import MediaItem@@ -43,6 +43,7 @@ class HistoryTable:await self.db_conn.execute(create_history)await self.db_conn.commit()await self.fix_bunkr_v4_entries()+ await self.fix_primary_keys()async def check_complete(self, domain: str, url: URL) -> bool:"""Checks whether an individual file has completed given its domain and url path"""@@ -121,3 +122,21 @@ class HistoryTable:async def fix_bunkr_v4_entries(self) -> None:"""Fixes bunkr v4 entries in the database"""await self.db_conn.execute("""UPDATE media SET domain = 'bunkrr' WHERE domain = 'bunkr'""")++ async def fix_primary_keys(self) -> None:+ cursor = await self.db_conn.cursor()+ result = await cursor.execute("""pragma table_info(media)""")+ result = await result.fetchall()+ if result[0][5] == 0:+ print("Fixing primary keys in the database: DO NOT EXIT THE PROGRAM")+ await self.db_conn.execute(create_fixed_history)+ await self.db_conn.commit()++ await self.db_conn.execute("""INSERT INTO media_copy SELECT * FROM media""")+ await self.db_conn.commit()++ await self.db_conn.execute("""DROP TABLE media""")+ await self.db_conn.commit()++ await self.db_conn.execute("""ALTER TABLE media_copy RENAME TO media""")+ await self.db_conn.commit()diff --git a/pyproject.toml b/pyproject.tomlindex 49c5e74dc..5149bc41b 100644--- a/pyproject.toml+++ b/pyproject.toml@@ -1,6 +1,6 @@[tool.poetry]name = "cyberdrop-dl"-version = "5.1.13"+version = "5.1.14"description = "Bulk downloader for multiple file hosts"authors = ["Jules Winnfield <[email protected]>"]readme = "README.md"