Fix: update buzzheavier link detection logic and improve filename extraction from headers

This commit is contained in:
Vxrtrauter
2026-05-04 19:07:42 +02:00
parent d378ee8258
commit 64ca3c76a2
4 changed files with 23 additions and 4 deletions
+1 -1
View File
@@ -113,7 +113,7 @@ class SteamripScraper:
try: try:
consoleLog(f"Found download link: {best}") consoleLog(f"Found download link: {best}")
if "buzzheavier" in best: if "buzzheavier" or "bzzhr" in best:
link = scrape_buzzheavier(best) link = scrape_buzzheavier(best)
return link return link
elif "gofile" in best: elif "gofile" in best:
+3 -1
View File
@@ -20,12 +20,14 @@ def add_direct_download(url: str, title: str, dl_path: Optional[str] = None, hea
consoleLog(f"Download already active: {title}") consoleLog(f"Download already active: {title}")
return return
filename = ( raw_filename = (
detect_filename_from_headers(url, DirectDownloadHandle.USER_AGENT) detect_filename_from_headers(url, DirectDownloadHandle.USER_AGENT)
or extract_filename_from_url(url) or extract_filename_from_url(url)
or sanitize_filename(title) + ".zip" or sanitize_filename(title) + ".zip"
) )
filename = sanitize_filename(raw_filename)
handle = DirectDownloadHandle(url, filename, dl_path, headers, single_threaded) handle = DirectDownloadHandle(url, filename, dl_path, headers, single_threaded)
with state.downloads_lock: with state.downloads_lock:
state.active_downloads[url] = handle state.active_downloads[url] = handle
+17
View File
@@ -10,6 +10,7 @@ import requests
import hashlib import hashlib
import json import json
import time import time
import sys
import os import os
@@ -231,7 +232,23 @@ class DirectDownloadHandle:
def _preallocate_file(self, total_size: int): def _preallocate_file(self, total_size: int):
if os.path.exists(self._file_path) and os.path.getsize(self._file_path) == total_size: if os.path.exists(self._file_path) and os.path.getsize(self._file_path) == total_size:
return return
with open(self._file_path, "wb") as f: with open(self._file_path, "wb") as f:
if sys.platform == "win32":
import msvcrt
import ctypes
from ctypes.wintypes import DWORD
handle = msvcrt.get_osfhandle(f.fileno())
kernel32 = ctypes.windll.kernel32
bytes_returned = DWORD()
kernel32.DeviceIoControl(
handle, 590020, None, 0, None, 0, ctypes.byref(bytes_returned), None
)
kernel32.SetFilePointerEx(handle, ctypes.c_int64(total_size), None, 0)
kernel32.SetEndOfFile(handle)
else:
f.truncate(total_size) f.truncate(total_size)
def _compute_chunks(self, total_size: int) -> list[ChunkSpec]: def _compute_chunks(self, total_size: int) -> list[ChunkSpec]:
+1 -1
View File
@@ -34,7 +34,7 @@ def detect_filename_from_headers(url: str, user_agent: str) -> Optional[str]:
if "filename=" in cd: if "filename=" in cd:
parts = cd.split("filename=") parts = cd.split("filename=")
if len(parts) > 1: if len(parts) > 1:
fname = parts[-1].strip().strip('"').strip("'") fname = parts[1].split(";")[0].strip().strip('"').strip("'")
if fname: if fname:
return fname return fname
except Exception as e: except Exception as e: