### Clone and Launch VibraVid Source: https://github.com/astraelabs/vibravid/blob/main/README.md Use these commands to clone the repository, install the required Python dependencies, and start the application via the manual interface. ```bash git clone https://github.com/AstraeLabs/VibraVid.git cd VibraVid pip install -r requirements.txt python manual.py ``` -------------------------------- ### File Editor Initialization and Reset Source: https://github.com/astraelabs/vibravid/blob/main/GUI/searchapp/templates/searchapp/cinema_system.html Loads initial configuration and login data into editors and provides reset functionality. ```javascript function source(id) { return JSON.parse(el(id).textContent); } var original = { config: source("cn-src-config"), login: source("cn-src-login") }; var editor = { config: el("cn-config"), login: el("cn-login") }; editor.config.value = original.config; editor.login.value = original.login; function fileMsg(which) { return el("cn-" + which + "-msg"); } document.querySelectorAll("[data-reset]").forEach(function (b) { b.addEventListener("click", function () { var which = this.dataset.reset; editor[which].value = original[which]; say(fileMsg(which), "Reverted."); }); }); ``` -------------------------------- ### Initialization and API Configuration Source: https://github.com/astraelabs/vibravid/blob/main/GUI/searchapp/templates/searchapp/cinema_system.html Defines the base URLs for server-side endpoints and the CSRF token for secure communication. ```javascript (function () { "use strict"; var URL_SAVE = "{% url 'save_settings' %}"; var URL_RELOAD = "{% url 'reload_config' %}"; var URL_ARR = "{% url 'arr_status' %}"; var URL_ARR_SYNC = "{% url 'arr_trigger_sync' %}"; var URL_UPLOAD = "{% url 'upload_service_zip' %}"; var URL_BINARIES = "{% url 'trigger_binaries_update' %}"; var CSRF = "{{ csrf_token }}"; ``` -------------------------------- ### Check System Binaries Source: https://github.com/astraelabs/vibravid/blob/main/GUI/searchapp/templates/searchapp/cinema_system.html Triggers a check for system binaries and displays the results or errors via a POST request. ```javascript // ── Binaries ────────────────────────────────────────────────────────────── el("cn-binaries").addEventListener("click", function () { var btn = this, msg = el("cn-binaries-msg"); btn.disabled = true; say(msg, "Checking…"); post(URL_BINARIES, null, false) .then(function (data) { if (!data || !data.success) { say(msg, (data && data.message) || "Check failed.", "bad"); return; } var lines = Object.keys(data.results || {}).map(function (tool) { return tool + ": " + data.results[tool].message; }); say(msg, lines.join(" | "), "good"); }) .catch(function (err) { say(msg, "Failed: " + err.message, "bad"); }) .finally(function () { btn.disabled = false; }); }); })(); {% endblock %} ``` -------------------------------- ### Save and Reload Binary Configurations Source: https://github.com/astraelabs/vibravid/blob/main/GUI/searchapp/templates/searchapp/cinema_system.html Handles the saving and reloading of binary configuration files via POST requests, including JSON validation and UI feedback. ```javascript try { JSON.parse(content); } catch (err) { say(msg, "Invalid JSON: " + err.message, "bad"); return; } say(msg, "Saving…"); post(URL_SAVE, JSON.stringify({ file_type: which, content: content }), true) .then(function (data) { if (!data.success) { say(msg, data.error || "Not saved.", "bad"); return; } original[which] = content; if (which === "config") rememberArr(content); say(msg, data.message || "Saved.", "good"); }) .catch(function (err) { say(msg, "Save failed: " + err.message, "bad"); }); }); }); document.querySelectorAll("[data-reload]").forEach(function (b) { b.addEventListener("click", function () { var which = this.dataset.reload; var msg = fileMsg(which); say(msg, "Reloading…"); post(URL_RELOAD, JSON.stringify({ file_type: which }), true) .then(function (data) { say(msg, data.success ? (data.message || "Reloaded.") : (data.error || "Failed."), data.success ? "good" : "bad"); }) .catch(function (err) { say(msg, "Reload failed: " + err.message, "bad"); }); }); }); ``` -------------------------------- ### Custom CLI Provider Arguments Management Source: https://github.com/astraelabs/vibravid/blob/main/GUI/searchapp/templates/searchapp/cinema_system.html Logic for rendering and managing custom CLI arguments per provider, including UI generation and validation of login configurations. ```javascript // ── Opzioni CLI personalizzate per provider ────────────────────────────── var extraArgsState = source("cn-src-extra-args") || {}; var extraArgsMsg = el("cn-extra-args-msg"); var extraArgsList = el("cn-extra-args-list"); function renderExtraArgs() { var keys = Object.keys(extraArgsState).sort(); el("cn-extra-args-count").textContent = keys.length; if (!keys.length) { extraArgsList.innerHTML = '

No custom options configured.

'; return; } extraArgsList.innerHTML = ""; keys.forEach(function (site) { var row = document.createElement("div"); row.className = "cn-ln"; row.style.background = "var(--cn-surf-2)"; row.style.padding = "9px 13px"; var label = document.createElement("span"); label.className = "cn-grow"; var t = document.createElement("span"); t.className = "cn-t"; t.style.fontSize = "14px"; t.textContent = site; var s = document.createElement("span"); s.className = "cn-s"; s.textContent = extraArgsState[site]; label.appendChild(t); label.appendChild(s); var removeBtn = document.createElement("button"); removeBtn.className = "cn-cta is-ghost cn-round"; removeBtn.type = "button"; removeBtn.title = "Remove"; removeBtn.setAttribute("aria-label", "Remove"); removeBtn.dataset.removeExtraArgs = site; removeBtn.textContent = "×"; row.appendChild(label); row.appendChild(removeBtn); extraArgsList.appendChild(row); }); } renderExtraArgs(); function saveExtraArgs() { var full; try { full = JSON.parse(editor.login.value); } catch (err) { say(extraArgsMsg, "login.json is invalid: fix it first.", "bad"); return; } // Per-site "extra_args" key, alongside each site's other login.json fields. // Drop it from sites no longer in extraArgsState, set/update it for the rest. ``` -------------------------------- ### Client-side Download Management Script Source: https://github.com/astraelabs/vibravid/blob/main/GUI/searchapp/templates/searchapp/cinema_download.html JavaScript logic for handling download status updates, poster rendering, and UI tile generation. ```javascript {% block scripts %} (function () { "use strict"; var URL_DOWNLOADS = "{% url 'get_downloads_json' %}?history=20"; var URL_KILL = "{% url 'kill_download' %}"; var URL_POSTERS = "{% url 'resolve_tmdb_posters' %}"; var CSRF = "{{ csrf_token }}"; var esc = CN.esc, titleize = CN.titleize, duotone = CN.duotone, pct = CN.pct; function outcome(d) { var status = String(d.status || "").toLowerCase(); if (status === "completed" || status === "success") { return { label: "Done", badge: "is-done", rule: "var(--cn-go)", note: "" }; } if (status === "cancelled" || String(d.error || "").toLowerCase() === "cancelled") { return { label: "Cancelled", badge: "is-wait", rule: "var(--cn-cool)", note: "stopped" }; } if (status === "timed_out") { return { label: "Timed out", badge: "is-warn", rule: "var(--cn-gold)", note: "no signal" }; } var why = String(d.error || "").split("\n")[0].trim(); if (why.length > 48) why = why.slice(0, 47) + "…"; return { label: "Failed", badge: "is-dead", rule: "var(--cn-hot)", note: why || "failed" }; } function poster(item, opts) { var url = item.poster || posterCache[item.series_name || item.title || item.name]; var art = url ? '' : ""; return '' + '
' + (opts.flag || "") + (opts.ring || "") + art + '
' + '
' + '
' + esc(titleize(opts.posterTitle || item.title || item.name)) + '
' + '
' + esc(opts.posterMeta || item.site) + '
' + '
' + (opts.bar || "") + '
'; } function tile(item, opts) { var key = item.series_name || item.title || item.name; var d = duotone(key); return '
' + poster(item, opts) + (opts.cap ? '' + esc(titleize(opts.cap)) + "" : "") + (opts.sub ? '' + esc(opts.sub) + "" : "") + "
"; } function elapsedText(startTime) { if (!startTime) return ""; var s = Math.max(0, Math.floor(Date.now() / 1000 - startTime)); var h = Math.floor(s / 3600), m = Math.floor((s % 3600) / 60), sec = s % 60; if (h) return h + "h " + String(m).padStart(2, "0") + "m"; if (m) return m + "m " + String(sec).padStart(2, "0") + "s"; return sec + "s"; } function activeRowInner(item, downloadId) { var key = item.series_name || item.title || item.name; var d = duotone(key); var url = item.poster || posterCache[key]; var art = url ? '' : ""; var elapsed = elapsedText(item.start_time); var facts = [item.site, item.quality, elapsed && (elapsed + " elapsed")].filter(Boolean).join(" · "); var tasks = item.tasks || {}; var taskNames = Object.keys(tasks); var streams = taskNames.length > 1 ? taskNames.map(function (k) { var raw = tasks[k].display_label || tasks[k].label || k.replace(/_/g, " "); // Strip only known Rich style tags (color/bold), never bracketed content // like "[DEFAULT]"/"[FORCED]" which is part of the label itself. ``` -------------------------------- ### Download UI Update and Interaction Logic Source: https://github.com/astraelabs/vibravid/blob/main/GUI/searchapp/templates/searchapp/cinema_download.html Handles DOM updates for the hero download section, stop button event listeners, and the main refresh cycle for active, queued, and historical downloads. ```javascript art.style.backgroundImage = ""; art.classList.remove("is-soft"); heroEntry = null; return; } var d = active[0]; heroId = d.id; var p = pct(d.progress); kick.innerHTML = '' + esc(d.status || "Running") + "" + '' + esc(d.site) + (d.is_anime ? " · anime" : "") + ""; document.getElementById("cn-hero-title").innerHTML = esc(titleize(d.title)) + '' + esc(d.quality || d.type || "") + ""; document.getElementById("cn-hero-line").textContent = d.path || ""; document.getElementById("cn-hero-pct").innerHTML = p.toFixed(0) + "%"; document.getElementById("cn-hero-of").textContent = [d.size, d.segments ? "segments " + d.segments : ""].filter(Boolean).join(" · "); document.getElementById("cn-hero-bar").style.width = p + "%"; var facts = []; if (d.speed) facts.push("" + esc(d.speed) + ""); if (d.quality) facts.push("quality " + esc(d.quality) + ""); if (d.language) facts.push("audio " + esc(d.language) + ""); document.getElementById("cn-hero-facts").innerHTML = facts.join(""); heroEntry = d; askBackdrop(d); paintHeroArt(d); prog.hidden = false; stop.hidden = false; } document.getElementById("cn-hero-stop").addEventListener("click", function () { if (!heroId) return; fetch(URL_KILL, { method: "POST", headers: { "Content-Type": "application/json", "X-CSRFToken": CSRF }, body: JSON.stringify({ download_id: heroId }) }).then(refresh).catch(function () { /* il giro successivo riallinea */ }); }); document.getElementById("cn-reel-active").addEventListener("click", function (e) { var btn = e.target.closest("[data-stop]"); if (!btn) return; btn.disabled = true; fetch(URL_KILL, { method: "POST", headers: { "Content-Type": "application/json", "X-CSRFToken": CSRF }, body: JSON.stringify({ download_id: btn.dataset.stop }) }).then(refresh).catch(function () { btn.disabled = false; }); }); function refresh() { return fetch(URL_DOWNLOADS) .then(function (r) { return r.json(); }) .then(function (data) { var active = data.active || []; var queue = data.scheduled || []; var hist = data.history || []; renderHero(active); fill("cn-reel-active", "cn-empty-active", "cn-n-active", active.map(function (d, i) { var p = pct(d.progress); var status = d.status || "Running"; d.pctText = p.toFixed(0); var downloadId = d.id || tileId(d, "a", i); return { id: tileId(d, "a", i), sig: status + "|" + p.toFixed(0) + "|" + (d.speed || "") + "|" + elapsedText(d.start_time), html: function () { return activeRow(d, downloadId); }, patch: function (node) { node.innerHTML = activeRowInner(d, downloadId); if (d.path) node.title = d.path; } }; })); fill("cn-reel-queue", "cn-empty-queue", "cn-n-queue", queue.map(function (d, i) { var place = "#" + (i + 1); return { id: tileId(d, "q", i), sig: place, html: function () { return tile(d, { flag: '' + place + "", ruleColor: "var(--cn-cool)", posterMeta: d.season ? "S" + d.season : d.type, cap: d.title, sub: d.site }); }, // quando la coda avanza cambia solo il numero d'ordine patch: function (node) { setText(node, ".cn-flag", place); } }; })); fill("cn-reel-hist", "cn-empty-hist", "cn-n-hist", hist.slice(0, 20).map(function (d, i) { var e = outcome(d); var sub = e.note ? (d.site ? d.site + " · " + e.note : e.note) : d.site; return { id: tileId(d, "h", i), sig: e.label + "|" + sub, html: function () { return tile(d, { flag: '' + e.label + "", ruleColor: e.rule, posterMeta: d.site, cap: d.title, sub: sub }); }, patch: function (node) { var flag = node.querySelector(".cn-flag"); if (flag) { flag.className = "cn-flag cn-st " + e.badge; flag.textContent = e.label; } setText(node, ".cn-sub", sub); } }; })); upgradePosters(active.concat(queue, hist.slice(0, 20))); }) .catch(function () { /* rete giù: si riprova al giro dopo */ }); } ``` -------------------------------- ### ARR Configuration Management and Synchronization Source: https://github.com/astraelabs/vibravid/blob/main/GUI/searchapp/templates/searchapp/cinema_system.html Functions to merge configuration objects, parse ARR settings, save changes to the server, and monitor the status of connected services like Sonarr and Radarr. ```javascript function merge(base, updates) { var out = {}; Object.keys(isObj(base) ? base : {}).forEach(function (k) { out[k] = base[k]; }); Object.keys(updates || {}).forEach(function (k) { out[k] = (isObj(updates[k]) && isObj(out[k])) ? merge(out[k], updates[k]) : updates[k]; }); return out; } function rememberArr(text) { try { var parsed = JSON.parse(text); arrOriginal = JSON.parse(JSON.stringify(parsed.ARR || {})); fillArr(arrOriginal); } catch (err) { say(arrMsg, "config.json is not readable: fix it in its tab.", "bad"); } } rememberArr(original.config); el("cn-arr-reset").addEventListener("click", function () { fillArr(arrOriginal); say(arrMsg, "Reverted."); }); el("cn-arr-save").addEventListener("click", function () { var full; try { full = JSON.parse(editor.config.value); } catch (err) { say(arrMsg, "config.json is invalid: fix it first.", "bad"); return; } full.ARR = merge(full.ARR, readArr()); var content = JSON.stringify(full, null, 4); say(arrMsg, "Saving…"); post(URL_SAVE, JSON.stringify({ file_type: "config", content: content }), true) .then(function (data) { if (!data.success) { say(arrMsg, data.error || "Not saved.", "bad"); return; } editor.config.value = content; original.config = content; arrOriginal = JSON.parse(JSON.stringify(full.ARR)); say(arrMsg, "ARR settings saved.", "good"); }) .catch(function (err) { say(arrMsg, "Save failed: " + err.message, "bad"); }); }); function arrStatus() { fetch(URL_ARR) .then(function (r) { return r.json(); }) .then(function (data) { var dot = el("cn-arr-dot"); dot.classList.toggle("is-idle", !data.enabled); if (!data.enabled) { el("cn-arr-state").textContent = "disabled"; return; } var on = []; if (data.polling_enabled) on.push("polling"); if (data.webhook_enabled) on.push("Seerr"); if (data.sonarr_webhook_enabled) on.push("Sonarr"); if (data.radarr_webhook_enabled) on.push("Radarr"); var s = data.stats || {}; el("cn-arr-state").textContent = (on.length ? on.join(" + ") : "active") + " · " + (s.pending || 0) + " pending, " + (s.downloading || 0) + " downloading, " + (s.completed || 0) + " done, " + (s.failed || 0) + " failed"; ["seerr", "sonarr", "radarr"].forEach(function (src) { var payload = data["last_" + src + "_test_payload"]; if (payload) el("cn-arr-test-" + src).textContent = JSON.stringify(payload, null, 2); }); }) .catch(function () { el("cn-arr-state").textContent = "status unreadable"; }); } arrStatus(); el("cn-arr-sync").addEventListener("click", function () { var btn = this; btn.disabled = true; post(URL_ARR_SYNC, null, false) .then(function () { say(arrMsg, "Sync started.", "good"); }) .catch(function (err) { say(arrMsg, "Not started: " + err.message, "bad"); }) .finally(function () { setTimeout(function () { btn.disabled = false; arrStatus(); }, 3000); }); }); ``` -------------------------------- ### Manage Extra Arguments Configuration Source: https://github.com/astraelabs/vibravid/blob/main/GUI/searchapp/templates/searchapp/cinema_system.html Handles the serialization and saving of extra arguments for providers, including adding new entries and removing existing ones from the state. ```javascript Object.keys(full).forEach(function (site) { if (isObj(full[site]) && "extra_args" in full[site] && !(site in extraArgsState)) { delete full[site].extra_args; } }); Object.keys(extraArgsState).forEach(function (site) { full[site] = full[site] || {}; full[site].extra_args = extraArgsState[site]; }); var content = JSON.stringify(full, null, 4); say(extraArgsMsg, "Saving…"); post(URL_SAVE, JSON.stringify({ file_type: "login", content: content }), true) .then(function (data) { if (!data.success) { say(extraArgsMsg, data.error || "Not saved.", "bad"); return; } editor.login.value = content; original.login = content; say(extraArgsMsg, "Saved.", "good"); }) .catch(function (err) { say(extraArgsMsg, "Save failed: " + err.message, "bad"); }); } el("cn-extra-args-add").addEventListener("click", function () { var siteSel = el("cn-extra-args-site"); var valInput = el("cn-extra-args-value"); var site = siteSel.value; var val = valInput.value.trim(); if (!site || !val) { say(extraArgsMsg, "Pick a provider and enter options.", "bad"); return; } extraArgsState[site] = val; renderExtraArgs(); valInput.value = ""; saveExtraArgs(); }); extraArgsList.addEventListener("click", function (e) { var b = e.target.closest("[data-remove-extra-args]"); if (!b) return; delete extraArgsState[b.dataset.removeExtraArgs]; renderExtraArgs(); saveExtraArgs(); }); ``` -------------------------------- ### TMDB Metadata and Poster Loading Source: https://github.com/astraelabs/vibravid/blob/main/GUI/searchapp/templates/searchapp/cinema_series.html Asynchronously fetches and applies episode metadata and posters when TMDB integration is enabled. ```javascript var SERIES = { name: "{{ series.name|escapejs }}", slug: "{{ series.slug|default:''|escapejs }}", year: "{{ series.year|default:''|escapejs }}", tmdb_id: "{{ series.tmdb_id|default:''|escapejs }}", site: "{{ series.source_alias|escapejs }}", poster: "{{ series.poster|default:''|escapejs }}" }; function art(label, url) { var box = label.querySelector(".cn-ep-art"); if (!box || box.querySelector("img")) return; var img = new Image(); img.loading = "lazy"; img.decoding = "async"; img.alt = ""; img.onerror = function () { img.remove(); }; img.src = url; box.insertBefore(img, box.firstChild); } function applyEpisodeInfo(label, meta) { if (!meta) return; if (meta.name) { var nameEl = label.querySelector(".cn-ep-name"); if (!nameEl) { nameEl = document.createElement("span"); nameEl.className = "cn-ep-name"; label.querySelector(".cn-ep-desc").insertAdjacentElement("beforebegin", nameEl); } nameEl.textContent = meta.name; } var descEl = label.querySelector(".cn-ep-desc"); if (meta.overview && descEl) { descEl.textContent = meta.overview; descEl.hidden = false; } } function loadSeason(section) { var labels = Array.prototype.slice.call(section.querySelectorAll(".cn-ep[data-noart]")); if (!labels.length) return; fetch(URL_POSTERS, { method: "POST", headers: { "Content-Type": "application/json", "X-CSRFToken": CSRF }, body: JSON.stringify({ items: labels.map(function (l) { return { index: l.dataset.season + "x" + l.dataset.episode, name: SERIES.name, slug: SERIES.slug || null, year: SERIES.year || null, tmdb_id: SERIES.tmdb_id || null, site: SERIES.site, season: l.dataset.season, episode: l.dataset.episode }; }) }) }) .then(function (r) { return r.ok ? r.json() : null; }) .then(function (data) { var found = (data && data.posters) || {}; var info = (data && data.episode_info) || {}; labels.forEach(function (l) { var key = l.dataset.season + "x" + l.dataset.episode; var url = found[key] || SERIES.poster; if (url) art(l, url); applyEpisodeInfo(l, info[key]); }); }) .catch(function () { if (SERIES.poster) labels.forEach(function (l) { art(l, SERIES.poster); }); }); } var loadedSeasons = {}; function loadSeasonByNumber(number) { if (loadedSeasons[number]) return; var panel = document.querySelector('.cn-spanel[data-season="' + number + '"]'); if (!panel) return; loadedSeasons[number] = true; loadSeason(panel); } var firstTab = document.querySelector(".cn-stab.is-active") || document.querySelector(".cn-stab"); if (firstTab) loadSeasonByNumber(firstTab.dataset.season); ``` -------------------------------- ### Cinema Results Client-Side Logic Source: https://github.com/astraelabs/vibravid/blob/main/GUI/searchapp/templates/searchapp/cinema_results.html Initializes the results grid, applies dynamic duotone styling to tiles, manages category filtering, and handles tile interaction. If TMDB is available, it performs an asynchronous fetch to resolve and inject movie posters. ```javascript (function () { "use strict"; var grid = document.getElementById("cn-results"); if (!grid) return; var URL_POSTERS = "{% url 'resolve_tmdb_posters' %}"; var CSRF = "{{ csrf_token }}"; var tiles = Array.prototype.slice.call(grid.querySelectorAll(".cn-tile")); function duotone(text) { var h = 0, s = String(text || "?"); for (var i = 0; i < s.length; i++) h += s.charCodeAt(i); h = h % 360; return ["hsl(" + h + " 34% 26%)", "hsl(" + h + " 40% 10%)"]; } tiles.forEach(function (t) { var d = duotone(t.getAttribute("data-key")); t.style.setProperty("--cn-p1", d[0]); t.style.setProperty("--cn-p2", d[1]); }); var kinds = document.getElementById("cn-kinds"); var present = {}; tiles.forEach(function (t) { present[t.dataset.kind] = true; }); kinds.querySelectorAll("button[data-kind]").forEach(function (b) { if (b.dataset.kind) b.hidden = !present[b.dataset.kind]; }); kinds.addEventListener("click", function (e) { var b = e.target.closest("button[data-kind]"); if (!b) return; kinds.querySelectorAll("button").forEach(function (x) { x.setAttribute("aria-pressed", String(x === b)); }); var want = b.dataset.kind, shown = 0; tiles.forEach(function (t) { var show = !want || t.dataset.kind === want; t.hidden = !show; if (show) shown++; }); document.getElementById("cn-count").textContent = shown; document.getElementById("cn-nokind").hidden = shown > 0; }); function activate(tile) { if (tile.dataset.detail) { window.location.href = tile.dataset.detail; return; } var form = tile.dataset.fire && document.getElementById(tile.dataset.fire); if (!form) return; tile.classList.add("is-firing"); form.submit(); } grid.addEventListener("click", function (e) { if (e.target.closest("button, a, form, select, label")) return; var tile = e.target.closest(".cn-tile"); if (tile) activate(tile); }); grid.addEventListener("keydown", function (e) { if (e.key !== "Enter" || e.target.closest("button, a, select")) return; var tile = e.target.closest(".cn-tile"); if (tile) { e.preventDefault(); activate(tile); } }); {% if tmdb_available %} fetch(URL_POSTERS, { method: "POST", headers: { "Content-Type": "application/json", "X-CSRFToken": CSRF }, body: JSON.stringify({ items: tiles.map(function (t) { return { index: t.dataset.index, name: t.dataset.name, year: t.dataset.year || null, is_movie: t.dataset.isMovie === "true", site: t.dataset.site || null, slug: t.dataset.slug || null, tmdb_id: t.dataset.tmdbId || null }; }) }) }) .then(function (r) { return r.ok ? r.json() : null; }) .then(function (data) { if (!data || !data.posters) return; tiles.forEach(function (t) { var url = data.posters[t.dataset.index]; if (!url) return; var img = document.getElementById("cn-poster-" + t.dataset.index); if (img) { img.src = url; return; } var box = t.querySelector(".cn-poster"); var fresh = new Image(); fresh.id = "cn-poster-" + t.dataset.index; fresh.loading = "lazy"; fresh.decoding = "async"; fresh.alt = ""; fresh.onerror = function () { fresh.remove(); }; fresh.src = url; box.insertBefore(fresh, box.querySelector(".cn-poster-fill")); }); }) .catch(function () { /* restano le locandine dei siti */ }); {% endif %} })(); ``` -------------------------------- ### Hero Art Management Source: https://github.com/astraelabs/vibravid/blob/main/GUI/searchapp/templates/searchapp/cinema_download.html Logic for fetching backdrop images and updating the hero section artwork based on the active media item. ```javascript var heroId = null; var heroEntry = null; function artKey(d) { return d.series_name || d.title; } var backdropCache = {}; var backdropAsked = {}; function askBackdrop(d) { var key = artKey(d); if (!key || backdropAsked[key]) return; backdropAsked[key] = true; fetch(URL_POSTERS, { method: "POST", headers: { "Content-Type": "application/json", "X-CSRFToken": CSRF }, body: JSON.stringify({ items: [{ index: key, name: key, site: d.site, backdrop: true, is_movie: String(d.type || "").toLowerCase() === "movie" }] }) }) .then(function (r) { return r.json(); }) .then(function (data) { var url = (data.posters || {})[key]; if (!url) return; backdropCache[key] = url; if (heroEntry) paintHeroArt(heroEntry); }) .catch(function () { /* niente backdrop: resta la locandina sfocata */ }); } var wideCache = {}; function paintHeroArt(d) { var art = document.getElementById("cn-hero-art"); var tone = duotone(d.title); var back = backdropCache[artKey(d)]; var url = back || d.poster || ""; art.style.backgroundImage = url ? 'url("' + url + '")' : ""; art.style.setProperty("--cn-h1", tone[0]); art.style.setProperty("--cn-h2", tone[1]); if (!url || back) { art.classList.remove("is-soft"); return; } if (url in wideCache) { art.classList.toggle("is-soft", !wideCache[url]); return; } art.classList.add("is-soft"); var probe = new Image(); probe.onload = function () { wideCache[url] = probe.naturalWidth >= probe.naturalHeight * 1.3; if ((backdropCache[artKey(d)] || d.poster || "") === url) { art.classList.toggle("is-soft", !wideCache[url]); } }; probe.src = url; } function renderHero(active) { var prog = document.getElementById("cn-hero-prog"); var stop = document.getElementById("cn-hero-stop"); var kick = document.getElementById("cn-hero-kicker"); var art = document.getElementById("cn-hero-art"); if (!active.length) { heroId = null; document.getElementById("cn-hero-title").innerHTML = 'Nothing runningQueue is empty'; document.getElementById("cn-hero-line").textContent = "When a download starts you'll find it here, with real-time progress."; kick.innerHTML = 'Idle'; prog.hidden = true; stop.hidden = true; ``` -------------------------------- ### Download Row Rendering and DOM Patching Source: https://github.com/astraelabs/vibravid/blob/main/GUI/searchapp/templates/searchapp/cinema_download.html Functions to generate HTML for active download rows and synchronize the DOM with the current state of downloads. ```javascript var name = raw .replace(/\\[\/?(?:bold\s+)?(?:yellow|white|blue|cyan|red|green|magenta|dim)\]/gi, "") .replace(/\\\\[/g, "[") .trim() || k.replace(/\_/g, " "); return esc(name) + " " + (tasks[k].progress || 0).toFixed(0) + "%"; }).join(" · ") : ""; return '' + art + '' + esc(titleize(key).slice(0, 1).toUpperCase()) + '' + '' + '' + '' + esc(titleize(item.title || key)) + '' + '' + esc(facts) + '' + (item.path ? '' + esc(item.path) + '' : "") + '' + (streams ? '' + streams + '' : "") + '' + '' + (item.size ? esc(item.size) + ' · ' : '') + esc(item.speed || '') + ' · ' + item.pctText + '%' + ''; } function activeRow(item, downloadId) { return '
' + activeRowInner(item, downloadId) + '
'; } function reelPatch(reel, rows) { var existing = {}; Array.prototype.forEach.call(reel.children, function (node) { existing[node.dataset.id] = node; }); var wanted = {}; rows.forEach(function (r) { wanted[r.id] = true; }); Object.keys(existing).forEach(function (id) { if (!wanted[id]) existing[id].remove(); }); var prev = null; rows.forEach(function (r) { var node = existing[r.id]; if (!node) { var holder = document.createElement("div"); holder.innerHTML = r.html(); node = holder.firstElementChild; node.dataset.id = r.id; } else if (node.dataset.sig !== r.sig) { r.patch(node); } node.dataset.sig = r.sig; var target = prev ? prev.nextSibling : reel.firstChild; if (node !== target) reel.insertBefore(node, target); prev = node; }); } function fill(reelId, emptyId, countId, rows) { var reel = document.getElementById(reelId); reelPatch(reel, rows); reel.hidden = rows.length === 0; document.getElementById(emptyId).hidden = rows.length > 0; document.getElementById(countId).textContent = rows.length; } function tileId(item, prefix, index) { return prefix + ":" + (item.id || item.title || item.name || index); } // Scorciatoie per i pezzi che una patch aggiorna. function setText(node, selector, text) { var el = node.querySelector(selector); if (el && el.textContent !== text) el.textContent = text; } function setWidth(node, selector, percent) { var el = node.querySelector(selector); if (el) el.style.width = percent + "%"; } ``` -------------------------------- ### Utility Functions for DOM and Fetch Source: https://github.com/astraelabs/vibravid/blob/main/GUI/searchapp/templates/searchapp/cinema_system.html Provides helper functions for element selection, POST requests with JSON support, and status message display. ```javascript function el(id) { return document.getElementById(id); } function post(url, body, json) { var headers = { "X-CSRFToken": CSRF }; if (json) headers["Content-Type"] = "application/json"; return fetch(url, { method: "POST", headers: headers, body: body }) .then(function (r) { return r.json(); }); } function say(node, text, kind) { node.textContent = text || ""; node.style.color = kind === "good" ? "var(--cn-go)" : kind === "bad" ? "var(--cn-hot)" : "var(--cn-mute)"; } ``` -------------------------------- ### ARR Configuration Management Functions Source: https://github.com/astraelabs/vibravid/blob/main/GUI/searchapp/templates/searchapp/cinema_system.html Functions to populate the ARR configuration form from an object and to read the current state of the form back into an object. ```javascript // ── ARR ───────────────────────────────────────────────────────────────── var arrMsg = el("cn-arr-msg"); var arrOriginal = {}; function fillArr(arr) { arr = arr || {}; el("arr-enabled").checked = !!arr.enabled; el("arr-polling").checked = arr.enable_polling !== false; el("arr-webhook").checked = !!arr.enable_seerr_webhook; el("arr-sonarr-webhook").checked = !!arr.enable_sonarr_webhook; el("arr-radarr-webhook").checked = !!arr.enable_radarr_webhook; el("arr-webhook-priority-enabled").checked = arr.webhook_priority_enabled !== false; el("arr-poll-interval").value = arr.polling_interval || 300; el("arr-resync-interval").value = arr.full_resync_interval || 21600; el("arr-max-downloads").value = arr.max_concurrent_downloads || 1; el("arr-native-priority-window").value = arr.native_webhook_priority_window_seconds || 120; el("arr-seerr-fallback-delay").value = arr.seerr_fallback_delay_seconds || 20; el("arr-sonarr-url").value = (arr.sonarr || {}).url || ""; el("arr-sonarr-key").value = (arr.sonarr || {}).api_key || ""; el("arr-radarr-url").value = (arr.radarr || {}).url || ""; el("arr-radarr-key").value = (arr.radarr || {}).api_key || ""; el("arr-webhook-secret").value = (arr.seerr || {}).webhook_secret || ""; el("arr-sonarr-webhook-secret").value = (arr.sonarr_webhook || {}).webhook_secret || ""; el("arr-radarr-webhook-secret").value = (arr.radarr_webhook || {}).webhook_secret || ""; } function readArr() { return { enabled: el("arr-enabled").checked, enable_polling: el("arr-polling").checked, enable_seerr_webhook: el("arr-webhook").checked, enable_sonarr_webhook: el("arr-sonarr-webhook").checked, enable_radarr_webhook: el("arr-radarr-webhook").checked, webhook_priority_enabled: el("arr-webhook-priority-enabled").checked, polling_interval: parseInt(el("arr-poll-interval").value, 10) || 300, full_resync_interval: parseInt(el("arr-resync-interval").value, 10) || 21600, max_concurrent_downloads: parseInt(el("arr-max-downloads").value, 10) || 1, native_webhook_priority_window_seconds: parseInt(el("arr-native-priority-window").value, 10) || 120, seerr_fallback_delay_seconds: parseInt(el("arr-seerr-fallback-delay").value, 10) || 20, sonarr: { url: el("arr-sonarr-url").value.trim(), api_key: el("arr-sonarr-key").value.trim() }, radarr: { url: el("arr-radarr-url").value.trim(), api_key: el("arr-radarr-key").value.trim() }, seerr: { webhook_secret: el("arr-webhook-secret").value.trim() }, sonarr_webhook: { webhook_secret: el("arr-sonarr-webhook-secret").value.trim() }, radarr_webhook: { webhook_secret: el("arr-radarr-webhook-secret").value.trim() } }; } function isObj(v) { return v !== null && typeof v === "object" && !Array.isArray(v); } // Fusione in profondità: il form ARR conosce solo le sue chiavi, e un // assegnamento piatto cancellerebbe tutto quello che c'è dentro ARR e che // il form non mostra. ``` -------------------------------- ### Episode Selection and Form Management Source: https://github.com/astraelabs/vibravid/blob/main/GUI/searchapp/templates/searchapp/cinema_series.html Handles episode checkbox synchronization, bulk selection buttons, and form submission validation. ```javascript nums[i]; } } return out.join(","); } function syncSeason(season) { var chosen = []; document.querySelectorAll('.cn-ep-pick[data-season="' + season + '"]:checked') .forEach(function (c) { chosen.push(c.value); }); el("cn-eps-" + season).value = chosen.length ? compress(chosen) : ""; el("cn-go-" + season).textContent = chosen.length ? "Download " + chosen.length + " episode" + (chosen.length === 1 ? "" : "s") : "Download selected"; } document.querySelectorAll(".cn-ep-pick").forEach(function (c) { c.addEventListener("change", function () { syncSeason(this.dataset.season); }); }); document.querySelectorAll("[data-pick-all], [data-pick-none], [data-pick-missing]").forEach(function (b) { b.addEventListener("click", function () { var d = this.dataset; var season = d.pickAll || d.pickNone || d.pickMissing; document.querySelectorAll('.cn-ep-pick[data-season="' + season + '"]') .forEach(function (c) { if (d.pickMissing !== undefined) { c.checked = !c.closest(".cn-ep").hasAttribute("data-owned"); } else { c.checked = d.pickAll !== undefined; } }); syncSeason(season); }); }); document.querySelectorAll('form[id^="cn-form-"]').forEach(function (form) { form.addEventListener("submit", function (e) { var field = this.querySelector('input[name="selected_episodes"]'); if (field && !field.value.trim()) { e.preventDefault(); alert("Select at least one episode."); } }); }); document.querySelectorAll(".cn-spanel").forEach(function (s) { syncSeason(s.dataset.season); }); refreshTray(); ``` -------------------------------- ### ARR Queue Table Structure Source: https://github.com/astraelabs/vibravid/blob/main/GUI/searchapp/templates/searchapp/cinema_arr.html The HTML table structure used to display media request details including title, status, source, queue keys, and timestamps. ```html | Title | Status | Source | Queue | Dates | | --- | --- | --- | --- | --- | | **{{ item.title }}** {% if item.content_type == "movie" %}Movie{% else %}Series{% endif %} {% if item.year %} · {{ item.year }}{% endif %} {% if item.season_number %} · S{{ item.season_number|stringformat:"02d" }}{% endif %}{% if item.episode_number %}E{{ item.episode_number|stringformat:"02d" }}{% endif %} · {{ item.provider|default:"unknown provider" }} | {{ item.get_status_display }} {% if entry.success == True %}succeeded{% elif entry.success == False %}closed without success{% else %}still open{% endif %} | **{{ item.arr_source }}** {{ item.get_sync_source_display }} ARR {{ item.arr_id }}{% if item.episode_id %} · ep {{ item.episode_id }}{% endif %} | `{{ entry.dedup_key }}` TMDB {{ item.tmdb_id|default:"—" }} · TVDB {{ item.tvdb_id|default:"—" }} | queued {{ entry.enqueued_at|date:"m/d/y H:i" }} started {% if entry.started_at %}{{ entry.started_at|date:"m/d/y H:i" }}{% else %}—{% endif %} closed {% if entry.completed_at %}{{ entry.completed_at|date:"m/d/y H:i" }}{% else %}—{% endif %} | ``` -------------------------------- ### Django Template Structure Source: https://github.com/astraelabs/vibravid/blob/main/GUI/searchapp/templates/searchapp/cinema_download.html The main HTML structure for the cinema download page, including template inheritance and conditional rendering for watchlist items. ```html {% extends "searchapp/cinema_base.html" %} {% block title %}ARROWAR{% endblock %} {# c'è un hero: la barra parte trasparente e si riempie allo scroll #} {% block top_float %} is-float{% endblock %} {% block content %} {% comment %} Reso vuoto e riempito da JS col primo job attivo. Se non gira niente resta lo stato di riposo: non si nasconde, altrimenti la pagina "salta" quando un download parte. {% endcomment %} Idle # Nothing running_Queue is empty_ When a download starts you'll find it here, with real-time progress. 0% Stop [Search something]({% url 'search_page' %}) {# ── FILE ─────────────────────────────────────────────────────────────────── #} ## Now 0 No downloads running. ## Queued 0 Queue is empty. ## From your watchlist {{ watchlist_items|length }} [Manage]({% url 'watchlist' %}) {% if watchlist_items %} {% for item in watchlist_items %} {% if item.is_new %}New{% endif %} {% if item.poster %} ![]({{ item.poster }}) {% endif %} {{ item.name }} {{ item.site }} {{ item.name }} {{ item.site }} {% endfor %} {% else %} No shows being watched. Add one from search. {% endif %} ## Recent results 0 No completed downloads yet. {% endblock %} ``` -------------------------------- ### Tab Navigation Logic Source: https://github.com/astraelabs/vibravid/blob/main/GUI/searchapp/templates/searchapp/cinema_system.html Handles tab switching by updating aria-selected attributes and toggling panel visibility. ```javascript var tabs = el("cn-tabs"); tabs.addEventListener("click", function (e) { var b = e.target.closest("button[data-tab]"); if (!b) return; tabs.querySelectorAll("button").forEach(function (x) { x.setAttribute("aria-selected", String(x === b)); }); document.querySelectorAll(".cn-panel").forEach(function (p) { p.hidden = p.dataset.panel !== b.dataset.tab; }); }); ``` -------------------------------- ### Scroll-based UI Floating Bar Script Source: https://github.com/astraelabs/vibravid/blob/main/GUI/searchapp/templates/searchapp/cinema_base.html JavaScript to handle the 'is-float' class on the top navigation bar, which makes it transparent over the hero section until the user scrolls. ```javascript (function () { var bar = document.getElementById("cn-top"); if (!bar.classList.contains("is-float")) return; var onScroll = function () { bar.classList.toggle("is-float", window.scrollY < 8); }; addEventListener("scroll", onScroll, { passive: true }); onScroll(); })(); ```