Compare commits
11 Commits
codex/conf
...
codex/fix-
| Author | SHA1 | Date | |
|---|---|---|---|
| 25ad8c05d0 | |||
| b65cb53463 | |||
| 6c13fbbb2f | |||
| 33282ddbcb | |||
| 7795e22744 | |||
| e83f1323cd | |||
| 194b16e09c | |||
| 423e8e28ec | |||
| daeee039fa | |||
| 97a5afbee9 | |||
| a2de578087 |
103
jd-webgui/app.py
103
jd-webgui/app.py
@@ -388,33 +388,14 @@ def fetch_proxy_list(url: str) -> str:
|
||||
req = urllib.request.Request(url)
|
||||
log_connection(f"HTTP GET {url} (no-proxy)")
|
||||
with NO_PROXY_OPENER.open(req, timeout=20) as resp:
|
||||
return resp.read().decode("utf-8", "replace")
|
||||
text = resp.read().decode("utf-8", "replace")
|
||||
if "\n" not in text and re.search(r"\s", text):
|
||||
return re.sub(r"\s+", "\n", text.strip())
|
||||
return text
|
||||
|
||||
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",
|
||||
"",
|
||||
"*.your-server.de",
|
||||
],
|
||||
"type": "BLACKLIST",
|
||||
}
|
||||
entries: List[Dict[str, Any]] = []
|
||||
type_map = {
|
||||
"socks5": "SOCKS5",
|
||||
@@ -449,7 +430,7 @@ def build_jdproxies_payload(text: str) -> Dict[str, Any]:
|
||||
if not proxy_type:
|
||||
continue
|
||||
entries.append({
|
||||
"filter": blacklist_filter,
|
||||
"filter": None,
|
||||
"proxy": {
|
||||
"address": parsed.hostname,
|
||||
"password": None,
|
||||
@@ -611,6 +592,31 @@ def local_paths_from_links(links: List[Dict[str, Any]], pkg_map: Dict[Any, Dict[
|
||||
out.append(p)
|
||||
return out
|
||||
|
||||
def call_raw_jd_api(dev, endpoints: List[str], payloads: List[Dict[str, Any]]) -> bool:
|
||||
method_candidates = ["action", "call", "api", "request"]
|
||||
for method_name in method_candidates:
|
||||
method = getattr(dev, method_name, None)
|
||||
if method is None:
|
||||
continue
|
||||
for endpoint in endpoints:
|
||||
for payload in payloads:
|
||||
try:
|
||||
method(endpoint, payload)
|
||||
return True
|
||||
except TypeError:
|
||||
try:
|
||||
method(endpoint, params=payload)
|
||||
return True
|
||||
except TypeError:
|
||||
try:
|
||||
method(endpoint, data=payload)
|
||||
return True
|
||||
except Exception:
|
||||
continue
|
||||
except Exception:
|
||||
continue
|
||||
return False
|
||||
|
||||
def try_remove_from_jd(dev, links: List[Dict[str, Any]], pkg_map: Dict[Any, Dict[str, Any]]) -> Optional[str]:
|
||||
link_ids = [l.get("uuid") for l in links if l.get("uuid") is not None]
|
||||
pkg_ids = list(pkg_map.keys())
|
||||
@@ -645,6 +651,14 @@ def try_remove_from_jd(dev, links: List[Dict[str, Any]], pkg_map: Dict[Any, Dict
|
||||
except Exception:
|
||||
continue
|
||||
|
||||
endpoint_candidates = [
|
||||
"downloads/removeLinks",
|
||||
"downloadsV2/removeLinks",
|
||||
"downloadcontroller/removeLinks",
|
||||
]
|
||||
if call_raw_jd_api(dev, endpoint_candidates, payloads):
|
||||
return None
|
||||
|
||||
return "JDownloader-API: Paket/Links konnten nicht entfernt werden (Wrapper-Methoden nicht vorhanden)."
|
||||
|
||||
def try_cancel_from_jd(dev, links: List[Dict[str, Any]], pkg_map: Dict[Any, Dict[str, Any]]) -> Optional[str]:
|
||||
@@ -683,6 +697,14 @@ def try_cancel_from_jd(dev, links: List[Dict[str, Any]], pkg_map: Dict[Any, Dict
|
||||
except Exception:
|
||||
continue
|
||||
|
||||
endpoint_candidates = [
|
||||
"downloads/removeLinks",
|
||||
"downloadsV2/removeLinks",
|
||||
"downloadcontroller/removeLinks",
|
||||
]
|
||||
if call_raw_jd_api(dev, endpoint_candidates, payloads):
|
||||
return None
|
||||
|
||||
return "JDownloader-API: Abbrechen fehlgeschlagen (Wrapper-Methoden nicht vorhanden)."
|
||||
|
||||
def cancel_job(dev, jobid: str) -> Optional[str]:
|
||||
@@ -1015,7 +1037,6 @@ def render_proxies_page(
|
||||
message: str = "",
|
||||
socks5_in: str = "",
|
||||
socks4_in: str = "",
|
||||
http_in: str = "",
|
||||
out_text: str = "",
|
||||
export_path: str = "",
|
||||
) -> str:
|
||||
@@ -1045,16 +1066,11 @@ def render_proxies_page(
|
||||
<textarea name="socks4_in" rows="6" style="width:100%; max-width:860px; padding:10px; border:1px solid #ccc; border-radius:8px;">{socks4_in}</textarea>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<label>HTTP (ein Proxy pro Zeile, z. B. IP:PORT)</label><br/>
|
||||
<textarea name="http_in" rows="6" style="width:100%; max-width:860px; padding:10px; border:1px solid #ccc; border-radius:8px;">{http_in}</textarea>
|
||||
</div>
|
||||
|
||||
<button type="submit">In JDownloader-Format umwandeln</button>
|
||||
</form>
|
||||
|
||||
<h2 style="margin-top:18px;">JDownloader Import-Liste</h2>
|
||||
<p class="hint">Format: <code>socks5://IP:PORT</code>, <code>socks4://IP:PORT</code>, <code>http://IP:PORT</code>. Keine Prüfung/Validierung.</p>
|
||||
<p class="hint">Format: <code>socks5://IP:PORT</code>, <code>socks4://IP:PORT</code>. Keine Prüfung/Validierung.</p>
|
||||
|
||||
<div class="row">
|
||||
<textarea id="out" rows="12" readonly style="width:100%; max-width:860px; padding:10px; border:1px solid #ccc; border-radius:8px;">{out_text}</textarea>
|
||||
@@ -1068,7 +1084,6 @@ def render_proxies_page(
|
||||
<form method="post" action="/proxies/save">
|
||||
<textarea name="socks5_in" style="display:none;">{socks5_in}</textarea>
|
||||
<textarea name="socks4_in" style="display:none;">{socks4_in}</textarea>
|
||||
<textarea name="http_in" style="display:none;">{http_in}</textarea>
|
||||
<button type="submit">Liste als JDProxies speichern</button>
|
||||
</form>
|
||||
|
||||
@@ -1138,18 +1153,20 @@ def cancel(jobid: str):
|
||||
@app.get("/proxies", response_class=HTMLResponse)
|
||||
def proxies_get():
|
||||
try:
|
||||
socks5_in = fetch_proxy_list("https://raw.githubusercontent.com/TheSpeedX/SOCKS-List/master/socks5.txt")
|
||||
socks4_in = fetch_proxy_list("https://raw.githubusercontent.com/TheSpeedX/SOCKS-List/master/socks4.txt")
|
||||
socks5_in = fetch_proxy_list(
|
||||
"https://api.proxyscrape.com/v4/free-proxy-list/get?request=displayproxies&protocol=socks5&timeout=10000&country=all&ssl=yes&anonymity=elite&skip=0&limit=2000"
|
||||
)
|
||||
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"
|
||||
)
|
||||
http_in = fetch_proxy_list("https://raw.githubusercontent.com/TheSpeedX/SOCKS-List/master/http.txt")
|
||||
|
||||
s5 = format_proxy_lines(socks5_in, "socks5")
|
||||
s4 = format_proxy_lines(socks4_in, "socks4")
|
||||
hp = format_proxy_lines(http_in, "http")
|
||||
combined = "\n".join([x for x in [s5, s4, hp] if x.strip()])
|
||||
combined = "\n".join([x for x in [s5, s4] if x.strip()])
|
||||
return HTMLResponse(render_proxies_page(
|
||||
socks5_in=socks5_in,
|
||||
socks4_in=socks4_in,
|
||||
http_in=http_in,
|
||||
out_text=combined,
|
||||
export_path=PROXY_EXPORT_PATH,
|
||||
))
|
||||
@@ -1160,18 +1177,15 @@ def proxies_get():
|
||||
def proxies_post(
|
||||
socks5_in: str = Form(""),
|
||||
socks4_in: str = Form(""),
|
||||
http_in: str = Form(""),
|
||||
):
|
||||
try:
|
||||
s5 = format_proxy_lines(socks5_in, "socks5")
|
||||
s4 = format_proxy_lines(socks4_in, "socks4")
|
||||
hp = format_proxy_lines(http_in, "http")
|
||||
|
||||
combined = "\n".join([x for x in [s5, s4, hp] if x.strip()])
|
||||
combined = "\n".join([x for x in [s5, s4] if x.strip()])
|
||||
return HTMLResponse(render_proxies_page(
|
||||
socks5_in=socks5_in,
|
||||
socks4_in=socks4_in,
|
||||
http_in=http_in,
|
||||
out_text=combined,
|
||||
export_path=PROXY_EXPORT_PATH,
|
||||
))
|
||||
@@ -1180,7 +1194,6 @@ def proxies_post(
|
||||
error=str(e),
|
||||
socks5_in=socks5_in,
|
||||
socks4_in=socks4_in,
|
||||
http_in=http_in,
|
||||
out_text="",
|
||||
export_path=PROXY_EXPORT_PATH,
|
||||
), status_code=400)
|
||||
@@ -1189,19 +1202,16 @@ def proxies_post(
|
||||
def proxies_save(
|
||||
socks5_in: str = Form(""),
|
||||
socks4_in: str = Form(""),
|
||||
http_in: str = Form(""),
|
||||
):
|
||||
try:
|
||||
s5 = format_proxy_lines(socks5_in, "socks5")
|
||||
s4 = format_proxy_lines(socks4_in, "socks4")
|
||||
hp = format_proxy_lines(http_in, "http")
|
||||
combined = "\n".join([x for x in [s5, s4, hp] if x.strip()])
|
||||
combined = "\n".join([x for x in [s5, s4] if x.strip()])
|
||||
export_path = save_proxy_export(combined)
|
||||
return HTMLResponse(render_proxies_page(
|
||||
message=f"Proxy-Liste gespeichert: {export_path}",
|
||||
socks5_in=socks5_in,
|
||||
socks4_in=socks4_in,
|
||||
http_in=http_in,
|
||||
out_text=combined,
|
||||
export_path=export_path,
|
||||
))
|
||||
@@ -1210,7 +1220,6 @@ def proxies_save(
|
||||
error=str(e),
|
||||
socks5_in=socks5_in,
|
||||
socks4_in=socks4_in,
|
||||
http_in=http_in,
|
||||
out_text="",
|
||||
export_path=PROXY_EXPORT_PATH,
|
||||
), status_code=400)
|
||||
|
||||
Reference in New Issue
Block a user