Skip to content

feat(title): read the brackets of a fansub name by role, and its titles - #78

Open
zze0s wants to merge 1 commit into
feat/numberingfrom
feat/anime-titles
Open

zze0s wants to merge 1 commit into
feat/numberingfrom
feat/anime-titles

Conversation

@zze0s

@zze0s zze0s commented Nov 18, 2026 •

Copy link
Copy Markdown

Description

Stacked on #77. The anime stage is the second half of step 3 and comes as three PRs: this one (brackets and titles), #79 (extras, volumes, contents, the episode number) and #80 (CJK markers and brackets).

A fansub name says with its brackets what a scene name says with its order: [Group] Title - 05 [tags][checksum].mkv. Until now the builder had no stage that read a name that way. This PR adds one, in front of the zone stage. It reads:

  • the role of each bracket by what it holds: a group, a checksum, tags, a number, words, a year. brackets in zone.go is still the one reading of the brackets of a name, and the zones, the new stage and the group owner all call it
  • the group in a bracket that opens the name when the meta lexer does not read it, (CBB) Title
  • where the title starts and the head ends, also for a title in a bracket of its own, [Group][Title][01][1080p]
  • more than one title. The first is Title, the others go to Alt: behind a bar or a spaced slash, behind a bare slash beside a CJK letter, and in parentheses behind the title when the two are in another script or another language
  • a number with a point in a title, Evangelion 3.33

Examples

name before after
(CBB) Aoki Hagane no Arpeggio - The Complete Series (BD 1080p)(HEVC-x265-10bit) title CBB, group Series title Aoki Hagane no Arpeggio - The Complete Series, group CBB
[Cleo] Saihate no Paladin | The Faraway Paladin [Dual Audio 10bit 1080p][HEVC-x265] title Saihate no Paladin | The Faraway Paladin title Saihate no Paladin, alt The Faraway Paladin
[Beatrice-Raws] Tonari no Totoro / My Neighbor Totoro [DCPrip 1998x1080 HEVC TrueHD].mkv unused My Neighbor Totoro alt My Neighbor Totoro
[Judas] Shingeki no Kyojin (Attack on Titan) - S04E30 [1080p][HEVC x265 10bit][Multi-Subs] (Weekly) unused Attack on Titan alt Attack on Titan
[UTW-THORA] Evangelion 3.33 You Can (Not) Redo [BD][1080p,x264,flac] title Evangelion 3 33 You Can title Evangelion 3.33 You Can (Not) Redo
[MiraiAnime] In This Corner (and Other Corners) of the World (2019) [...] title In This Corner title In This Corner (and Other Corners) of the World
[WBDP] [Vivid] Uchouten Kazoku / The Eccentric Family 2 [BD][1080p-AAC] title Uchouten Kazoku title Uchouten Kazoku 2, alt The Eccentric Family 2
[RaX]Mezzo(DSA)_-_05_-_[x264_ogg]_[585d9971].mkv title Mezzo, unused DSA title Mezzo(DSA)

The Complete Series leaves the first title in #79.

Which names the stage reads

This is the part to review hardest. The first version read any spaced name with a bracket and a resolution, which is every YTS, QxR and Plex name, and two reviews found film names it got wrong. The rule now, stated in the comment of shapeOf:

  • A name with no bracket, a name that sets its words apart with dots, and a record or a book with no sign of a video are not read. They keep the tags the lexers made, tag for tag, which TestStructureKeepsTags holds over tests.yaml and the corpora.
  • A name a fansub group wrote is read in full. The name says so itself: a bracket opens it that names who made the release, or it has a checksum.
  • A lead bracket whose word the vocabulary reads as a tag, or that is a year, names no maker: [BluRay], [English], [PL], [Hi10], [2019]. TestLeadWord holds 41 words.
  • Any other name with a sign of a video is read only where the name sets a marker apart from its title. That matters from feat(series): read the extras, volumes and contents of a fansub name #79 on.

A tracker tag in front of a spaced title cannot be told from a group: [TGx] Dante 01 1080p WEB-DL x264 reads as episode 1 of Dante. No list of tracker tags is kept. The name is a probe row in the list of known wrong readings.

What changes, by set

Against #77, at this commit:

set names changed
real scene names 54,766 0
German names 8,719 0
sports.txt 2,505 0
probe sets of scene names 163 0
tests.yaml 872 3
nyaa.txt 13,215 1,012

%o gives the name back on every name of every set.

Accuracy

#77 this PR
nyaa-400, names right in every field 331 337
nyaa-400, title 347 354
nyaa-blind-140, names 27 36
nyaa-blind-140, title 63 81

16 names leave the wrong lines, all on the title. One enters until #79: [Kametsu] Fate Stay Night: Unlimited Blade Works (TV) (Prologue+S1+S2+Sunny Day) keeps (TV) in its title.

Labelled floors: anitomy title 65 to 70 and group 92 to 93, habari title 70 to 74, anitogo title 65 to 71 and group 93 to 94. The habari season floor goes from 89 to 91, which it measured before this change too. No floor goes down.

Other titles in parentheses, and their limit

Shingeki no Kyojin (Attack on Titan) gives an Alt, and Kanteishi (Kari) or (The Final Season) must not. The stage reads the bracket as another title only when the name says so: the two sides are in another script, or one is Japanese in Latin letters and the other is not. It tells that by Japanese particles, small English words and the share of words made of open syllables (another, tongueOf, romaji in anime.go).

Measured on nyaa names that gain an Alt from a bracket: 0 wrong in two seeded samples, 160 and 106 names. The first version of the rule had 21 wrong of 160.

Two limits, both in the comment of another:

  • An English subtitle behind a Japanese title reads as another title, Kimetsu no Yaiba (Hashira Training). Nothing in the name tells it from a translation. A reviewer made 40 such names and 13 read wrong. None of the 266 real ones did.
  • Pairs in other languages written in Latin letters (Korean, Spanish, French, German) are left unread.

Time and size

Rotating runs, 12 each, the same names on both sides:

benchmark #77 this PR
Parse (tests.yaml names) 21.24 µs 22.02 µs +3.7%
Build 6.51 µs 7.24 µs +11.2%
ParseNyaa 28.00 µs 30.10 µs +7.5%
ParseSports 17.69 µs 17.89 µs +1.1%
ParseTags 12.85 µs 12.85 µs same

Allocations per nyaa name go from 54 to 55.5, and stay 41 and 47 on the other two sets within half an allocation. A name with no bracket pays for one pass over its tags.

TestStructureLinear times names made of what the stage reads at two lengths: the shapes it lists, and shapes generated from every joiner and every kind of bracket. A crash came out of review, and it is older than this PR. A claim in front of a closing bracket read one tag past the end when a name was built with all of its tags inside it. #77 has the same hole (Show German] built that way panics there). The zones now read the tag at their anchor in one guarded place. TestAnchorPastEnd builds every name of the tests and the corpora whole, and the fuzz target every input.

A fix after the PR was opened

A later fuzz run found [REPACK7](A000)00 000(000000: the release carried an episode that its own tags did not write. A name that opens with flags in a bracket is built in two steps, and the outer release kept the old tags whenever the inner build had not changed their count. This stage reads some names in a copy of the same length, so fields were read from tags the release did not hold. [REPACK] (CBB) Aoki Hagane no Arpeggio - ... had the group CBB and no group tag.

build now tells the tags apart by where they are kept. TestFlagsInFront holds it, and TestNumberingBehindBrackets runs the numbering check and the round trip on every name of tests.yaml and TestStructure behind 26 kinds of leading bracket. Ten minutes of FuzzParseString on the head of the three PRs found nothing more. No reading of a real name changes: no name in any set opens with flags.

For you to decide

  1. The group has a second maker. leadGroup in group.go makes the group tag of (CBB) Title. It has to run before the shape is read, since the group bracket decides where the title starts. TestGroupOwner lists it, and TestOneOwner gains exemptions for the steps that must retype a tag in front of the zones (decimals, numbers, contents, handBackMarker, each with its reason in the test).
  2. Mezzo(DSA). The title is as the name writes it. Before it was Mezzo with DSA unused.
  3. A language test in the parser. It is about 200 lines and decides one thing, whether a bracket is another title. If you would rather not carry it, the fallback is to read no bracket as another title in Latin letters, which loses about 460 Alt values in nyaa.txt.

Downstream impact on autobrr and qui

No API changes. Readings change for fansub-style names only:

  • Alt holds other titles where it was empty, and Title is the first title where it was both.
  • Group is right for a group in parentheses in front.
  • Unused() no longer holds the words of another title.

Both apps build and pass against this commit with the ports of #77 and no further change: qui's 11 packages that use rls pass, and autobrr fails only the two tests that fail against master.

Review

Two independent reviews, each followed by a fix round, and my own probes of film, show and record names in the shapes of YTS, QxR, Plex and tracker listings. What they found in this PR's part, all fixed here: the crash above, a CJK bracket printed as an ASCII one in a title, wrong Alt values, and a lead [2019] or [BluRay] read as a group.

Type of change

  • New feature (non-breaking change which adds functionality)

How has this been tested?

  • TestStructure (real names with the fields the stage owns), TestLeadWord, TestStructureKeepsTags, TestAnchorPastEnd, TestStructureLinear, and the group tests of refactor(group): give the group of a release one owner #75.
  • The differential above with a dump of every field, at this commit.
  • go vet ./..., gofmt -l . with Go 1.26 and 1.27, go test ./... with the corpus present, the cmd/rls checks, on a clean export of this commit. go test -race ./... and 60 s of FuzzParseString on the head of the three.

Checklist

  • I ran go fmt and the test suite passes locally
  • I added cases to tests.yaml for any parsing change
  • If this adds or renames a normalized value (source, codec, HDR, etc.), I noted the downstream impact on autobrr/qui
  • I have linked any related issue (none)

AI disclosure

Yes, all of it. Claude Code (Claude Fable 5.2) wrote the stage and its tests. Two further model runs reviewed it, and the fixes for what they found are in this commit.

@coderabbitai

coderabbitai Bot commented Nov 18, 2026 •

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 0d156768-a95b-404d-bbf2-a982302373f7

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • Trigger review

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

A fansub name says with its brackets what a scene name says with its
order. brackets, the one reading of the brackets of a name, now also gives
each bracket a role by what it holds: a group, a checksum, tags, numbers
alone, words alone, a year. The zones read its kinds as before, and a new
stage in the builder, in front of the zones, reads the roles:

- the group in parentheses that opens a name, which the owner of the
  group makes a group tag: '(CBB) Aoki Hagane no Arpeggio' had the title
  'CBB'
- the shape of the name: where the title starts, also in a bracket of its
  own ('[Group][Title][01][1080p]') and behind a bracket of words that
  names another group ('[WBDP] [Vivid] Title'), and where the head ends
- more than one title, behind a bar or a spaced slash, behind a bare
  slash that sets a title in a CJK script apart from the next, or behind
  a season. The first is Title and the others go to Alt: '[Cleo] Saihate
  no Paladin | The Faraway Paladin' had both in Title. A bare slash cuts
  beside a letter of such a script, or between a part that has one and a
  part that has none ('魔法少女奈叶剧场版 1st/Mahou Shoujo Lyrical Nanoha
  The Movie 1st'). 'In/Spectre', 'Bullet/Bullet' and 'Fate / stay night'
  stay one title, and the number that ends 'Uchouten Kazoku / The
  Eccentric Family 2' counts for both. A bracket that lists what the
  release holds with a plus is no title ('[正片+其他动画短片+花絮]')
- another title in parentheses behind the title, when the name says that
  it is one: the two are written in another script or in another
  language. Of the languages the stage tells Japanese in Latin letters
  from any other, by the particles, the small words and the share of
  words made of open syllables on each side ('Shingeki no Kyojin (Attack
  on Titan)', 'Hell's Paradise (Jigokuraku)'). In the language of the
  title the bracket is a part of it or a note, which nothing tells apart,
  and is left unread as before ('Kanteishi (Kari)', 'Muri Muri! (Muri ja
  Nakatta)', '(The Animation)', '(The Final Season)')
- a number with a point in the title of a name that sets its words apart
  with spaces: 'Evangelion 3.33 You Can (Not) Redo' was 'Evangelion 3 33
  You Can', and the '3.0+1.0' of 'Evangelion 3.0+1.0 Thrice Upon a Time'
  was read as two channel layouts

The stage reads a name with a bracket that sets its words apart with
spaces, when a fansub group wrote it or it has a sign of a video. The name
says the first itself: a bracket opens it that holds a group or words that
are no tag, or it has a checksum. A bracket of tags or a year opens any
kind of name. The meta lexer reads any one word in the bracket that opens
a name as its site, so the stage asks the vocabulary about that word: one
that it reads as a tag of any type but a group names no maker ('[BluRay]',
'[English]', '[PL]', '[Hi10]', '[Uncut]', '[700MB]', '[ENG SUB]'), and
neither does a year ('[2019]'). A known group stays one. The bracket
behind one that names no maker is then read for the group and the title
('[4K][DBD-Raws][Title][2160P]'). The tag of a tracker cannot be told from
a group and opens the name as one does ('[TGx]', '[YTS]'), and so does a
word of quality that the vocabulary does not hold ('[HD]'): no list of
either is kept. TestLeadWord holds the words.

A name the stage does not read keeps the tags the lexers made, each as it
was: the steps in front of the gate work on a copy, which
TestStructureKeepsTags holds. No name of the scene sets, of sports.txt or
of the probe sets changes.

A name with flags in a bracket in front is built in two steps: the rest
alone, then the flags back in front of it ('[REPACK] (Group) Title - 01').
The builder kept the tags of the rest only when their number had changed,
which is how it told that fixHalfEpisode had made new ones. The stage
reads some names in a copy that is as long, so the release of such a name
would keep the tags from before, and its group, its title and its
numbering would be read from tags it does not hold. The builder now tells
the tags apart by where they are kept. TestFlagsInFront holds that a name
behind flags is read as the name alone, tag for tag, and
TestNumberingBehindBrackets checks the numbering against the tags for
every name of tests.yaml and of TestStructure behind each kind of leading
bracket. The fuzz targets check the numbering of a name built whole and
of a hinted name as well.

TestStructureLinear times names made of what the stage reads, at two
lengths: the shapes it lists, and shapes made from every joiner and every
kind of bracket.

The zones read the tag at their anchor in one place, which gives a tag of
no type when the anchor is the end of the tags. A claim in front of a
closing bracket read past the end when a name was built with all of its
tags inside it. TestAnchorPastEnd builds every name of the tests and the
corpora that way, and the fuzz target every input.

Samples: nyaa-400 names 331 to 337, title 347 to 354, group 392 to 393.
nyaa-blind-140 names 27 to 36, title 63 to 81. 16 names leave the wrong
lines, all on the title: the titles with a bar or a slash, the
Evangelion titles and 'In This Corner (and Other Corners) of the World'.
One enters: '[Kametsu] Fate Stay Night: Unlimited Blade Works (TV)
(Prologue+S1+S2+Sunny Day)' keeps '(TV)' in its title until the next
commit reads it as what the release holds. Labelled floors: anitomy title
65 to 70 and group 92 to 93, habari title 70 to 74, anitogo title 65 to 71
and group 93 to 94. The habari season floor goes from 89 to the 91 it
measured before this change too.

tests.yaml: 'Mezzo(DSA)' is the title of '[RaX]Mezzo(DSA)_-_05' (was
'Mezzo' with 'DSA' unused), and 'Attack on Titan' and 'Shuumatsu no Harem'
are other titles and no unused words. Two names are new.
@zze0s
zze0s force-pushed the feat/anime-titles branch from 56eb8e2 to 78e3776 Compare November 18, 2026 16:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant