mirror of
https://github.com/KeksPirates/SoftwareManager.git
synced 2026-08-03 17:39:42 +02:00
Merge branch 'main' of https://github.com/KeksPirates/SoftwareManager
This commit is contained in:
@@ -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:
|
||||||
|
|||||||
@@ -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
|
||||||
|
|||||||
@@ -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]:
|
||||||
|
|||||||
@@ -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:
|
||||||
|
|||||||
Reference in New Issue
Block a user