@dominevo/addon-media-library 0.1.6 → 0.1.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +8 -0
- package/dist/media-library.addon.js +36 -28
- package/dist/media-library.addon.mjs +36 -28
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -7,6 +7,14 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
7
7
|
|
|
8
8
|
## [Unreleased]
|
|
9
9
|
|
|
10
|
+
## [0.1.7] - 2026-12-03
|
|
11
|
+
|
|
12
|
+
### Changed
|
|
13
|
+
|
|
14
|
+
- Library titles and overviews follow any default language chosen in System settings (Chinese uses the simplified catalogue)
|
|
15
|
+
- Series, movie and search lists are now sorted A-Z by the title shown in your language, not the stored title.
|
|
16
|
+
- Episode and cover images served over plain http by your Sonarr or Radarr now load; only URLs on the configured arr address are fetched, every other http URL stays refused.
|
|
17
|
+
|
|
10
18
|
## [0.1.6] - 2026-12-03
|
|
11
19
|
|
|
12
20
|
### Changed
|
|
@@ -10781,6 +10781,19 @@ function resolveItemText(row, requested, serverDefault) {
|
|
|
10781
10781
|
overview: overview ?? row.overview
|
|
10782
10782
|
};
|
|
10783
10783
|
}
|
|
10784
|
+
/**
|
|
10785
|
+
* `rows` in A–Z order of the title each reader sees (`resolveItemText`, minus a leading article), compared with the
|
|
10786
|
+
* collator of the reader's language (`en` when none). A stable sort: equal titles keep the order
|
|
10787
|
+
* the rows came in (the caller's read order: item id for `queryAllItems`), so a page cut is deterministic.
|
|
10788
|
+
*/
|
|
10789
|
+
function sortByShownTitle(rows, requested, serverDefault) {
|
|
10790
|
+
const collator = new Intl.Collator(languageKey(requested) ?? "en", {
|
|
10791
|
+
sensitivity: "base",
|
|
10792
|
+
numeric: true
|
|
10793
|
+
});
|
|
10794
|
+
const keys = new Map(rows.map((row) => [row, sortKey(resolveItemText(row, requested, serverDefault).title)]));
|
|
10795
|
+
return rows.toSorted((a, b) => collator.compare(keys.get(a) ?? "", keys.get(b) ?? ""));
|
|
10796
|
+
}
|
|
10784
10797
|
var FILE_PLANE_PREFIX = "file";
|
|
10785
10798
|
var HUB_PLANE_BASE = "/addon/media-library";
|
|
10786
10799
|
var SEARCH_DEFAULT_LIMIT = 50;
|
|
@@ -10847,25 +10860,15 @@ var LibraryStore = class {
|
|
|
10847
10860
|
});
|
|
10848
10861
|
}
|
|
10849
10862
|
pageOf = async (kind, userId, limit, offset, language) => {
|
|
10850
|
-
const
|
|
10851
|
-
where: {
|
|
10852
|
-
kind,
|
|
10853
|
-
topLevel: true
|
|
10854
|
-
},
|
|
10855
|
-
orderBy: {
|
|
10856
|
-
field: "sortTitle",
|
|
10857
|
-
direction: "asc"
|
|
10858
|
-
},
|
|
10859
|
-
limit: limit ?? 100,
|
|
10860
|
-
offset: offset ?? 0
|
|
10861
|
-
});
|
|
10862
|
-
const total = await this.db.count(ITEMS, { where: {
|
|
10863
|
+
const all = await this.queryAllItems({ where: {
|
|
10863
10864
|
kind,
|
|
10864
10865
|
topLevel: true
|
|
10865
10866
|
} });
|
|
10867
|
+
const start = offset ?? 0;
|
|
10868
|
+
const page = sortByShownTitle(all, language, this.serverLanguage()).slice(start, start + (limit ?? 100));
|
|
10866
10869
|
return {
|
|
10867
|
-
items: await this.summaries(
|
|
10868
|
-
total
|
|
10870
|
+
items: await this.summaries(page, userId, language),
|
|
10871
|
+
total: all.length
|
|
10869
10872
|
};
|
|
10870
10873
|
};
|
|
10871
10874
|
listSeries(userId, limit, offset, language) {
|
|
@@ -10888,15 +10891,9 @@ var LibraryStore = class {
|
|
|
10888
10891
|
async search(userId, query, limit, language) {
|
|
10889
10892
|
const needle = foldTitle(query);
|
|
10890
10893
|
if (needle === "") return [];
|
|
10891
|
-
const rows = await this.
|
|
10892
|
-
where: { topLevel: true },
|
|
10893
|
-
orderBy: {
|
|
10894
|
-
field: "sortTitle",
|
|
10895
|
-
direction: "asc"
|
|
10896
|
-
}
|
|
10897
|
-
});
|
|
10894
|
+
const rows = await this.queryAllItems({ where: { topLevel: true } });
|
|
10898
10895
|
const fallback = this.serverLanguage();
|
|
10899
|
-
const hits = rows.filter((row) => row.titleFold.includes(needle) || foldTitle(resolveItemText(row, language, fallback).title).includes(needle)).slice(0, limit ?? SEARCH_DEFAULT_LIMIT);
|
|
10896
|
+
const hits = sortByShownTitle(rows.filter((row) => row.titleFold.includes(needle) || foldTitle(resolveItemText(row, language, fallback).title).includes(needle)), language, fallback).slice(0, limit ?? SEARCH_DEFAULT_LIMIT);
|
|
10900
10897
|
return this.summaries(hits, userId, language);
|
|
10901
10898
|
}
|
|
10902
10899
|
episodesOf(seriesId) {
|
|
@@ -11016,7 +11013,7 @@ var LibraryStore = class {
|
|
|
11016
11013
|
kind: "remote",
|
|
11017
11014
|
url: cover
|
|
11018
11015
|
});
|
|
11019
|
-
else if (cover.startsWith("/")) out.push({
|
|
11016
|
+
else if (cover.startsWith("/") || cover.startsWith("http://")) out.push({
|
|
11020
11017
|
kind: "arr",
|
|
11021
11018
|
path: cover,
|
|
11022
11019
|
sourceId: item.sourceId
|
|
@@ -12557,9 +12554,11 @@ var SeasonSchema = object({ episodes: array(object({
|
|
|
12557
12554
|
overview: string().nullish(),
|
|
12558
12555
|
still_path: string().nullish()
|
|
12559
12556
|
})) });
|
|
12560
|
-
/** TMDB's tag for a
|
|
12561
|
-
function tmdbLanguageOf(
|
|
12562
|
-
|
|
12557
|
+
/** TMDB's tag for a content language: English keeps the region it was always asked in, Chinese is the simplified catalogue, others are sent bare. */
|
|
12558
|
+
function tmdbLanguageOf(language) {
|
|
12559
|
+
if (language === "en") return DEFAULT_LANGUAGE;
|
|
12560
|
+
if (language === "zh") return "zh-CN";
|
|
12561
|
+
return language;
|
|
12563
12562
|
}
|
|
12564
12563
|
function yearOf$1(date) {
|
|
12565
12564
|
const match = /^(\d{4})/.exec(date ?? "");
|
|
@@ -13085,8 +13084,17 @@ function typeOf(bytes) {
|
|
|
13085
13084
|
if (bytes.length > 12 && bytes.subarray(8, 12).toString("latin1") === "WEBP") return "image/webp";
|
|
13086
13085
|
return null;
|
|
13087
13086
|
}
|
|
13088
|
-
/**
|
|
13087
|
+
/**
|
|
13088
|
+
* The remote URL of an arr cover: a path on the arr's own origin, or an absolute URL that already
|
|
13089
|
+
* IS on that origin (the arr app answers plain http on a LAN). Never another host, port or scheme,
|
|
13090
|
+
* and never a URL that carries credentials.
|
|
13091
|
+
*/
|
|
13089
13092
|
function coverUrl(source, path) {
|
|
13093
|
+
if (/^https?:\/\//i.test(path)) {
|
|
13094
|
+
const absolute = URL.canParse(path) ? new URL(path) : null;
|
|
13095
|
+
const own = new URL(source.baseUrl);
|
|
13096
|
+
return absolute !== null && absolute.origin === own.origin && absolute.username === "" && absolute.password === "" ? absolute.toString() : null;
|
|
13097
|
+
}
|
|
13090
13098
|
if (!path.startsWith("/") || path.startsWith("//")) return null;
|
|
13091
13099
|
const base = new URL(source.baseUrl);
|
|
13092
13100
|
const url = new URL(`${source.baseUrl}${path}`);
|
|
@@ -10777,6 +10777,19 @@ function resolveItemText(row, requested, serverDefault) {
|
|
|
10777
10777
|
overview: overview ?? row.overview
|
|
10778
10778
|
};
|
|
10779
10779
|
}
|
|
10780
|
+
/**
|
|
10781
|
+
* `rows` in A–Z order of the title each reader sees (`resolveItemText`, minus a leading article), compared with the
|
|
10782
|
+
* collator of the reader's language (`en` when none). A stable sort: equal titles keep the order
|
|
10783
|
+
* the rows came in (the caller's read order: item id for `queryAllItems`), so a page cut is deterministic.
|
|
10784
|
+
*/
|
|
10785
|
+
function sortByShownTitle(rows, requested, serverDefault) {
|
|
10786
|
+
const collator = new Intl.Collator(languageKey(requested) ?? "en", {
|
|
10787
|
+
sensitivity: "base",
|
|
10788
|
+
numeric: true
|
|
10789
|
+
});
|
|
10790
|
+
const keys = new Map(rows.map((row) => [row, sortKey(resolveItemText(row, requested, serverDefault).title)]));
|
|
10791
|
+
return rows.toSorted((a, b) => collator.compare(keys.get(a) ?? "", keys.get(b) ?? ""));
|
|
10792
|
+
}
|
|
10780
10793
|
var FILE_PLANE_PREFIX = "file";
|
|
10781
10794
|
var HUB_PLANE_BASE = "/addon/media-library";
|
|
10782
10795
|
var SEARCH_DEFAULT_LIMIT = 50;
|
|
@@ -10843,25 +10856,15 @@ var LibraryStore = class {
|
|
|
10843
10856
|
});
|
|
10844
10857
|
}
|
|
10845
10858
|
pageOf = async (kind, userId, limit, offset, language) => {
|
|
10846
|
-
const
|
|
10847
|
-
where: {
|
|
10848
|
-
kind,
|
|
10849
|
-
topLevel: true
|
|
10850
|
-
},
|
|
10851
|
-
orderBy: {
|
|
10852
|
-
field: "sortTitle",
|
|
10853
|
-
direction: "asc"
|
|
10854
|
-
},
|
|
10855
|
-
limit: limit ?? 100,
|
|
10856
|
-
offset: offset ?? 0
|
|
10857
|
-
});
|
|
10858
|
-
const total = await this.db.count(ITEMS, { where: {
|
|
10859
|
+
const all = await this.queryAllItems({ where: {
|
|
10859
10860
|
kind,
|
|
10860
10861
|
topLevel: true
|
|
10861
10862
|
} });
|
|
10863
|
+
const start = offset ?? 0;
|
|
10864
|
+
const page = sortByShownTitle(all, language, this.serverLanguage()).slice(start, start + (limit ?? 100));
|
|
10862
10865
|
return {
|
|
10863
|
-
items: await this.summaries(
|
|
10864
|
-
total
|
|
10866
|
+
items: await this.summaries(page, userId, language),
|
|
10867
|
+
total: all.length
|
|
10865
10868
|
};
|
|
10866
10869
|
};
|
|
10867
10870
|
listSeries(userId, limit, offset, language) {
|
|
@@ -10884,15 +10887,9 @@ var LibraryStore = class {
|
|
|
10884
10887
|
async search(userId, query, limit, language) {
|
|
10885
10888
|
const needle = foldTitle(query);
|
|
10886
10889
|
if (needle === "") return [];
|
|
10887
|
-
const rows = await this.
|
|
10888
|
-
where: { topLevel: true },
|
|
10889
|
-
orderBy: {
|
|
10890
|
-
field: "sortTitle",
|
|
10891
|
-
direction: "asc"
|
|
10892
|
-
}
|
|
10893
|
-
});
|
|
10890
|
+
const rows = await this.queryAllItems({ where: { topLevel: true } });
|
|
10894
10891
|
const fallback = this.serverLanguage();
|
|
10895
|
-
const hits = rows.filter((row) => row.titleFold.includes(needle) || foldTitle(resolveItemText(row, language, fallback).title).includes(needle)).slice(0, limit ?? SEARCH_DEFAULT_LIMIT);
|
|
10892
|
+
const hits = sortByShownTitle(rows.filter((row) => row.titleFold.includes(needle) || foldTitle(resolveItemText(row, language, fallback).title).includes(needle)), language, fallback).slice(0, limit ?? SEARCH_DEFAULT_LIMIT);
|
|
10896
10893
|
return this.summaries(hits, userId, language);
|
|
10897
10894
|
}
|
|
10898
10895
|
episodesOf(seriesId) {
|
|
@@ -11012,7 +11009,7 @@ var LibraryStore = class {
|
|
|
11012
11009
|
kind: "remote",
|
|
11013
11010
|
url: cover
|
|
11014
11011
|
});
|
|
11015
|
-
else if (cover.startsWith("/")) out.push({
|
|
11012
|
+
else if (cover.startsWith("/") || cover.startsWith("http://")) out.push({
|
|
11016
11013
|
kind: "arr",
|
|
11017
11014
|
path: cover,
|
|
11018
11015
|
sourceId: item.sourceId
|
|
@@ -12553,9 +12550,11 @@ var SeasonSchema = object({ episodes: array(object({
|
|
|
12553
12550
|
overview: string().nullish(),
|
|
12554
12551
|
still_path: string().nullish()
|
|
12555
12552
|
})) });
|
|
12556
|
-
/** TMDB's tag for a
|
|
12557
|
-
function tmdbLanguageOf(
|
|
12558
|
-
|
|
12553
|
+
/** TMDB's tag for a content language: English keeps the region it was always asked in, Chinese is the simplified catalogue, others are sent bare. */
|
|
12554
|
+
function tmdbLanguageOf(language) {
|
|
12555
|
+
if (language === "en") return DEFAULT_LANGUAGE;
|
|
12556
|
+
if (language === "zh") return "zh-CN";
|
|
12557
|
+
return language;
|
|
12559
12558
|
}
|
|
12560
12559
|
function yearOf$1(date) {
|
|
12561
12560
|
const match = /^(\d{4})/.exec(date ?? "");
|
|
@@ -13081,8 +13080,17 @@ function typeOf(bytes) {
|
|
|
13081
13080
|
if (bytes.length > 12 && bytes.subarray(8, 12).toString("latin1") === "WEBP") return "image/webp";
|
|
13082
13081
|
return null;
|
|
13083
13082
|
}
|
|
13084
|
-
/**
|
|
13083
|
+
/**
|
|
13084
|
+
* The remote URL of an arr cover: a path on the arr's own origin, or an absolute URL that already
|
|
13085
|
+
* IS on that origin (the arr app answers plain http on a LAN). Never another host, port or scheme,
|
|
13086
|
+
* and never a URL that carries credentials.
|
|
13087
|
+
*/
|
|
13085
13088
|
function coverUrl(source, path) {
|
|
13089
|
+
if (/^https?:\/\//i.test(path)) {
|
|
13090
|
+
const absolute = URL.canParse(path) ? new URL(path) : null;
|
|
13091
|
+
const own = new URL(source.baseUrl);
|
|
13092
|
+
return absolute !== null && absolute.origin === own.origin && absolute.username === "" && absolute.password === "" ? absolute.toString() : null;
|
|
13093
|
+
}
|
|
13086
13094
|
if (!path.startsWith("/") || path.startsWith("//")) return null;
|
|
13087
13095
|
const base = new URL(source.baseUrl);
|
|
13088
13096
|
const url = new URL(`${source.baseUrl}${path}`);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dominevo/addon-media-library",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.7",
|
|
4
4
|
"description": "The self-hosted media library: a catalogue built from the arr apps and plain folders, probed files, per-user progress, direct play with Range and a native /media app in the viewer.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"dominevo",
|
|
@@ -58,7 +58,7 @@
|
|
|
58
58
|
}
|
|
59
59
|
],
|
|
60
60
|
"requires": {
|
|
61
|
-
"server": ">=0.1.
|
|
61
|
+
"server": ">=0.1.58"
|
|
62
62
|
}
|
|
63
63
|
},
|
|
64
64
|
"files": [
|