Compare commits
1 Commits
codex/add-
...
codex/add-
| Author | SHA1 | Date | |
|---|---|---|---|
| a0e7ed91c7 |
114
jd-webgui/app.py
114
jd-webgui/app.py
@@ -366,15 +366,94 @@ def fetch_proxy_list(url: str) -> str:
|
||||
with urllib.request.urlopen(req, timeout=20) as resp:
|
||||
return resp.read().decode("utf-8", "replace")
|
||||
|
||||
def save_proxy_export(text: str) -> str:
|
||||
def build_jdproxies_payload(text: str) -> Dict[str, Any]:
|
||||
if not text.strip():
|
||||
raise ValueError("Keine Proxy-Einträge zum Speichern.")
|
||||
blacklist_filter = {
|
||||
"entries": [
|
||||
"# Dies ist ein Kommentar",
|
||||
"// Dies ist auch ein Kommentar",
|
||||
"# Für jdownloader.org auskommentieren",
|
||||
"# jdownloader.org",
|
||||
"# unten für alle Accounts mit der ID 'test *' @ jdownloader.org auskommentieren",
|
||||
"#test@jdownloader.org",
|
||||
"# Kommentar unten für ein Konto mit der ID 'test' @ jdownloader.org",
|
||||
"#test$@jdownloader.org",
|
||||
"# Sie können Muster für Konto-ID und Host verwenden, z. B. accountPattern @ hostPattern",
|
||||
"",
|
||||
"my.jdownloader.org",
|
||||
"",
|
||||
"api.jdownloader.org",
|
||||
"",
|
||||
"*.jdownloader.org",
|
||||
],
|
||||
"type": "BLACKLIST",
|
||||
}
|
||||
entries: List[Dict[str, Any]] = []
|
||||
type_map = {
|
||||
"socks5": "SOCKS5",
|
||||
"socks4": "SOCKS4",
|
||||
"http": "HTTP",
|
||||
}
|
||||
entries.append({
|
||||
"filter": None,
|
||||
"proxy": {
|
||||
"address": None,
|
||||
"password": None,
|
||||
"port": 80,
|
||||
"type": "NONE",
|
||||
"username": None,
|
||||
"connectMethodPrefered": False,
|
||||
"preferNativeImplementation": False,
|
||||
"resolveHostName": False,
|
||||
},
|
||||
"enabled": True,
|
||||
"pac": False,
|
||||
"rangeRequestsSupported": True,
|
||||
"reconnectSupported": True,
|
||||
})
|
||||
for line in text.splitlines():
|
||||
s = line.strip()
|
||||
if not s:
|
||||
continue
|
||||
parsed = urllib.parse.urlparse(s)
|
||||
if not parsed.scheme or not parsed.hostname or parsed.port is None:
|
||||
continue
|
||||
proxy_type = type_map.get(parsed.scheme.lower())
|
||||
if not proxy_type:
|
||||
continue
|
||||
entries.append({
|
||||
"filter": blacklist_filter,
|
||||
"proxy": {
|
||||
"address": parsed.hostname,
|
||||
"password": None,
|
||||
"port": int(parsed.port),
|
||||
"type": proxy_type,
|
||||
"username": None,
|
||||
"connectMethodPrefered": False,
|
||||
"preferNativeImplementation": False,
|
||||
"resolveHostName": False,
|
||||
},
|
||||
"enabled": True,
|
||||
"pac": False,
|
||||
"rangeRequestsSupported": True,
|
||||
"reconnectSupported": False,
|
||||
})
|
||||
if not entries:
|
||||
raise ValueError("Keine gültigen Proxy-Einträge gefunden.")
|
||||
return {"customProxyList": entries}
|
||||
|
||||
def save_proxy_export(text: str) -> str:
|
||||
payload = build_jdproxies_payload(text)
|
||||
export_path = PROXY_EXPORT_PATH
|
||||
export_dir = os.path.dirname(export_path)
|
||||
if export_dir:
|
||||
os.makedirs(export_dir, exist_ok=True)
|
||||
if os.path.exists(export_path):
|
||||
os.remove(export_path)
|
||||
with open(export_path, "w", encoding="utf-8") as handle:
|
||||
handle.write(text.strip() + "\n")
|
||||
handle.write(json.dumps(payload, indent=2))
|
||||
handle.write("\n")
|
||||
return export_path
|
||||
|
||||
def pick_library_target(library_choice: str, filename: str, package_name: str) -> str:
|
||||
@@ -742,7 +821,11 @@ def worker(jobid: str):
|
||||
def favicon():
|
||||
return HTMLResponse(status_code=204)
|
||||
|
||||
def render_page(error: str = "") -> str:
|
||||
@app.get("/jobs", response_class=HTMLResponse)
|
||||
def jobs_get():
|
||||
return HTMLResponse(render_job_rows())
|
||||
|
||||
def render_job_rows() -> str:
|
||||
rows = ""
|
||||
with lock:
|
||||
job_list = list(jobs.values())[::-1]
|
||||
@@ -772,6 +855,13 @@ def render_page(error: str = "") -> str:
|
||||
f"</tr>"
|
||||
)
|
||||
|
||||
if not rows:
|
||||
rows = "<tr><td colspan='5'><em>No jobs yet.</em></td></tr>"
|
||||
return rows
|
||||
|
||||
def render_page(error: str = "") -> str:
|
||||
rows = render_job_rows()
|
||||
|
||||
err_html = f"<p class='error'>{error}</p>" if error else ""
|
||||
auth_note = "aktiv" if _auth_enabled() else "aus"
|
||||
return f"""
|
||||
@@ -781,10 +871,18 @@ def render_page(error: str = "") -> str:
|
||||
<meta charset="utf-8">
|
||||
<title>JD → Jellyfin</title>
|
||||
<script>
|
||||
setInterval(() => {{
|
||||
async function refreshJobs() {{
|
||||
if (document.hidden) return;
|
||||
window.location.reload();
|
||||
}}, 5000);
|
||||
try {{
|
||||
const resp = await fetch('/jobs');
|
||||
if (!resp.ok) return;
|
||||
const html = await resp.text();
|
||||
const tbody = document.getElementById('jobs-body');
|
||||
if (tbody) tbody.innerHTML = html;
|
||||
}} catch (e) {{
|
||||
}}
|
||||
}}
|
||||
setInterval(refreshJobs, 5000);
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
@@ -822,8 +920,8 @@ def render_page(error: str = "") -> str:
|
||||
<thead>
|
||||
<tr><th>JobID</th><th>URL</th><th>Paket</th><th>Ziel</th><th>Status</th></tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{rows if rows else "<tr><td colspan='5'><em>No jobs yet.</em></td></tr>"}
|
||||
<tbody id="jobs-body">
|
||||
{rows}
|
||||
</tbody>
|
||||
</table>
|
||||
</body>
|
||||
|
||||
Reference in New Issue
Block a user