Repository navigation
Conversation
The numbering of a name was two ints that could not tell zero from none, and seven accessors that each walked the tags their own way. Release.Numbering holds it as one value that a parse builds once: the scheme, the seasons, the episodes with a range as one Ep, and a second numbering apart from them in Alt. Season, Episode, Absolute, Shape and All read that value and nothing else, so they answer the same for a Numbering made by hand or decoded from a stored release. Readings stay as they were, with these exceptions. Episode gives the first episode of a batch: '[Grp] Show - 01-12' gives 1 and true, where the field was 0 for a range the range lexer read and 1 for 'S01E01-E03'. Shape tells one episode from several. A first episode 0 is an episode too: '[Grp] Show - 00 - 05' gives 0 and true, where the field skipped the 0 and was 5. No name of the sets compared writes that. The end of a range in front of a version is an episode and no second numbering: 'S04E29-31v2' is the episodes 29 to 31 and has no absolute episode. This is the rule of #72, and with it TestAbsoluteInvariants passes when the corpus is present. Absolute needs one regular episode and no more, so that it is the number Episode gives. The field was the first bare episode that is not 0, whatever stood beside it. Of the 71,636 names compared, 48 that write two episodes and no season lose their absolute episode: two episodes in one release ('Hellsing.E06.E07' gave 6), a batch written as two numbers ('- 07 - 09' gave 7), and a number of the title read as an episode ('Fairy Tail - 100 Years Quest - 07' gave 100). Three gain one, where the field took a year in the title for half an episode ('E01.1954.bis.1990' gives 1). Seasons are in the order the name writes them, and Season gives the first, as Series did: 'Season 2 + Season 1 OVA' gives 2. Frac is the digits after the point without the zeros that end them, so '12.50' is the half that '12.5' is. Episode, Absolute, Shape and All read the regular episodes. An Ep of another Kind is in Episodes for a caller that wants it. All is safe on any value: it counts the width of a range unsigned, and yields at most two pairs for each Ep and maxRangeFill beside them. The numbering is read in two passes over the tags. collect and the accessors called secondNumbering for every series tag, and it walks the name, so a name that is all numbering took quadratic time: '- 05 ' repeated to 128 KB parsed in 3.8 s and takes 81 ms now. TestNumberingLinear holds that for 15 shapes. The type of a release and Event depend on whether a tag writes an episode other than 0 in its first place, which the range of a batch does not. No rule over the Numbering gives that back for every name, so the parse keeps it in Release.numbered and neither changes. A release with no tags, made by hand or decoded, is read by its Numbering, where a range with no season is a batch. Event is the same before and after a JSON round trip for every name of tests.yaml and the corpora, which TestEventRoundTrip holds, and differs for a range written with an 'E' after a competition ('UFC 300 - E01-E03'). Volume, Contents and Batch are not set yet, and every Kind is EpRegular. tests.yaml gains the episode of nine names whose first episode stands in a range, each the first pair of the entry's own seriesEpisodes, and the name that the rule of #72 fixes. TestAccuracyLabelled compares every label of a row with the episodes of the release: one label with one episode, two with the ends of a batch. It read the first label alone, so it counted a batch right whose end the parser missed, and could not read a label with a fraction. The episode floors move to what it measures: anitomy 65, habari 65, anitogo 64. cmd/rls keeps its keys series, episode, has_season, has_episode, seasons and episodes, computed from the numbering, and adds a numbering object with the fields. BREAKING CHANGE: the fields Release.Series and Release.Episode, the methods Release.HasSeason, HasEpisode, Seasons, SeriesEpisodes, EpisodeRange, EpisodeSpans and Absolute, and the type EpisodeSpan are removed. With n := r.Numbering they become: r.Series season, _ := n.Season() r.Episode episode, _ := n.Episode(), which is the first episode of a range too, and 0 when 0 is written first r.HasSeason() _, ok := n.Season() r.HasEpisode() _, ok := n.Episode() r.Seasons() n.Seasons, in the order written and not sorted r.SeriesEpisodes() for season, episode := range n.All(), in the order written, with NoSeason where it gave season 0 r.EpisodeRange() First and Last of n.Episodes[0] when n.Shape() is ShapeEpisodes and it is one Ep r.EpisodeSpans() n.Episodes, and n.Alt for a second numbering EpisodeSpan Ep, with numbers where it held the digits of the name r.Absolute() n.Absolute(), which is false for more than one episode
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the
|
2 of 5 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Stacked on #76. First of two PRs for step 3: the type. The anime stage that fills the new fields follows.
A name's numbering was spread over two ints that cannot tell zero from none,
SeriesandEpisode, and seven accessors that each walk the tags their own way. qui has four different definitions of a season pack built on them, and both apps read season or episode 0 as "none". This PR replaces all of it with one value,Release.Numbering, built once per parse.String()onScheme,ShapeandEpKindis the only addition beyond the shape you approved. The CLI and logs have to print them.What a caller writes instead
n := r.Numberingr.Seriesseason, _ := n.Season()r.Episodeepisode, _ := n.Episode()r.HasSeason()_, ok := n.Season()r.HasEpisode()_, ok := n.Episode()r.Seasons()n.Seasons, in the order writtenr.SeriesEpisodes()for season, episode := range n.All(), withNoSeasonwhere it gave 0r.EpisodeRange()n.Episodes[0].Firstand.Lastwhenn.Shape() == ShapeEpisodesand it is oneEpr.EpisodeSpans(),EpisodeSpann.Episodesandn.Altr.Absolute()n.Absolute()Readings
This PR changes no reading on purpose, except where it has to. Before the old code was deleted its answers were recorded, and the new value was compared with them on every name of nine sets:
tests.yaml,nyaa.txt,sports.txt, the probe sets, the labelled fixtures, 54,766 real scene names and 7,719 real German names.Type,Event(), the season, "has a season", "has an episode", the seasons and the season and episode pairs are identical on every name. What differs:Episode()is the first episode of a range[shincaps] Nige Jouzu no Wakagimi - 01-12: 0 to 1S04E29-31v2is a rangeAbsolute()is none for a name that writes two episodesHellsing.E06.E07.UNCUT.GERMAN.2002.DVDRiP.SVCD-MB: 6 to noneAbsolute()for an episode with digits after a dotAngela.Merkel...E01.1954.bis.1990: none to 1Episode()when the first episode is 0[Grp] Show - 00 - 05: 5 to 0Fracdrops zeros at the end12.50is the half that12.5isEpisode()and a batch. The removed field was 0 for[Grp] Show - 01-12and 1 forShow.S01E01-E03. That was an artefact of how two lexers lay out their tags, and nothing in the name says it.Episode()gives the first episode in both. A caller that means "this release is one episode" asksShape() == ShapeEpisode.Absolute(). It is true when the name gives exactly one regular episode and no season, or a second numbering beside a seasoned episode (S23E19.Episode.1174). 21 of the 48 names that lose it are names where a title number was read as an episode (Fairy Tail - 100 Years Quest - 07gave 100). They were wrong before, and the anime stage reads them right.Kinds.
Episode(),Shape()andAll()describe regular episodes only. No parsed name has another kind yet. When the anime stage reads- OVA 02, it is anEpwith kindEpOVAinEpisodes, with noEpisode()andShapeNone. That follows decision 3.Nine
episode:expectations change intests.yaml, all the first case of the table. A script checks that each new value is the first pair of that entry's ownseriesEpisodes.Time and size
On master a long name that is all numbering is quadratic, because
collectand the accessors walk the tags for every series tag. The numbering is now built in two passes.- 05S2 - 04Title 17-26 - 01 ~ 08S01E01.TestNumberingLinearcovers 15 shapes.unsafe.Sizeof(Release{})goes from 752 to 840 bytes, and a kept release is 2.7 to 3.4% larger. A name with no numbering allocates nothing more. A name with it allocates one slice each for its seasons, episodes and second numbering. Benchmarks are 1.9% faster in the geometric mean.Downstream impact on autobrr and qui
This is the largest port of the stack. I did it in local worktrees of both apps, against this branch. Nothing is pushed there.
develop(bc56dcac)develop(9edcbede)TestRelease_Parse/parse_7,TestRelease_Hash/23, the1080ichange since v0.10.0)pkg/releases/numbering.go: 107 production reads ofSeries, 70 ofEpisode, 18 places that set them on a copy, 108 literals in tests.hasSingleSeasonandIsEpisodeRangeno longer walk tags. They readlen(Seasons) == 1andShape() == ShapeEpisodes.internal/domain/release.go. A small helper returns what the oldEpisodefield held, so no stored season, episode orNormalizedHashchanges over 71,632 names.Three behaviour questions come out of the port:
[SubsPlease] Dr. Stone S4 (01-24) [Batch]. The old tag walk dropped the(01-24).Numberingcannot tell that name fromS01E02-E04yet. The anime stage setsBatchfor it, which gives qui a way to keep it a pack.S02E17 ... (The Blue Orchestra Season 2)). Counting seasons and not tags looks right to me.[Grp] Show - 01-12stores episode 0 today, and the port keeps that. With plainEpisode()it would store 1 on 727 names, their hash would change, and a filter on episode 1 would match a batch.Other things a caller meets:
Seasonsis in the order written, whereSeasons()sorted. 13 names write their seasons out of rising order.Epis episode 0 of season 0. A caller that builds one by hand for a name with no season setsSeason: rls.NoSeason.Event()reads an unexported flag that a parse sets, so a release decoded from JSON can answer differently for one shape:UFC 300 - E01-E03 [1080p]is a show when parsed and an event after a round trip. The doc comment says so andTestEventRoundTrippins it.Compareranks a batch equal on episode with its first episode, where it ranked with releases that have none.episodekey goes from 0 to the first episode on the 727 batch names, and it gains anumberingobject. The other keys are identical on 71,636 names.Review
An independent review compared old and new answers with its own programs over 80,013 real names and 816 generated shapes with every hint. It confirmed the table above and found, all fixed in this commit:
All()could run without end on aNumberingdecoded from JSON with a huge range.Absolute()andEpisode()contradicted each other on- 00 - 05.TestAccuracyLabelledcounted a batch as right without checking its end. It scores both ends now, and halves. Theepisodefloors move to anitomy 65, habari 65, anitogo 64. No row moved because a reading changed: five batches and three half episodes count as right that the old scorer could not read, and four batches of which the parser reads only the first episode no longer count.Type of change
How has this been tested?
TestNumbering*keeps every case of the old 1,000 lines of tables, and adds invariants overtests.yamland the corpora: every pairAllyields lies inside anEp,ShapeisShapeEpisodeexactly for oneEpthat is no range,Absoluteis never inside a range. They also run in the fuzz target.sampleFloorsandprobeFailuresdo not move.go vet ./...,gofmt -l .with Go 1.26 and 1.27,go test ./...with the corpus present,go test -race ./..., thecmd/rlschecks and 60 s ofFuzzParseStringpass.TestAbsoluteInvariantspasses here, since the rule of fix(series): read the end of a range before a version as an episode #72 is carried in.Checklist
go fmtand the test suite passes locallytests.yamlfor any parsing changeAI disclosure
Yes, all of it. Claude Code (Claude Fable 5.2) wrote the type, the tests and the comparison. A second model reviewed it, and a third ported both apps in local worktrees.
BREAKING CHANGE: the fields
Release.SeriesandRelease.Episode, the methodsRelease.HasSeason,HasEpisode,Seasons,SeriesEpisodes,EpisodeRange,EpisodeSpansandAbsolute, and the typeEpisodeSpanare removed.Release.Numberingreplaces them.Numbering.Episode()gives the first episode of a batch where the field was 0.