Compare commits
5 Commits
codex/fetc
...
codex/fix-
| Author | SHA1 | Date | |
|---|---|---|---|
| 25ad8c05d0 | |||
| b65cb53463 | |||
| 6c13fbbb2f | |||
| 33282ddbcb | |||
| 7795e22744 |
@@ -396,29 +396,6 @@ def fetch_proxy_list(url: str) -> str:
|
|||||||
def build_jdproxies_payload(text: str) -> Dict[str, Any]:
|
def build_jdproxies_payload(text: str) -> Dict[str, Any]:
|
||||||
if not text.strip():
|
if not text.strip():
|
||||||
raise ValueError("Keine Proxy-Einträge zum Speichern.")
|
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",
|
|
||||||
"88.99.115.46",
|
|
||||||
],
|
|
||||||
"type": "BLACKLIST",
|
|
||||||
}
|
|
||||||
entries: List[Dict[str, Any]] = []
|
entries: List[Dict[str, Any]] = []
|
||||||
type_map = {
|
type_map = {
|
||||||
"socks5": "SOCKS5",
|
"socks5": "SOCKS5",
|
||||||
@@ -453,7 +430,7 @@ def build_jdproxies_payload(text: str) -> Dict[str, Any]:
|
|||||||
if not proxy_type:
|
if not proxy_type:
|
||||||
continue
|
continue
|
||||||
entries.append({
|
entries.append({
|
||||||
"filter": blacklist_filter,
|
"filter": None,
|
||||||
"proxy": {
|
"proxy": {
|
||||||
"address": parsed.hostname,
|
"address": parsed.hostname,
|
||||||
"password": None,
|
"password": None,
|
||||||
@@ -615,6 +592,31 @@ def local_paths_from_links(links: List[Dict[str, Any]], pkg_map: Dict[Any, Dict[
|
|||||||
out.append(p)
|
out.append(p)
|
||||||
return out
|
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]:
|
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]
|
link_ids = [l.get("uuid") for l in links if l.get("uuid") is not None]
|
||||||
pkg_ids = list(pkg_map.keys())
|
pkg_ids = list(pkg_map.keys())
|
||||||
@@ -649,6 +651,14 @@ def try_remove_from_jd(dev, links: List[Dict[str, Any]], pkg_map: Dict[Any, Dict
|
|||||||
except Exception:
|
except Exception:
|
||||||
continue
|
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)."
|
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]:
|
def try_cancel_from_jd(dev, links: List[Dict[str, Any]], pkg_map: Dict[Any, Dict[str, Any]]) -> Optional[str]:
|
||||||
@@ -687,6 +697,14 @@ def try_cancel_from_jd(dev, links: List[Dict[str, Any]], pkg_map: Dict[Any, Dict
|
|||||||
except Exception:
|
except Exception:
|
||||||
continue
|
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)."
|
return "JDownloader-API: Abbrechen fehlgeschlagen (Wrapper-Methoden nicht vorhanden)."
|
||||||
|
|
||||||
def cancel_job(dev, jobid: str) -> Optional[str]:
|
def cancel_job(dev, jobid: str) -> Optional[str]:
|
||||||
|
|||||||
Reference in New Issue
Block a user