Prober: no packaging or release-name-plus-extension as inner name
Lone candidates are often par2 volumes of random-named sets
("42507096….vol007+08.par2"): their yEnc name was taken as the inner
name. Packaging names are skipped for lone files too, and a name that
starts with the release's own name says nothing new.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
738402aefa
commit
4ed7f89951
2 files changed
+6
-2
No files matched your search
@@ -76,7 +76,8 @@ export function inspect(body: Buffer): Inspection {
|
||||
export function innerName(inspections: { kind: string; result: Inspection }[], releaseName = ''): string | null {
|
||||
const of = (kind: string) => inspections.filter((i) => i.kind === kind).map((i) => i.result)
|
||||
const content = (kind: string) => of(kind).flatMap((i) => i.names ?? []).find((n) => !PACKAGING.test(n))
|
||||
const pick = content('archive') ?? content('par2') ?? of('lone').find((i) => i.yencName)?.yencName
|
||||
const pick = content('archive') ?? content('par2') ?? of('lone').find((i) => i.yencName && !PACKAGING.test(i.yencName))?.yencName
|
||||
const name = pick?.replace(/^.*[\\/]/, '').slice(0, 255)
|
||||
return name && name.toLowerCase() !== releaseName.toLowerCase() ? name : null
|
||||
// The release's own name with an extension says nothing new (a random-named file's yEnc name is mostly its random name).
|
||||
return name && !name.toLowerCase().startsWith(releaseName.toLowerCase() || '\0') ? name : null
|
||||
}
|
||||
@@ -123,5 +123,8 @@ test.group('probe / innerName', () => {
|
||||
assert.equal(innerName([lone], 'k3j4h5'), 'Real.Name.mkv')
|
||||
// A random-named file whose yEnc name is its random name says nothing new.
|
||||
assert.isNull(innerName([lone], 'real.name.mkv'))
|
||||
assert.isNull(innerName([lone], 'Real.Name'))
|
||||
// Nor does packaging: a lone par2 volume.
|
||||
assert.isNull(innerName([{ kind: 'lone', result: { yencName: 'a1b2.vol007+08.par2', size: 1, type: 'par2' } }], 'x9y8'))
|
||||
})
|
||||
})
|
||||
Reference in new issue
Block a user