phase 2 rework
This commit is contained in:
1 parent
20054198f3
commit
b397ea9256
44 files changed
+5528
-1377
No files matched your search
@@ -0,0 +1,38 @@
|
||||
<%
|
||||
const live = typeof activity === 'object' && activity ? activity : { workers: [], unassigned: [], available: false };
|
||||
const paused = typeof global === 'object' && global?.captcha_blocked === true;
|
||||
const currentWorkers = Array.isArray(live.workers) ? live.workers : [];
|
||||
const unknownJobs = Array.isArray(live.unassigned) ? live.unassigned : [];
|
||||
const liveSource = value => typeof value === 'string' && /^https:\/\/proxer\.me\/watch\/[1-9]\d*\/[1-9]\d*\/(engsub|engdub|gersub|gerdub)$/.test(value) ? value : '';
|
||||
const liveBytes = value => {
|
||||
if (typeof value !== 'number' || !Number.isFinite(value) || value < 0) return 'Size unavailable';
|
||||
const units = ['B', 'KiB', 'MiB', 'GiB', 'TiB'];
|
||||
const n = value ? Math.min(Math.floor(Math.log(value) / Math.log(1024)), 4) : 0;
|
||||
return (value / 1024 ** n).toFixed(n ? 1 : 0) + ' ' + units[n] + ' on disk';
|
||||
};
|
||||
const workerState = worker => worker.jobs.length ? 'Active' : worker.status !== 'online'
|
||||
? (worker.status === 'errored' ? 'Error' : worker.status === 'stopped' ? 'Stopped' : 'Not ready')
|
||||
: worker.activityUnknown ? 'Activity unknown' : paused ? 'Paused' : 'Idle';
|
||||
%>
|
||||
<section class="activity-section" id="current-downloads" aria-labelledby="activity-title">
|
||||
<div class="section-heading"><div><h2 id="activity-title">Current downloads</h2><p class="field-hint" id="activity-freshness">Current claims by worker · refreshes with this page</p></div><a class="text-link" href="/pm2" id="activity-manage">Manage workers <span aria-hidden="true">↗</span></a></div>
|
||||
<p class="inline-notice notice-warning activity-warning" id="activity-warning"<%- live.available && !live.truncated && !live.workersTruncated ? ' hidden' : '' %>><%= !live.available ? 'Worker status is unavailable. Saved active claims are still shown below.' : 'Showing up to 50 workers and 50 active claims. Open the Active queue for the full list; empty cards may have unlisted activity.' %></p>
|
||||
<ul class="activity-cards" id="activity-workers" aria-label="Current download per worker. Scroll horizontally to view more workers." tabindex="0">
|
||||
<% currentWorkers.forEach(worker => { const state = workerState(worker); %>
|
||||
<li class="worker-card" data-worker-key="<%= worker.key %>">
|
||||
<div class="worker-card-heading"><strong class="worker-card-name"><%= worker.name %></strong><span class="worker-card-state badge <%= state === 'Active' ? 'badge-info' : ['Paused', 'Activity unknown'].includes(state) ? 'badge-warning' : state === 'Idle' ? 'badge-success' : 'badge-neutral' %>"><%= state %></span></div>
|
||||
<ul class="worker-card-jobs">
|
||||
<% worker.jobs.forEach(job => { %><%- include('active-job', { job, liveSource, liveBytes }) %><% }) %>
|
||||
</ul>
|
||||
<p class="worker-card-empty"<%- worker.jobs.length ? ' hidden' : '' %>><%= worker.activityUnknown && worker.status === 'online' ? 'No current job could be reliably linked to this worker.' : worker.status !== 'online' ? 'Start the worker to take queued episodes.' : paused ? 'Waiting for verification to clear.' : 'Ready for the next queued episode.' %></p>
|
||||
</li>
|
||||
<% }) %>
|
||||
</ul>
|
||||
<p class="field-hint activity-scroll-hint" id="activity-scroll-hint" hidden>Scroll sideways to view all <%= currentWorkers.length %> workers.</p>
|
||||
<div class="activity-empty" id="activity-empty"<%- currentWorkers.length ? ' hidden' : '' %>><strong><%= live.available ? 'No managed workers yet' : 'Worker inventory unavailable' %></strong><span><%= live.available ? 'Quick-add a worker to start taking queued episodes.' : 'Check the worker supervisor, then refresh.' %></span><a class="button button-secondary button-small" href="/pm2">Open workers</a></div>
|
||||
<section class="unassigned-activity" id="activity-unassigned" aria-labelledby="unassigned-title"<%- unknownJobs.length ? '' : ' hidden' %>>
|
||||
<div class="section-heading"><div><h3 id="unassigned-title">Active claims without a confirmed worker</h3><p class="field-hint">Older jobs and unavailable or restarted workers can appear here. These claims stay protected.</p></div><a class="text-link" href="/status?state=processing">View active queue</a></div>
|
||||
<ul class="unassigned-jobs" id="activity-unassigned-jobs"><% unknownJobs.forEach(job => { %><%- include('active-job', { job, liveSource, liveBytes, unassigned: true }) %><% }) %></ul>
|
||||
</section>
|
||||
</section>
|
||||
<script src="/activity.js" defer></script>
|
||||
@@ -0,0 +1,7 @@
|
||||
<% const source = liveSource(job.url); const parts = source.split('/'); const unconfirmed = typeof unassigned === 'boolean' && unassigned; %>
|
||||
<li class="active-job" data-active-job-id="<%= job._id %>">
|
||||
<strong class="active-job-name"><%= job.filename %></strong>
|
||||
<a class="active-job-source"<% if (source) { %> href="<%= source %>" target="_blank" rel="noopener noreferrer"<% } %>><%= source ? 'Series ' + parts[4] + ' · Episode ' + parts[5] + ' · ' + parts[6] : 'Source unavailable' %></a>
|
||||
<div class="active-job-metrics"><span class="active-job-size"><%= liveBytes(job.fileSize) %></span><span class="active-job-time" data-started-at="<%= job.started_at || '' %>"><%= job.started_at ? 'Started ' + new Date(job.started_at).toLocaleTimeString('en-GB', { hour: '2-digit', minute: '2-digit' }) : 'Start time unavailable' %></span></div>
|
||||
<p class="active-job-attribution field-hint"<%- unconfirmed ? '' : ' hidden' %>><%= unconfirmed && job.worker ? 'Saved worker: ' + job.worker.name + ' · live assignment unconfirmed' : unconfirmed ? 'Worker was not recorded for this claim.' : '' %></p>
|
||||
</li>
|
||||
@@ -1,5 +1,4 @@
|
||||
<footer class="mt-5 small">Built by DeSqBlocki</footer>
|
||||
</div>
|
||||
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/js/bootstrap.bundle.min.js"></script>
|
||||
</body>
|
||||
</main>
|
||||
<footer class="app-footer"><span>Proxer Downloader</span><span>Built by DeSqBlocki</span></footer>
|
||||
</body>
|
||||
</html>
|
||||
+38
-47
@@ -1,56 +1,47 @@
|
||||
<%
|
||||
const currentPage = typeof activePage === 'string' ? activePage : '';
|
||||
const pageTitle = typeof title === 'string' && title ? title : 'Proxer Downloader';
|
||||
const globalStatus = typeof global === 'object' && global ? global : {};
|
||||
const summaryKnown = typeof counts === 'object' && counts !== null;
|
||||
const downloadsPaused = globalStatus.captcha_blocked === true;
|
||||
const pendingCount = summaryKnown ? (Number(counts.queued) || 0) + (Number(counts.processing) || 0) : null;
|
||||
%>
|
||||
<!doctype html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<title>Proxer-Downloader</title>
|
||||
<link rel="shortcut icon" href="/assets/favicon.ico" type="image/x-icon">
|
||||
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css" rel="stylesheet">
|
||||
<meta name="color-scheme" content="dark">
|
||||
<title><%= pageTitle %><%= pageTitle === 'Proxer Downloader' ? '' : ' · Proxer Downloader' %></title>
|
||||
<link rel="icon" href="/assets/favicon.ico" type="image/x-icon">
|
||||
<link rel="stylesheet" href="/style.css">
|
||||
<script src="/app.js" defer></script>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<!-- CAPTCHA ALERT (initially hidden, will be toggled by JS) -->
|
||||
<div id="captcha-alert" class="alert alert-danger text-center m-0" style="display: <%= (typeof global !== 'undefined' && global.captcha_blocked) ? 'block' : 'none' %>;">
|
||||
<span id="captcha-message"><%= (typeof global !== 'undefined' && global.pause_reason === 'resolution')
|
||||
? '⚠ The video link could not be resolved. Possible causes include CAPTCHA or login verification, an unavailable video, or a source change. Workers are paused for verification.'
|
||||
: '⚠ Authentication or access needs verification on Proxer. Workers are paused until verification is complete.' %></span>
|
||||
<form id="clear-captcha-form" action="/clear-captcha" method="POST" class="d-inline ms-2">
|
||||
<button class="btn btn-danger btn-sm">Resume after verification</button>
|
||||
</form>
|
||||
</div>
|
||||
<div class="container-fluid py-4" style="max-width: 2000px;">
|
||||
<!-- HEADER -->
|
||||
<header class="d-flex justify-content-between align-items-center mb-4">
|
||||
<h1>Proxer-Downloader</h1>
|
||||
<nav class="d-flex gap-2">
|
||||
<a class="btn btn-outline-light" href="/">Home</a>
|
||||
<a class="btn btn-outline-light" href="/status">Status</a>
|
||||
<a class="btn btn-outline-light" href="/pm2">PM2</a>
|
||||
<a class="skip-link" href="#main-content">Skip to content</a>
|
||||
<header class="topbar">
|
||||
<div class="topbar-inner">
|
||||
<a class="brand" href="/" aria-label="Proxer Downloader home">
|
||||
<span class="brand-mark" aria-hidden="true"><svg viewBox="0 0 24 24" fill="none"><path d="M12 4v11m-4-4 4 4 4-4M5 17v3h14v-3" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round"/></svg></span>
|
||||
<span class="brand-text">Proxer<span>Downloader</span></span>
|
||||
</a>
|
||||
<nav class="main-nav" aria-label="Main navigation">
|
||||
<a href="/" class="nav-link<%= currentPage === 'dashboard' ? ' is-active' : '' %>"<%- currentPage === 'dashboard' ? ' aria-current="page"' : '' %>>Dashboard</a>
|
||||
<a href="/download" class="nav-link<%= currentPage === 'download' ? ' is-active' : '' %>"<%- currentPage === 'download' ? ' aria-current="page"' : '' %>>New download</a>
|
||||
<a href="/status" class="nav-link<%= currentPage === 'queue' ? ' is-active' : '' %>"<%- currentPage === 'queue' ? ' aria-current="page"' : '' %>>Queue <span id="nav-queue-count" class="nav-count"<%- pendingCount === null ? ' hidden' : '' %>><%= pendingCount === null ? '' : pendingCount.toLocaleString('en') %></span></a>
|
||||
<a href="/pm2" class="nav-link<%= currentPage === 'workers' ? ' is-active' : '' %>"<%- currentPage === 'workers' ? ' aria-current="page"' : '' %>>Workers</a>
|
||||
</nav>
|
||||
</header>
|
||||
|
||||
<script>
|
||||
async function updateCaptchaAlert() {
|
||||
try {
|
||||
const res = await fetch('/status-data', { cache: 'no-store' });
|
||||
const data = await res.json();
|
||||
const alertEl = document.getElementById('captcha-alert');
|
||||
const messageEl = document.getElementById('captcha-message');
|
||||
|
||||
if (data.global && data.global.captcha_blocked) {
|
||||
messageEl.textContent = data.global.pause_reason === 'resolution'
|
||||
? '⚠ The video link could not be resolved. Possible causes include CAPTCHA or login verification, an unavailable video, or a source change. Workers are paused for verification.'
|
||||
: '⚠ Authentication or access needs verification on Proxer. Workers are paused until verification is complete.';
|
||||
alertEl.style.display = 'block';
|
||||
} else {
|
||||
alertEl.style.display = 'none';
|
||||
}
|
||||
} catch (err) {
|
||||
console.error('Error fetching status-data:', err);
|
||||
}
|
||||
}
|
||||
|
||||
// Poll every 5 seconds
|
||||
setInterval(updateCaptchaAlert, 5000);
|
||||
</script>
|
||||
<span id="global-status" class="connection-status<%= downloadsPaused ? ' is-paused' : summaryKnown ? ' is-ready' : '' %>" role="status" aria-live="polite"><span class="status-dot" aria-hidden="true"></span><span id="global-status-text"><%= downloadsPaused ? 'Downloads paused' : summaryKnown ? 'Queue ready' : 'Checking queue…' %></span></span>
|
||||
</div>
|
||||
</header>
|
||||
<div class="notice-wrap">
|
||||
<section id="captcha-alert" class="verification-notice" aria-label="Downloads need your attention"<%- downloadsPaused ? '' : ' hidden' %>>
|
||||
<div class="notice-copy"><strong>Verification needed</strong><span id="captcha-message"><%= globalStatus.pause_reason === 'resolution'
|
||||
? 'The video link could not be resolved. Possible causes include CAPTCHA or login verification, an unavailable video, or a source change. Workers are paused for verification.'
|
||||
: 'Authentication or access needs verification on Proxer. Workers are paused until verification is complete.' %></span></div>
|
||||
<form id="clear-captcha-form" action="/clear-captcha" method="POST">
|
||||
<button type="submit" class="button button-warning button-small">Resume after verification</button>
|
||||
</form>
|
||||
</section>
|
||||
</div>
|
||||
<main id="main-content" class="app-main" data-page="<%= currentPage %>" tabindex="-1">
|
||||
Reference in new issue
Block a user