Release 0.2.5: harden proxy and streamline metadata fetching
Remove obsolete rule formats, batch SQLite work, preserve artwork source URLs, and coordinate refresh workers with maintenance. Add regression coverage and document backup format changes.
This commit is contained in:
1 parent
7eb62b156e
commit
e36775f1a3
49 files changed
+2126
-1813
No files matched your search
@@ -1,11 +1,4 @@
|
||||
(function () {
|
||||
if (!Element.prototype.replaceChildren) {
|
||||
Element.prototype.replaceChildren = function () {
|
||||
this.textContent = "";
|
||||
for (let index = 0; index < arguments.length; index++) this.appendChild(arguments[index]);
|
||||
};
|
||||
}
|
||||
|
||||
const basePath = () => {
|
||||
const path = window.location.pathname || "";
|
||||
const marker = "/web/";
|
||||
@@ -21,23 +14,13 @@
|
||||
}
|
||||
}
|
||||
|
||||
function headers() {
|
||||
const qs = new URLSearchParams(location.search);
|
||||
const t = token() || qs.get("token") || qs.get("api_key") || "";
|
||||
const h = { "Content-Type": "application/json" };
|
||||
if (t) {
|
||||
h["X-Emby-Token"] = t;
|
||||
h["X-MediaBrowser-Token"] = t;
|
||||
}
|
||||
return h;
|
||||
}
|
||||
|
||||
function authHeaders(contentType) {
|
||||
const qs = new URLSearchParams(location.search);
|
||||
const t = token() || qs.get("token") || qs.get("api_key") || "";
|
||||
const h = {};
|
||||
if (contentType) h["Content-Type"] = contentType;
|
||||
if (t) {
|
||||
h.Authorization = `MediaBrowser Token="${t}"`;
|
||||
h["X-Emby-Token"] = t;
|
||||
h["X-MediaBrowser-Token"] = t;
|
||||
}
|
||||
@@ -56,7 +39,7 @@
|
||||
async function request(path, options) {
|
||||
const response = await fetch(`${basePath()}${path}`, {
|
||||
cache: "no-store",
|
||||
headers: headers(),
|
||||
headers: authHeaders("application/json"),
|
||||
...options
|
||||
});
|
||||
if (!response.ok) throw new Error(`HTTP ${response.status}`);
|
||||
@@ -111,41 +94,9 @@
|
||||
URL.revokeObjectURL(url);
|
||||
}
|
||||
|
||||
function chip(label) {
|
||||
const el = document.createElement("span");
|
||||
el.className = "ml-chip";
|
||||
el.textContent = label;
|
||||
el.draggable = true;
|
||||
el.dataset.value = label;
|
||||
el.addEventListener("dragstart", (event) => {
|
||||
event.dataTransfer.setData("text/plain", label);
|
||||
event.dataTransfer.effectAllowed = "move";
|
||||
el.classList.add("ml-dragging");
|
||||
});
|
||||
el.addEventListener("dragend", () => el.classList.remove("ml-dragging"));
|
||||
return el;
|
||||
}
|
||||
|
||||
function bucketValues(bucket) {
|
||||
return [...bucket.querySelectorAll(".ml-chip")].map((el) => el.dataset.value || el.textContent.trim()).filter(Boolean);
|
||||
}
|
||||
|
||||
function renderBucket(bucket, values) {
|
||||
bucket.replaceChildren(...values.map(chip));
|
||||
}
|
||||
|
||||
function wireBucket(bucket, onDrop) {
|
||||
bucket.addEventListener("dragover", (event) => {
|
||||
event.preventDefault();
|
||||
bucket.classList.add("ml-over");
|
||||
});
|
||||
bucket.addEventListener("dragleave", () => bucket.classList.remove("ml-over"));
|
||||
bucket.addEventListener("drop", (event) => {
|
||||
event.preventDefault();
|
||||
bucket.classList.remove("ml-over");
|
||||
const value = event.dataTransfer.getData("text/plain");
|
||||
if (value) onDrop(value, bucket);
|
||||
});
|
||||
function replaceChildren(parent, ...children) {
|
||||
parent.textContent = "";
|
||||
parent.append(...children);
|
||||
}
|
||||
|
||||
const staticData = {
|
||||
@@ -167,10 +118,7 @@
|
||||
showModal,
|
||||
hideModals,
|
||||
downloadBlob,
|
||||
chip,
|
||||
bucketValues,
|
||||
renderBucket,
|
||||
wireBucket,
|
||||
replaceChildren,
|
||||
staticData
|
||||
};
|
||||
})();
|
||||
Reference in new issue
Block a user