fix: remove invalid fastapi.middleware.base import (ModuleNotFoundError)
This commit is contained in:
@@ -19,7 +19,6 @@ from typing import Any, Dict, List, Optional, Tuple
|
|||||||
|
|
||||||
import paramiko
|
import paramiko
|
||||||
from fastapi import FastAPI, Form, Request
|
from fastapi import FastAPI, Form, Request
|
||||||
from fastapi.middleware.base import BaseHTTPMiddleware
|
|
||||||
from fastapi.responses import HTMLResponse, RedirectResponse
|
from fastapi.responses import HTMLResponse, RedirectResponse
|
||||||
from fastapi.staticfiles import StaticFiles
|
from fastapi.staticfiles import StaticFiles
|
||||||
from myjdapi import Myjdapi
|
from myjdapi import Myjdapi
|
||||||
@@ -243,14 +242,12 @@ def get_device():
|
|||||||
|
|
||||||
wanted = (MYJD_DEVICE or "").strip()
|
wanted = (MYJD_DEVICE or "").strip()
|
||||||
|
|
||||||
# wait up to 30s for device to become ONLINE
|
|
||||||
deadline = time.time() + 30
|
deadline = time.time() + 30
|
||||||
last = None
|
last = None
|
||||||
while time.time() < deadline:
|
while time.time() < deadline:
|
||||||
devs = jd.list_devices() or []
|
devs = jd.list_devices() or []
|
||||||
last = devs
|
last = devs
|
||||||
|
|
||||||
# pick by name (or first)
|
|
||||||
def pick():
|
def pick():
|
||||||
if wanted:
|
if wanted:
|
||||||
for d in devs:
|
for d in devs:
|
||||||
@@ -358,7 +355,6 @@ def is_video_file(path: str) -> bool:
|
|||||||
DEMO_PATTERNS = {"big_buck_bunny", "bigbuckbunny", "big buck bunny", "bbb_sunflower"}
|
DEMO_PATTERNS = {"big_buck_bunny", "bigbuckbunny", "big buck bunny", "bbb_sunflower"}
|
||||||
|
|
||||||
def is_demo_link(name: str) -> bool:
|
def is_demo_link(name: str) -> bool:
|
||||||
"""Detect JDownloader demo/fallback videos (e.g. Big Buck Bunny)."""
|
|
||||||
lower = name.lower().replace("-", "_").replace(".", " ")
|
lower = name.lower().replace("-", "_").replace(".", " ")
|
||||||
return any(p in lower for p in DEMO_PATTERNS)
|
return any(p in lower for p in DEMO_PATTERNS)
|
||||||
|
|
||||||
@@ -401,7 +397,6 @@ def pick_library_target(library_choice: str, filename: str, package_name: str) -
|
|||||||
return JELLYFIN_MOVIES_DIR or JELLYFIN_DEST_DIR
|
return JELLYFIN_MOVIES_DIR or JELLYFIN_DEST_DIR
|
||||||
if library_choice == "series":
|
if library_choice == "series":
|
||||||
return JELLYFIN_SERIES_DIR or JELLYFIN_DEST_DIR
|
return JELLYFIN_SERIES_DIR or JELLYFIN_DEST_DIR
|
||||||
# auto
|
|
||||||
if SERIES_RE.search(filename) or SERIES_RE.search(package_name or ""):
|
if SERIES_RE.search(filename) or SERIES_RE.search(package_name or ""):
|
||||||
return JELLYFIN_SERIES_DIR or JELLYFIN_DEST_DIR
|
return JELLYFIN_SERIES_DIR or JELLYFIN_DEST_DIR
|
||||||
return JELLYFIN_MOVIES_DIR or JELLYFIN_DEST_DIR
|
return JELLYFIN_MOVIES_DIR or JELLYFIN_DEST_DIR
|
||||||
@@ -490,19 +485,10 @@ def call_raw_jd_api(dev, endpoints: List[str], payloads: List[Dict[str, Any]]) -
|
|||||||
def cancel_job(dev, jobid: str) -> str:
|
def cancel_job(dev, jobid: str) -> str:
|
||||||
links, pkg_map = query_links_and_packages(dev, jobid)
|
links, pkg_map = query_links_and_packages(dev, jobid)
|
||||||
link_ids = [l.get("uuid") for l in links if l.get("uuid") is not None]
|
link_ids = [l.get("uuid") for l in links if l.get("uuid") is not None]
|
||||||
pkg_ids = [p for p in pkg_map]
|
pkg_ids = list(pkg_map)
|
||||||
|
|
||||||
msgs = []
|
|
||||||
for ep, pl in [
|
for ep, pl in [
|
||||||
("downloads/remove_links", {"linkIds": link_ids, "packageIds": []}),
|
("downloads/remove_links", {"linkIds": link_ids, "packageIds": []}),
|
||||||
("downloadcontroller/remove_links", {"linkIds": link_ids, "packageIds": []}),
|
("downloadcontroller/remove_links", {"linkIds": link_ids, "packageIds": []}),
|
||||||
]:
|
|
||||||
try:
|
|
||||||
call_raw_jd_api(dev, [ep], [pl])
|
|
||||||
except Exception:
|
|
||||||
pass
|
|
||||||
|
|
||||||
for ep, pl in [
|
|
||||||
("downloads/remove_links", {"linkIds": [], "packageIds": pkg_ids}),
|
("downloads/remove_links", {"linkIds": [], "packageIds": pkg_ids}),
|
||||||
("downloadcontroller/remove_links", {"linkIds": [], "packageIds": pkg_ids}),
|
("downloadcontroller/remove_links", {"linkIds": [], "packageIds": pkg_ids}),
|
||||||
]:
|
]:
|
||||||
@@ -510,8 +496,7 @@ def cancel_job(dev, jobid: str) -> str:
|
|||||||
call_raw_jd_api(dev, [ep], [pl])
|
call_raw_jd_api(dev, [ep], [pl])
|
||||||
except Exception:
|
except Exception:
|
||||||
pass
|
pass
|
||||||
|
return "Download abgebrochen."
|
||||||
return " ".join(msgs) if msgs else "Download abgebrochen."
|
|
||||||
|
|
||||||
def try_remove_from_jd(dev, links: List[Dict[str, Any]], pkg_map: Dict[Any, Dict[str, Any]]) -> str:
|
def try_remove_from_jd(dev, links: List[Dict[str, Any]], pkg_map: Dict[Any, Dict[str, Any]]) -> str:
|
||||||
link_ids = [l.get("uuid") for l in links if l.get("uuid") is not None]
|
link_ids = [l.get("uuid") for l in links if l.get("uuid") is not None]
|
||||||
@@ -790,7 +775,6 @@ def worker(jobid: str):
|
|||||||
if remote_md5.lower() != md5_hex.lower():
|
if remote_md5.lower() != md5_hex.lower():
|
||||||
raise RuntimeError(f"MD5 mismatch for {os.path.basename(f)}: local={md5_hex} remote={remote_md5}")
|
raise RuntimeError(f"MD5 mismatch for {os.path.basename(f)}: local={md5_hex} remote={remote_md5}")
|
||||||
|
|
||||||
# Cleanup local
|
|
||||||
try:
|
try:
|
||||||
os.remove(f)
|
os.remove(f)
|
||||||
except Exception:
|
except Exception:
|
||||||
@@ -853,7 +837,7 @@ def render_jobs_page(job_list: list, log_lines: list) -> str:
|
|||||||
"canceled": "#9e9e9e",
|
"canceled": "#9e9e9e",
|
||||||
"uploading": "#2196f3",
|
"uploading": "#2196f3",
|
||||||
"upload": "#2196f3",
|
"upload": "#2196f3",
|
||||||
"downloading":"#ff9800",
|
"downloading": "#ff9800",
|
||||||
"collecting": "#9c27b0",
|
"collecting": "#9c27b0",
|
||||||
}.get(j.status, "#607d8b")
|
}.get(j.status, "#607d8b")
|
||||||
rows += (
|
rows += (
|
||||||
@@ -913,7 +897,6 @@ def render_jobs_page(job_list: list, log_lines: list) -> str:
|
|||||||
</html>"""
|
</html>"""
|
||||||
|
|
||||||
def render_page(message: str = "", error: str = "") -> str:
|
def render_page(message: str = "", error: str = "") -> str:
|
||||||
video_list = ", ".join(sorted(VIDEO_EXTS))
|
|
||||||
return f"""<!DOCTYPE html>
|
return f"""<!DOCTYPE html>
|
||||||
<html lang='de'>
|
<html lang='de'>
|
||||||
<head>
|
<head>
|
||||||
@@ -1131,7 +1114,6 @@ def proxies_get():
|
|||||||
socks4_in = fetch_proxy_list(
|
socks4_in = fetch_proxy_list(
|
||||||
"https://api.proxyscrape.com/v4/free-proxy-list/get?request=displayproxies&protocol=socks4&timeout=10000&country=all&ssl=yes&anonymity=elite&skip=0&limit=2000"
|
"https://api.proxyscrape.com/v4/free-proxy-list/get?request=displayproxies&protocol=socks4&timeout=10000&country=all&ssl=yes&anonymity=elite&skip=0&limit=2000"
|
||||||
)
|
)
|
||||||
|
|
||||||
s5 = format_proxy_lines(socks5_in, "socks5")
|
s5 = format_proxy_lines(socks5_in, "socks5")
|
||||||
s4 = format_proxy_lines(socks4_in, "socks4")
|
s4 = format_proxy_lines(socks4_in, "socks4")
|
||||||
combined = "\n".join([x for x in [s5, s4] if x.strip()])
|
combined = "\n".join([x for x in [s5, s4] if x.strip()])
|
||||||
@@ -1152,7 +1134,6 @@ def proxies_post(
|
|||||||
try:
|
try:
|
||||||
s5 = format_proxy_lines(socks5_in, "socks5")
|
s5 = format_proxy_lines(socks5_in, "socks5")
|
||||||
s4 = format_proxy_lines(socks4_in, "socks4")
|
s4 = format_proxy_lines(socks4_in, "socks4")
|
||||||
|
|
||||||
combined = "\n".join([x for x in [s5, s4] if x.strip()])
|
combined = "\n".join([x for x in [s5, s4] if x.strip()])
|
||||||
return HTMLResponse(render_proxies_page(
|
return HTMLResponse(render_proxies_page(
|
||||||
socks5_in=socks5_in,
|
socks5_in=socks5_in,
|
||||||
@@ -1177,14 +1158,11 @@ def proxies_save(
|
|||||||
try:
|
try:
|
||||||
s5 = format_proxy_lines(socks5_in, "socks5")
|
s5 = format_proxy_lines(socks5_in, "socks5")
|
||||||
s4 = format_proxy_lines(socks4_in, "socks4")
|
s4 = format_proxy_lines(socks4_in, "socks4")
|
||||||
|
|
||||||
combined = "\n".join([x for x in [s5, s4] if x.strip()])
|
combined = "\n".join([x for x in [s5, s4] if x.strip()])
|
||||||
payload = build_jdproxies_payload(combined)
|
payload = build_jdproxies_payload(combined)
|
||||||
|
|
||||||
os.makedirs(os.path.dirname(PROXY_EXPORT_PATH), exist_ok=True)
|
os.makedirs(os.path.dirname(PROXY_EXPORT_PATH), exist_ok=True)
|
||||||
with open(PROXY_EXPORT_PATH, "w", encoding="utf-8") as fh:
|
with open(PROXY_EXPORT_PATH, "w", encoding="utf-8") as fh:
|
||||||
json.dump(payload, fh, indent=2, ensure_ascii=False)
|
json.dump(payload, fh, indent=2, ensure_ascii=False)
|
||||||
|
|
||||||
return HTMLResponse(render_proxies_page(
|
return HTMLResponse(render_proxies_page(
|
||||||
socks5_in=socks5_in,
|
socks5_in=socks5_in,
|
||||||
socks4_in=socks4_in,
|
socks4_in=socks4_in,
|
||||||
|
|||||||
Reference in New Issue
Block a user