@torrent-tv/proxy 2.80.19 → 2.81.1

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.
Files changed (58) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/package.json +1 -1
  3. package/research/double-spawn-2026-09-10.md +171 -0
  4. package/services/disk/DiskSpace.js +150 -0
  5. package/services/disk/wire.js +60 -0
  6. package/services/encode/EncodeRun.js +25 -3
  7. package/services/encode/SegmentStore.js +137 -9
  8. package/services/hls-session-manager.js +26 -45
  9. package/services/orchestrators/EncodeOrchestrator.js +4 -1
  10. package/services/piece-store/allowance.js +107 -0
  11. package/services/piece-store/piece-disk-store.js +365 -0
  12. package/services/piece-store/shared-piece-store.js +1549 -1535
  13. package/services/torrent-worker/client.js +32 -0
  14. package/services/torrent-worker/pool-adapter.js +15 -0
  15. package/services/torrent-worker/protocol.js +9 -0
  16. package/services/torrent-worker/worker.js +8 -1
  17. package/services/viewer/positions.js +48 -0
  18. package/test/audio-inventory.test.js +176 -176
  19. package/test/auto-quality-step.test.js +514 -514
  20. package/test/concurrent-cost.test.js +138 -138
  21. package/test/coverage-follows-the-disk.test.js +191 -191
  22. package/test/coverage-map.test.js +195 -195
  23. package/test/declared-tracks.test.js +35 -35
  24. package/test/disk-space.test.js +150 -0
  25. package/test/encode-orchestrator.test.js +0 -3
  26. package/test/encode-run.test.js +5 -12
  27. package/test/held-request-width.test.js +155 -155
  28. package/test/helpers/encode-run.js +2 -2
  29. package/test/matroska-blocks.test.js +0 -0
  30. package/test/matroska-cues-track.test.js +192 -192
  31. package/test/mp4-composition-times.test.js +0 -0
  32. package/test/mp4-subtitles.test.js +173 -173
  33. package/test/one-authority.test.js +281 -220
  34. package/test/orchestrator-wired.test.js +199 -199
  35. package/test/packet-witness-ring.test.js +236 -236
  36. package/test/packet-witness.test.js +148 -148
  37. package/test/piece-disk-store.test.js +267 -0
  38. package/test/piece-reader.test.js +4 -4
  39. package/test/piece-store-eviction.test.js +17 -17
  40. package/test/piece-store-reservations.test.js +20 -1
  41. package/test/piece-store-slow-disk.test.js +16 -1
  42. package/test/read-window.test.js +6 -6
  43. package/test/run-intervals.test.js +100 -100
  44. package/test/seek-landing.test.js +109 -109
  45. package/test/segment-store-eviction.test.js +232 -0
  46. package/test/segments-are-shared.test.js +1 -1
  47. package/test/shared-piece-store.test.js +12 -12
  48. package/test/sidecar-naming.test.js +142 -142
  49. package/test/subtitle-cue-framing.test.js +200 -200
  50. package/test/subtitle-cue-walk.test.js +369 -369
  51. package/test/subtitle-defaults.test.js +97 -97
  52. package/test/subtitle-track-numbering.test.js +370 -370
  53. package/test/tail-duplication.test.js +167 -167
  54. package/test/tracks-begin-together.test.js +195 -195
  55. package/test/two-viewers-one-picture.test.js +374 -374
  56. package/test/video-facts.test.js +102 -102
  57. package/test/wedge-certainty.test.js +131 -131
  58. package/services/piece-store/disk-tier.js +0 -151
@@ -1,142 +1,142 @@
1
- /**
2
- * @file What a torrent's own names say about a track shipped as its own file.
3
- *
4
- * The rule worth pinning is the releaser one, because getting it wrong invents
5
- * an author. In the field case — `[HorribleSubs] Drifters - 02 [1080p].mka` in
6
- * `Rus Sound/`, beside `[HorribleSubs] Drifters - 02 [1080p].mkv` — the dub
7
- * carries the picture's own brackets and nothing else, so there is nothing
8
- * truthful to say about who made it. The subtitles of the same release sit in
9
- * `Sub/[Stan WarHammer & Nesitach]/`, a bracket the picture does not carry, and
10
- * that one IS their author.
11
- */
12
-
13
- import test from "node:test";
14
- import assert from "node:assert/strict";
15
- import {
16
- languageFromFolderNames,
17
- releaserFrom,
18
- sidecarNaming
19
- } from "../services/torrent/naming.js";
20
- /**
21
- * Read a whole path, the way the pairing does. `code` is `"und"` where nothing
22
- * was read, and `group` is what the browser calls the releaser.
23
- *
24
- * @param {string} relativePath
25
- * @param {string} [videoName]
26
- * @returns {{ code: string, group: string | null }}
27
- */
28
- function readPath(relativePath, videoName = "") {
29
- const parts = String(relativePath).split("/");
30
- const naming = sidecarNaming({
31
- folders: parts.slice(0, -1),
32
- fileName: parts[parts.length - 1],
33
- videoName
34
- });
35
- return { ...naming, code: naming.code ?? "und", group: naming.releaser };
36
- }
37
-
38
-
39
- const VIDEO_NAME = "[HorribleSubs] Drifters - 02 [1080p].mkv";
40
-
41
- test("a folder naming a language is read, whole segment or word", () => {
42
- assert.equal(languageFromFolderNames(["ENG"])?.code, "en");
43
- assert.equal(languageFromFolderNames(["Rus Sound"])?.code, "ru");
44
- assert.equal(languageFromFolderNames(["Sub", "Russian"])?.code, "ru");
45
- assert.equal(languageFromFolderNames([])?.code, undefined);
46
- });
47
-
48
- test("the innermost folder answers first", () => {
49
- assert.equal(languageFromFolderNames(["Russian", "English Dub"])?.code, "en");
50
- });
51
-
52
- test("a two-letter word inside a longer folder name is not taken for a language", () => {
53
- // "No" is Norwegian as a whole segment, but a word in `No Subs` is a word.
54
- assert.equal(languageFromFolderNames(["No Subs"]), null);
55
- assert.equal(languageFromFolderNames(["no"])?.code, "no");
56
- });
57
-
58
- test("a bracket the picture also carries is not the sidecar's author", () => {
59
- assert.equal(
60
- releaserFrom({
61
- folders: ["Rus Sound"],
62
- fileName: "[HorribleSubs] Drifters - 02 [1080p].mka",
63
- videoName: VIDEO_NAME
64
- }),
65
- null
66
- );
67
- });
68
-
69
- test("a bracket only the sidecar carries is its author", () => {
70
- assert.equal(
71
- releaserFrom({
72
- folders: ["Sub", "[Stan WarHammer & Nesitach]"],
73
- fileName: "[HorribleSubs] Drifters - 02 [1080p].ass",
74
- videoName: VIDEO_NAME
75
- }),
76
- "Stan WarHammer & Nesitach"
77
- );
78
- });
79
-
80
- test("a bracket describing the encode is never an author", () => {
81
- for (const token of ["1080p", "x264", "HEVC", "WEB-DL", "AAC", "5.1", "10bit", "78EFD746", "RUS"]) {
82
- assert.equal(
83
- releaserFrom({ folders: [], fileName: `Film [${token}].mka`, videoName: "Other.mkv" }),
84
- null,
85
- `[${token}] should not be read as a releaser`
86
- );
87
- }
88
- });
89
-
90
- test("the innermost folder is preferred to the file name", () => {
91
- assert.equal(
92
- releaserFrom({ folders: ["[TeamA]"], fileName: "[TeamB] ep.ass", videoName: "ep.mkv" }),
93
- "TeamA"
94
- );
95
- });
96
-
97
- test("language and author together, for the field case", () => {
98
- assert.deepEqual(
99
- sidecarNaming({
100
- folders: ["Rus Sound"],
101
- fileName: "[HorribleSubs] Drifters - 02 [1080p].mka",
102
- videoName: VIDEO_NAME
103
- }),
104
- { code: "ru", name: "Russian", releaser: null, isForced: false, isHearingImpaired: false, isDefault: false }
105
- );
106
- assert.deepEqual(
107
- sidecarNaming({
108
- folders: ["Sub", "[Stan WarHammer & Nesitach]"],
109
- fileName: "[HorribleSubs] Drifters - 02 [1080p].ass",
110
- videoName: VIDEO_NAME
111
- }),
112
- {
113
- code: null,
114
- name: null,
115
- releaser: "Stan WarHammer & Nesitach",
116
- isForced: false,
117
- isHearingImpaired: false,
118
- isDefault: false
119
- }
120
- );
121
- });
122
-
123
- test("a subtitle file takes its author from the folder the release put it in", () => {
124
- const info = readPath("Sub/[Stan WarHammer & Nesitach]/[HorribleSubs] Drifters - 02 [1080p].ass", VIDEO_NAME);
125
- assert.equal(info.group, "Stan WarHammer & Nesitach");
126
- });
127
-
128
- test("the picture's own release group is never reported as the translator", () => {
129
- const info = readPath("Sub/[HorribleSubs] Drifters - 02 [1080p].ass", VIDEO_NAME);
130
- assert.equal(info.group, null);
131
- });
132
-
133
- test("the language of a subtitle folder is read where the whole segment is not a language", () => {
134
- const info = readPath("Rus Sub/ep.srt", "ep.mkv");
135
- assert.equal(info.code, "ru");
136
- });
137
-
138
- test("what the rules answer with nothing to go on", () => {
139
- const info = readPath("ep.srt");
140
- assert.equal(info.code, "und");
141
- assert.equal(info.group, null);
142
- });
1
+ /**
2
+ * @file What a torrent's own names say about a track shipped as its own file.
3
+ *
4
+ * The rule worth pinning is the releaser one, because getting it wrong invents
5
+ * an author. In the field case — `[HorribleSubs] Drifters - 02 [1080p].mka` in
6
+ * `Rus Sound/`, beside `[HorribleSubs] Drifters - 02 [1080p].mkv` — the dub
7
+ * carries the picture's own brackets and nothing else, so there is nothing
8
+ * truthful to say about who made it. The subtitles of the same release sit in
9
+ * `Sub/[Stan WarHammer & Nesitach]/`, a bracket the picture does not carry, and
10
+ * that one IS their author.
11
+ */
12
+
13
+ import test from "node:test";
14
+ import assert from "node:assert/strict";
15
+ import {
16
+ languageFromFolderNames,
17
+ releaserFrom,
18
+ sidecarNaming
19
+ } from "../services/torrent/naming.js";
20
+ /**
21
+ * Read a whole path, the way the pairing does. `code` is `"und"` where nothing
22
+ * was read, and `group` is what the browser calls the releaser.
23
+ *
24
+ * @param {string} relativePath
25
+ * @param {string} [videoName]
26
+ * @returns {{ code: string, group: string | null }}
27
+ */
28
+ function readPath(relativePath, videoName = "") {
29
+ const parts = String(relativePath).split("/");
30
+ const naming = sidecarNaming({
31
+ folders: parts.slice(0, -1),
32
+ fileName: parts[parts.length - 1],
33
+ videoName
34
+ });
35
+ return { ...naming, code: naming.code ?? "und", group: naming.releaser };
36
+ }
37
+
38
+
39
+ const VIDEO_NAME = "[HorribleSubs] Drifters - 02 [1080p].mkv";
40
+
41
+ test("a folder naming a language is read, whole segment or word", () => {
42
+ assert.equal(languageFromFolderNames(["ENG"])?.code, "en");
43
+ assert.equal(languageFromFolderNames(["Rus Sound"])?.code, "ru");
44
+ assert.equal(languageFromFolderNames(["Sub", "Russian"])?.code, "ru");
45
+ assert.equal(languageFromFolderNames([])?.code, undefined);
46
+ });
47
+
48
+ test("the innermost folder answers first", () => {
49
+ assert.equal(languageFromFolderNames(["Russian", "English Dub"])?.code, "en");
50
+ });
51
+
52
+ test("a two-letter word inside a longer folder name is not taken for a language", () => {
53
+ // "No" is Norwegian as a whole segment, but a word in `No Subs` is a word.
54
+ assert.equal(languageFromFolderNames(["No Subs"]), null);
55
+ assert.equal(languageFromFolderNames(["no"])?.code, "no");
56
+ });
57
+
58
+ test("a bracket the picture also carries is not the sidecar's author", () => {
59
+ assert.equal(
60
+ releaserFrom({
61
+ folders: ["Rus Sound"],
62
+ fileName: "[HorribleSubs] Drifters - 02 [1080p].mka",
63
+ videoName: VIDEO_NAME
64
+ }),
65
+ null
66
+ );
67
+ });
68
+
69
+ test("a bracket only the sidecar carries is its author", () => {
70
+ assert.equal(
71
+ releaserFrom({
72
+ folders: ["Sub", "[Stan WarHammer & Nesitach]"],
73
+ fileName: "[HorribleSubs] Drifters - 02 [1080p].ass",
74
+ videoName: VIDEO_NAME
75
+ }),
76
+ "Stan WarHammer & Nesitach"
77
+ );
78
+ });
79
+
80
+ test("a bracket describing the encode is never an author", () => {
81
+ for (const token of ["1080p", "x264", "HEVC", "WEB-DL", "AAC", "5.1", "10bit", "78EFD746", "RUS"]) {
82
+ assert.equal(
83
+ releaserFrom({ folders: [], fileName: `Film [${token}].mka`, videoName: "Other.mkv" }),
84
+ null,
85
+ `[${token}] should not be read as a releaser`
86
+ );
87
+ }
88
+ });
89
+
90
+ test("the innermost folder is preferred to the file name", () => {
91
+ assert.equal(
92
+ releaserFrom({ folders: ["[TeamA]"], fileName: "[TeamB] ep.ass", videoName: "ep.mkv" }),
93
+ "TeamA"
94
+ );
95
+ });
96
+
97
+ test("language and author together, for the field case", () => {
98
+ assert.deepEqual(
99
+ sidecarNaming({
100
+ folders: ["Rus Sound"],
101
+ fileName: "[HorribleSubs] Drifters - 02 [1080p].mka",
102
+ videoName: VIDEO_NAME
103
+ }),
104
+ { code: "ru", name: "Russian", releaser: null, isForced: false, isHearingImpaired: false, isDefault: false }
105
+ );
106
+ assert.deepEqual(
107
+ sidecarNaming({
108
+ folders: ["Sub", "[Stan WarHammer & Nesitach]"],
109
+ fileName: "[HorribleSubs] Drifters - 02 [1080p].ass",
110
+ videoName: VIDEO_NAME
111
+ }),
112
+ {
113
+ code: null,
114
+ name: null,
115
+ releaser: "Stan WarHammer & Nesitach",
116
+ isForced: false,
117
+ isHearingImpaired: false,
118
+ isDefault: false
119
+ }
120
+ );
121
+ });
122
+
123
+ test("a subtitle file takes its author from the folder the release put it in", () => {
124
+ const info = readPath("Sub/[Stan WarHammer & Nesitach]/[HorribleSubs] Drifters - 02 [1080p].ass", VIDEO_NAME);
125
+ assert.equal(info.group, "Stan WarHammer & Nesitach");
126
+ });
127
+
128
+ test("the picture's own release group is never reported as the translator", () => {
129
+ const info = readPath("Sub/[HorribleSubs] Drifters - 02 [1080p].ass", VIDEO_NAME);
130
+ assert.equal(info.group, null);
131
+ });
132
+
133
+ test("the language of a subtitle folder is read where the whole segment is not a language", () => {
134
+ const info = readPath("Rus Sub/ep.srt", "ep.mkv");
135
+ assert.equal(info.code, "ru");
136
+ });
137
+
138
+ test("what the rules answer with nothing to go on", () => {
139
+ const info = readPath("ep.srt");
140
+ assert.equal(info.code, "und");
141
+ assert.equal(info.group, null);
142
+ });