Fix bug when downloading covers, bump version

This commit is contained in:
iamdoubz
2026-03-26 09:34:12 -05:00
parent 8c9c634623
commit 928165467c
+7 -7
View File
@@ -3,6 +3,7 @@ import glob
import logging import logging
import os import os
from pathlib import Path from pathlib import Path
from pathvalidate import sanitize_filename
import random import random
import requests import requests
from selenium import webdriver from selenium import webdriver
@@ -16,7 +17,7 @@ from selenium.webdriver.support import expected_conditions as EC
import sys import sys
import time import time
__version__ = "2026.3.25.0" __version__ = "2026.3.26.0"
# Helper for logging # Helper for logging
def setup_logging(mode="syslog", logfile=None): def setup_logging(mode="syslog", logfile=None):
@@ -122,11 +123,7 @@ def main():
chrome_options.add_experimental_option("prefs", prefs) chrome_options.add_experimental_option("prefs", prefs)
driver = webdriver.Chrome(options=chrome_options) driver = webdriver.Chrome(options=chrome_options)
#driver = webdriver.Chrome(service=Service(r"C:\Tools\Standalone\chromedriver.exe"), options=chrome_options)
#driver = webdriver.Remote(
# command_executor=f"http://127.0.0.1:{chrome_port}",
# options=chrome_options
#)
if headless == True: if headless == True:
# Chrome sometimes blocks downloads in headless mode # Chrome sometimes blocks downloads in headless mode
driver.execute_cdp_cmd( driver.execute_cdp_cmd(
@@ -203,12 +200,14 @@ def main():
response.raise_for_status() response.raise_for_status()
if response.status_code == 200: if response.status_code == 200:
fext = 'avif' fext = 'avif'
ftitle = sanitize_filename(title)
if iform == 2: if iform == 2:
fext = 'webp' fext = 'webp'
save_path = os.path.join(download_dir, f"{title}.{fext}") save_path = os.path.join(f"{download_dir}", f"{ftitle}.{fext}")
with open(save_path, 'wb') as file: with open(save_path, 'wb') as file:
for chunk in response.iter_content(1024): for chunk in response.iter_content(1024):
file.write(chunk) file.write(chunk)
time.sleep(1)
else: else:
logging.warning(f"Could not download box image: {response.status_code} - {response.reason}") logging.warning(f"Could not download box image: {response.status_code} - {response.reason}")
pass pass
@@ -237,6 +236,7 @@ def main():
logging.warning("No large box image found.") logging.warning("No large box image found.")
actions = ActionChains(driver) actions = ActionChains(driver)
actions.move_to_element_with_offset(body_element, random.randint(1, 100), random.randint(1, 100)).click().perform() actions.move_to_element_with_offset(body_element, random.randint(1, 100), random.randint(1, 100)).click().perform()
time.sleep(1)
except Exception as e: except Exception as e:
logging.warning(f"No large box image found! {e}") logging.warning(f"No large box image found! {e}")
except: except: