Compare commits
4 Commits
codex/add-
...
codex/conf
| Author | SHA1 | Date | |
|---|---|---|---|
| be4785b04a | |||
| db39f2b55e | |||
| a0e7ed91c7 | |||
| 7443a0e0ca |
@@ -60,6 +60,8 @@ PROXY_EXPORT_PATH = os.environ.get("PROXY_EXPORT_PATH", "/output/jd-proxies.jdpr
|
||||
|
||||
URL_RE = re.compile(r"^https?://", re.I)
|
||||
|
||||
NO_PROXY_OPENER = urllib.request.build_opener(urllib.request.ProxyHandler({}))
|
||||
|
||||
VIDEO_EXTS = {
|
||||
".mkv", ".mp4", ".m4v", ".avi", ".mov", ".wmv", ".flv", ".webm",
|
||||
".ts", ".m2ts", ".mts", ".mpg", ".mpeg", ".vob", ".ogv",
|
||||
@@ -290,7 +292,7 @@ def remote_md5sum(ssh: paramiko.SSHClient, remote_path: str) -> str:
|
||||
# ============================================================
|
||||
def _http_get_json(url: str, headers: Optional[Dict[str, str]] = None) -> Any:
|
||||
req = urllib.request.Request(url, headers=headers or {})
|
||||
with urllib.request.urlopen(req, timeout=20) as r:
|
||||
with NO_PROXY_OPENER.open(req, timeout=20) as r:
|
||||
return json.loads(r.read().decode("utf-8", "replace"))
|
||||
|
||||
def tmdb_search_movie(query: str) -> Optional[Dict[str, Any]]:
|
||||
@@ -363,7 +365,7 @@ def format_proxy_lines(raw: str, scheme: str) -> str:
|
||||
|
||||
def fetch_proxy_list(url: str) -> str:
|
||||
req = urllib.request.Request(url)
|
||||
with urllib.request.urlopen(req, timeout=20) as resp:
|
||||
with NO_PROXY_OPENER.open(req, timeout=20) as resp:
|
||||
return resp.read().decode("utf-8", "replace")
|
||||
|
||||
def build_jdproxies_payload(text: str) -> Dict[str, Any]:
|
||||
@@ -527,7 +529,7 @@ def jellyfin_refresh_library():
|
||||
try:
|
||||
url = JELLYFIN_API_BASE + path
|
||||
req = urllib.request.Request(url, headers=headers, method="POST")
|
||||
with urllib.request.urlopen(req, timeout=20) as r:
|
||||
with NO_PROXY_OPENER.open(req, timeout=20) as r:
|
||||
_ = r.read()
|
||||
return
|
||||
except Exception:
|
||||
@@ -821,7 +823,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]
|
||||
@@ -851,6 +857,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"""
|
||||
@@ -860,10 +873,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>
|
||||
@@ -901,8 +922,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