From 84f83482e8b4578f1f6ff9a0ab36bff154a16a53 Mon Sep 17 00:00:00 2001 From: Blondel MONDESIR Date: Sat, 19 Oct 2024 16:39:32 -0400 Subject: [PATCH] Revert changes to avoid conflict with #259 --- cps/tasks/download.py | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/cps/tasks/download.py b/cps/tasks/download.py index 425af518ab..d5d28945d8 100644 --- a/cps/tasks/download.py +++ b/cps/tasks/download.py @@ -20,7 +20,6 @@ def __init__(self, task_message, media_url, original_url, current_user_name, she self.message = task_message self.media_url = media_url self.media_url_link = f'{media_url}' - self.media_id = None self.original_url = original_url self.current_user_name = current_user_name self.shelf_id = shelf_id @@ -90,8 +89,7 @@ def run(self, worker_thread): # Database operations with sqlite3.connect(XKLB_DB_FILE) as conn: try: - # requested_file = conn.execute("SELECT path FROM media WHERE webpath = ? AND path NOT LIKE 'http%'", (self.media_url,)).fetchone()[0] - self.media_id, requested_file = conn.execute("SELECT id, path FROM media WHERE webpath = ? AND path NOT LIKE 'http%'", (self.media_url,)).fetchone() + requested_file = conn.execute("SELECT path FROM media WHERE webpath = ? AND path NOT LIKE 'http%'", (self.media_url,)).fetchone()[0] # Abort if there is not a path if not requested_file: @@ -103,16 +101,16 @@ def run(self, worker_thread): else: log.error("%s failed to download: No path or error found in the database (likely the video failed due to unavailable fragments?)", self.media_url) self.message = f"{self.media_url_link} failed to download: No path or error found in the database (likely the video failed due to unavailable fragments?)" - self.media_id = conn.execute("SELECT id FROM media WHERE webpath = ?", (self.media_url,)).fetchone()[0] + media_id = conn.execute("SELECT id FROM media WHERE webpath = ?", (self.media_url,)).fetchone()[0] conn.execute("DELETE FROM media WHERE webpath = ?", (self.media_url,)) - conn.execute("DELETE FROM captions WHERE media_id = ?", (self.media_id,)) + conn.execute("DELETE FROM captions WHERE media_id = ?", (media_id,)) return except sqlite3.Error as db_error: log.error("An error occurred while trying to connect to the database: %s", db_error) self.message = f"{self.media_url_link} failed to download: {db_error}" self.message = self.message + "\n" + f"Almost done..." - response = requests.get(self.original_url, params={"requested_file": requested_file, "current_user_name": self.current_user_name, "shelf_id": self.shelf_id, "media_id": self.media_id}) + response = requests.get(self.original_url, params={"requested_file": requested_file, "current_user_name": self.current_user_name, "shelf_id": self.shelf_id}) if response.status_code == 200: log.info("Successfully sent the requested file to %s", self.original_url) file_downloaded = response.json()["file_downloaded"]