fix: skip torrent folders named like videos so catalog sizes and streams resolve
NFS/WebDAV listings treat a TorBox folder named *.mkv as a 0-byte video. Scan now keeps real files only, grouping drops size-0 placeholders, and stream resolve uses the index instead of a full TMDB catalog walk.
This commit is contained in:
+39
-1
@@ -1,6 +1,6 @@
|
||||
import assert from 'node:assert/strict';
|
||||
import { test } from 'node:test';
|
||||
import { catalogGroupKey, catalogMembers, groupCatalog } from './library.js';
|
||||
import { catalogAliases, catalogGroupKey, catalogMembers, groupCatalog } from './library.js';
|
||||
|
||||
const pathId = file => Buffer.from(file).toString('base64url');
|
||||
|
||||
@@ -55,3 +55,41 @@ test('unmapped titles group by lowercase title and year', () => {
|
||||
assert.equal(catalog[0].id, 'evolution-2026');
|
||||
assert.equal(catalogGroupKey({ title: 'Evolution', year: 2026, type: 'video' }), 'evolution-2026');
|
||||
});
|
||||
|
||||
test('size-0 torrent folders are dropped when a real file exists', () => {
|
||||
const catalog = groupCatalog([
|
||||
{ id: 'dir', file: 'Rons.Gone.Wrong.2021.mkv', title: 'Rons Gone Wrong', year: 2021, type: 'video', size: 0 },
|
||||
{ id: 'real', file: 'Rons.Gone.Wrong.2021.mkv/Rons.Gone.Wrong.2021.mkv', title: 'Rons Gone Wrong', year: 2021, type: 'video', size: 1506040768 },
|
||||
{ id: 'yts', file: 'Rons Gone Wrong (2021)/Rons.Gone.Wrong.2021.mp4', title: 'Rons Gone Wrong', year: 2021, type: 'video', size: 2112849010 },
|
||||
]);
|
||||
assert.equal(catalog.length, 1);
|
||||
assert.equal(catalog[0].id, 'rons-gone-wrong-2021');
|
||||
assert.equal(catalog[0].size, 2112849010);
|
||||
assert.deepEqual(catalog[0].files.map(file => file.id), ['yts', 'real']);
|
||||
assert.equal(catalogMembers(catalog[0], catalog[0].id).length, 2);
|
||||
});
|
||||
|
||||
test('duplicate file ids collapse to one stream', () => {
|
||||
const catalog = groupCatalog([
|
||||
{ id: 'a', file: 'Movie.mp4', title: 'Movie', year: 2020, type: 'video', size: 10 },
|
||||
{ id: 'a', file: 'Movie.mp4', title: 'Movie', year: 2020, type: 'video', size: 10 },
|
||||
]);
|
||||
assert.equal(catalog[0].files.length, 1);
|
||||
});
|
||||
|
||||
test('a size-0-only group is omitted', () => {
|
||||
const catalog = groupCatalog([
|
||||
{ id: 'dir', file: 'Rons.Gone.Wrong.2021.mkv', title: 'Rons Gone Wrong', year: 2021, type: 'video', size: 0 },
|
||||
]);
|
||||
assert.equal(catalog.length, 0);
|
||||
});
|
||||
|
||||
test('title-year id still resolves after imdb grouping', () => {
|
||||
const catalog = groupCatalog([
|
||||
{ id: 'a', file: 'Rons.mkv', title: 'Rons Gone Wrong', year: 2021, imdbId: 'tt7504818', type: 'video', size: 10 },
|
||||
{ id: 'b', file: 'Rons.mp4', title: 'Rons Gone Wrong', year: 2021, imdbId: 'tt7504818', type: 'video', size: 20 },
|
||||
]);
|
||||
assert.equal(catalog[0].id, 'tt7504818');
|
||||
assert.equal(catalogMembers(catalog[0], 'rons-gone-wrong-2021').length, 2);
|
||||
assert.ok(catalogAliases(catalog[0]).has('rons-gone-wrong-2021'));
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user