Compare commits
16 Commits
codex/anal
...
codex/add-
| Author | SHA1 | Date | |
|---|---|---|---|
| f1267a46a1 | |||
| 9baf87cc33 | |||
| d57948af82 | |||
| 93310e3d99 | |||
| 00c72a78d2 | |||
| 2891466635 | |||
| de41769e5f | |||
| f9ba535c56 | |||
| 32f159c03a | |||
| 30329ef72a | |||
| 1f5fa2e31d | |||
| e8dfe28b0b | |||
| 0d4f030f2c | |||
| 812cb08df7 | |||
| 063c22ab86 | |||
| 93fc395ebc |
@@ -26,6 +26,6 @@ services:
|
|||||||
environment:
|
environment:
|
||||||
TZ: Europe/Berlin
|
TZ: Europe/Berlin
|
||||||
volumes:
|
volumes:
|
||||||
- ./data/jd-output:/output:ro
|
- ./data/jd-output:/output:rw
|
||||||
- ./data/md5:/md5:rw
|
- ./data/md5:/md5:rw
|
||||||
- /root/.ssh/id_ed25519:/ssh/id_ed25519:ro
|
- /root/.ssh/id_ed25519:/ssh/id_ed25519:ro
|
||||||
|
|||||||
255
jd-webgui/app.py
255
jd-webgui/app.py
@@ -56,6 +56,7 @@ POLL_SECONDS = float(os.environ.get("POLL_SECONDS", "5"))
|
|||||||
|
|
||||||
# JDownloader writes here inside container
|
# JDownloader writes here inside container
|
||||||
JD_OUTPUT_PATH = "/output"
|
JD_OUTPUT_PATH = "/output"
|
||||||
|
PROXY_EXPORT_PATH = os.environ.get("PROXY_EXPORT_PATH", "/output/jd-proxies.jdproxies")
|
||||||
|
|
||||||
URL_RE = re.compile(r"^https?://", re.I)
|
URL_RE = re.compile(r"^https?://", re.I)
|
||||||
|
|
||||||
@@ -321,6 +322,101 @@ def sanitize_name(name: str) -> str:
|
|||||||
out = "".join("_" if c in bad else c for c in name).strip()
|
out = "".join("_" if c in bad else c for c in name).strip()
|
||||||
return re.sub(r"\s+", " ", out)
|
return re.sub(r"\s+", " ", out)
|
||||||
|
|
||||||
|
def format_proxy_lines(raw: str, scheme: str) -> str:
|
||||||
|
"""
|
||||||
|
Takes raw lines (ip:port or scheme://ip:port) and outputs normalized lines:
|
||||||
|
scheme://ip:port (one per line). Ignores empty lines and comments.
|
||||||
|
"""
|
||||||
|
scheme = scheme.strip().lower()
|
||||||
|
if scheme not in {"socks5", "socks4", "http"}:
|
||||||
|
raise ValueError("Unsupported proxy scheme")
|
||||||
|
|
||||||
|
out = []
|
||||||
|
for line in (raw or "").splitlines():
|
||||||
|
s = line.strip()
|
||||||
|
if not s or s.startswith("#"):
|
||||||
|
continue
|
||||||
|
|
||||||
|
if "://" in s:
|
||||||
|
s = s.split("://", 1)[1].strip()
|
||||||
|
|
||||||
|
if ":" not in s:
|
||||||
|
continue
|
||||||
|
|
||||||
|
host, port = s.rsplit(":", 1)
|
||||||
|
host = host.strip()
|
||||||
|
port = port.strip()
|
||||||
|
|
||||||
|
if not host or not port.isdigit():
|
||||||
|
continue
|
||||||
|
|
||||||
|
out.append(f"{scheme}://{host}:{port}")
|
||||||
|
|
||||||
|
seen = set()
|
||||||
|
dedup = []
|
||||||
|
for x in out:
|
||||||
|
if x not in seen:
|
||||||
|
seen.add(x)
|
||||||
|
dedup.append(x)
|
||||||
|
|
||||||
|
return "\n".join(dedup)
|
||||||
|
|
||||||
|
def fetch_proxy_list(url: str) -> str:
|
||||||
|
req = urllib.request.Request(url)
|
||||||
|
with urllib.request.urlopen(req, timeout=20) as resp:
|
||||||
|
return resp.read().decode("utf-8", "replace")
|
||||||
|
|
||||||
|
def build_jdproxies_payload(text: str) -> Dict[str, Any]:
|
||||||
|
if not text.strip():
|
||||||
|
raise ValueError("Keine Proxy-Einträge zum Speichern.")
|
||||||
|
entries: List[Dict[str, Any]] = []
|
||||||
|
type_map = {
|
||||||
|
"socks5": "SOCKS5",
|
||||||
|
"socks4": "SOCKS4",
|
||||||
|
"http": "HTTP",
|
||||||
|
}
|
||||||
|
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": None,
|
||||||
|
"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)
|
||||||
|
with open(export_path, "w", encoding="utf-8") as handle:
|
||||||
|
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:
|
def pick_library_target(library_choice: str, filename: str, package_name: str) -> str:
|
||||||
if library_choice not in {"movies", "series", "auto"}:
|
if library_choice not in {"movies", "series", "auto"}:
|
||||||
library_choice = "auto"
|
library_choice = "auto"
|
||||||
@@ -733,6 +829,7 @@ def render_page(error: str = "") -> str:
|
|||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<h1>JD → Jellyfin</h1>
|
<h1>JD → Jellyfin</h1>
|
||||||
|
{render_nav("downloads")}
|
||||||
{err_html}
|
{err_html}
|
||||||
|
|
||||||
<form method="post" action="/submit">
|
<form method="post" action="/submit">
|
||||||
@@ -773,6 +870,84 @@ def render_page(error: str = "") -> str:
|
|||||||
</html>
|
</html>
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
def render_nav(active: str) -> str:
|
||||||
|
def link(label: str, href: str, key: str) -> str:
|
||||||
|
style = "font-weight:700;" if active == key else ""
|
||||||
|
return f"<a href='{href}' style='margin-right:14px; {style}'>{label}</a>"
|
||||||
|
return (
|
||||||
|
"<div style='margin: 8px 0 14px 0;'>"
|
||||||
|
+ link("Downloads", "/", "downloads")
|
||||||
|
+ link("Proxies", "/proxies", "proxies")
|
||||||
|
+ "</div>"
|
||||||
|
)
|
||||||
|
|
||||||
|
def render_proxies_page(
|
||||||
|
error: str = "",
|
||||||
|
message: str = "",
|
||||||
|
socks5_in: str = "",
|
||||||
|
socks4_in: str = "",
|
||||||
|
http_in: str = "",
|
||||||
|
out_text: str = "",
|
||||||
|
export_path: str = "",
|
||||||
|
) -> str:
|
||||||
|
err_html = f"<p class='error'>{error}</p>" if error else ""
|
||||||
|
msg_html = f"<p class='success'>{message}</p>" if message else ""
|
||||||
|
return f"""
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<link rel="stylesheet" href="/static/style.css">
|
||||||
|
<meta charset="utf-8">
|
||||||
|
<title>JD → Jellyfin (Proxies)</title>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<h1>JD → Jellyfin</h1>
|
||||||
|
{render_nav("proxies")}
|
||||||
|
{err_html}
|
||||||
|
{msg_html}
|
||||||
|
|
||||||
|
<form method="post" action="/proxies">
|
||||||
|
<div class="row">
|
||||||
|
<label>SOCKS5 (ein Proxy pro Zeile, z. B. IP:PORT)</label><br/>
|
||||||
|
<textarea name="socks5_in" rows="6" style="width:100%; max-width:860px; padding:10px; border:1px solid #ccc; border-radius:8px;">{socks5_in}</textarea>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="row">
|
||||||
|
<label>SOCKS4 (ein Proxy pro Zeile, z. B. IP:PORT)</label><br/>
|
||||||
|
<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>
|
||||||
|
|
||||||
|
<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>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<button type="button" onclick="navigator.clipboard.writeText(document.getElementById('out').value)">Kopieren</button>
|
||||||
|
|
||||||
|
<h2 style="margin-top:18px;">Datei für Connection Manager</h2>
|
||||||
|
<p class="hint">Speichert die Liste als <code>.jdproxies</code> im Container, z. B. zum Import in JDownloader → Verbindungsmanager → Importieren.</p>
|
||||||
|
|
||||||
|
<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>
|
||||||
|
|
||||||
|
<p class="hint">Aktueller Pfad: <code>{export_path or PROXY_EXPORT_PATH}</code></p>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
|
"""
|
||||||
|
|
||||||
@app.get("/", response_class=HTMLResponse)
|
@app.get("/", response_class=HTMLResponse)
|
||||||
def index():
|
def index():
|
||||||
try:
|
try:
|
||||||
@@ -830,3 +1005,83 @@ def cancel(jobid: str):
|
|||||||
job.cancel_requested = True
|
job.cancel_requested = True
|
||||||
job.message = "Abbruch angefordert…"
|
job.message = "Abbruch angefordert…"
|
||||||
return RedirectResponse(url="/", status_code=303)
|
return RedirectResponse(url="/", status_code=303)
|
||||||
|
|
||||||
|
@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")
|
||||||
|
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()])
|
||||||
|
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,
|
||||||
|
))
|
||||||
|
except Exception as e:
|
||||||
|
return HTMLResponse(render_proxies_page(error=str(e)), status_code=502)
|
||||||
|
|
||||||
|
@app.post("/proxies", response_class=HTMLResponse)
|
||||||
|
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()])
|
||||||
|
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,
|
||||||
|
))
|
||||||
|
except Exception as e:
|
||||||
|
return HTMLResponse(render_proxies_page(
|
||||||
|
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)
|
||||||
|
|
||||||
|
@app.post("/proxies/save", response_class=HTMLResponse)
|
||||||
|
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()])
|
||||||
|
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,
|
||||||
|
))
|
||||||
|
except Exception as e:
|
||||||
|
return HTMLResponse(render_proxies_page(
|
||||||
|
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)
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ th { background:#fbfbfb; text-align:left; }
|
|||||||
code { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12px; background:#f2f2f2; padding:2px 4px; border-radius:4px; }
|
code { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12px; background:#f2f2f2; padding:2px 4px; border-radius:4px; }
|
||||||
.hint { color:#555; font-size: 12px; margin-top: 10px; }
|
.hint { color:#555; font-size: 12px; margin-top: 10px; }
|
||||||
.error { color:#b00020; font-weight: 700; }
|
.error { color:#b00020; font-weight: 700; }
|
||||||
|
.success { color:#1b7f3a; font-weight: 700; }
|
||||||
.progress-row { display:flex; align-items:center; gap:8px; margin-top:6px; }
|
.progress-row { display:flex; align-items:center; gap:8px; margin-top:6px; }
|
||||||
.progress-text { font-size:12px; color:#333; min-width:48px; }
|
.progress-text { font-size:12px; color:#333; min-width:48px; }
|
||||||
.inline-form { margin-top:6px; }
|
.inline-form { margin-top:6px; }
|
||||||
|
|||||||
Reference in New Issue
Block a user