Skip to content

Bulk asynchronous downloader for multiple file hosts

write temp table funcs

Jules-WinnfieldXdaee7d6d5b4e
diff --git a/cyberdrop_dl/utils/db/tables/temp_table.py b/cyberdrop_dl/utils/db/tables/temp_table.py
index 1225fe4f1..e11c96e7c 100644
--- a/cyberdrop_dl/utils/db/tables/temp_table.py
+++ b/cyberdrop_dl/utils/db/tables/temp_table.py
@@ -1,3 +1,5 @@
+from typing import List
+
import aiosqlite
from cyberdrop_dl.utils.db.table_definitions import create_temp
@@ -11,3 +13,16 @@ class TempTable:
"""Startup process for the TempTable"""
await self.db_conn.execute(create_temp)
await self.db_conn.commit()
+
+ async def get_temp_names(self) -> List[str]:
+ """Gets the list of temp filenames"""
+ cursor = await self.db_conn.cursor()
+ await cursor.execute("SELECT downloaded_filename FROM downloads_temp;")
+ filenames = await cursor.fetchall()
+ filenames = [list(filename) for filename in filenames]
+ return list(sum(filenames, ()))
+
+ async def sql_insert_temp(self, downloaded_filename: str) -> None:
+ """Inserts a temp filename into the downloads_temp table"""
+ await self.db_conn.execute("""INSERT OR IGNORE INTO downloads_temp VALUES (?)""", (downloaded_filename,))
+ await self.db_conn.commit()