Identity: unquoted names are no counters; renumbered and timestamped image sets
Test and deploy / test (push) Successful in 53s
Test and deploy / edge (push) Successful in 2m3s
Test and deploy / deploy (push) Successful in 2m4s

- The file total is read from the subject without the file name, as with a
  quoted one: "shyla-shy-09-0195.jpg hardcore …" read as 9 of 195 made each
  of 866 images a release of its own.
- imageSet: "_N" right after a number is a renumbering ("kate108lg029_28"
  once an image was skipped), and a trailing camera timestamp
  ("kurozo-2006-7-26-15-21") numbers no set.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Daan MeijerandClaude Opus 5.5 committed 2026-10-12 03:47:51 +02:00
1 parent f094fb4593
commit e72a9b1ef5
3 files changed
+51 -16

No files matched your search

+17 -10
View File
@@ -145,10 +145,14 @@ const DATES = /\b(?:(?:19|20)\d{2}[-._ ](?:0?[1-9]|1[0-2])[-._ ]\d{1,2}|\d{1,2}[
* An image's set: its name up to the number that counts the images, digits before it kept ("stp250x001" →
* "stp250x", "cutie-071-032" → "cutie-071-"); empty for a name without numbers. Suffixes after it that don't
* count the images go first: a repeat of the number before (katelg010_10), a year (hgrscans1097_2009), a
* size of 4+ digits (…_24of40_1600), and an "of" total (24of40) (LOG.md 2026-10-12 (3)).
* size of 4+ digits (…_24of40_1600), and an "of" total (24of40) (LOG.md 2026-10-12 (3)); also a renumbering
* right after it (kate108lg029_28) and a camera's timestamp (kurozo-2006-7-26-15-21) (LOG.md 2026-10-12 (5)).
*/
const TIMESTAMP = /[-_. ]?(?:19|20)\d{2}[-._ ](?:0?[1-9]|1[0-2])[-._ ]\d{1,2}(?:[-._ ]\d{1,2})*$/
export function imageSet(stem: string): string {
let s = stem.replace(/(\d+)\s*of\s*\d+/gi, '$1')
// A camera's timestamp ("kurozo-2006-7-26-15-21"): the date and the time after it number no set.
let s = stem.replace(/(\d+)\s*of\s*\d+/gi, '$1').replace(TIMESTAMP, '')
while (true) {
const m = /[_-](\d+)$/.exec(s)
if (!m) break
@@ -158,7 +162,9 @@ export function imageSet(stem: string): string {
const n = m[1]
// A repeat: the same number, or the end of the one before ("kate054001_1_1": 054001 ends in 1).
const repeat = Number(n) === Number(previous[1]) || previous[1].endsWith(n)
if (repeat || /^(?:19|20)\d\d$/.test(n) || n.length >= 4) s = before
// A renumbering right after the number ("kate108lg029_28" once an image is skipped): both count the images.
const renumbered = m[0][0] === '_' && !n.startsWith('0') && previous.index + previous[1].length === before.length
if (repeat || renumbered || /^(?:19|20)\d\d$/.test(n) || n.length >= 4) s = before
else break
}
return /\d/.test(s) ? s.replace(/\d+\D*$/, '') : ''
@@ -235,7 +241,6 @@ export function releaseIdentity(input: ReleaseInput): ReleaseIdentity | null {
const counter = /\[(\d+)\/(\d+)\]/.exec(input.subject)
// The post rule's key takes the [i/M] total (as when the catalog started); the release's file total any counter's.
const postTotal = counter ? Number.parseInt(counter[2], 10) : undefined
const fileTotal = counterTotal(input.subject)
const stem = fileStem(input.name)
if (input.weak) {
@@ -250,11 +255,13 @@ export function releaseIdentity(input: ReleaseInput): ReleaseIdentity | null {
// as the quotes would have been: otherwise every file of a set would name a release of its own.
// The subject here has its spaces collapsed; the name may not ("lara_bath 15of19 larabath_2.5.jpg").
const collapsed = input.name.replace(/\s+/g, ' ').trim()
const remainder = subjectRemainder(
input.subject.includes(`"${input.name}"`)
? input.subject
: (input.subject.includes(input.name) ? input.subject.replace(input.name, ' ') : input.subject.replace(collapsed, ' ')).replace(/"/g, ' ')
)
const named = input.subject.includes(`"${input.name}"`)
? input.subject
: (input.subject.includes(input.name) ? input.subject.replace(input.name, ' ') : input.subject.replace(collapsed, ' ')).replace(/"/g, ' ')
const remainder = subjectRemainder(named)
// Counted without the file name, as quoted names are: "shyla-shy-09-0195.jpg hardcore …" is no "9 of 195"
// (each of 866 images was a release of its own; LOG.md 2026-10-12 (5)).
const fileTotal = counterTotal(named)
// A document or comic is a release of its own (collections post hundreds under one subject).
if (DOCUMENT.test(input.name)) return { key: hash('stem', poster, stem), name: stem.replace(DOCUMENT, '') || stem, fileTotal, source: 'stem' }
const image = IMAGE.test(input.name)
@@ -276,7 +283,7 @@ export function releaseIdentity(input: ReleaseInput): ReleaseIdentity | null {
if (!tag && (namesRelease(remainder) || (image && /^[A-Za-z]{3,}$/.test(remainder)))) {
// Bounded by the counter's total, so the uploads a poster names alike are apart while the files
// of one upload (par2 and nfo included) share it (LOG.md 2026-10-09 (9)).
const total = counterTotal(input.subject)
const total = fileTotal
// Without a counter an image's set bounds it: its name up to its last number, digits kept ("stp250x001.jpg"
// → "stp250x": STIRILING SILVER's 300 sets were one release of 44k images); a name without numbers names no
// set ("Kindly Husband-to-Be.JPG": a thread of 1,177 releases), so the subject alone (LOG.md 2026-10-12 (2)).