Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions accuracy_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -655,6 +655,12 @@ func TestAccuracySample(t *testing.T) {
var probeFailures = map[string]map[string]string{
"probes-title.json": {
"Series.7.The.Contenders.2001.DVDRip.x264-GRP": `series "The Contenders", group "GRP", seasons [7]`,
// fixSourceUHD joins the uhd to the group, which is still a source
// tag when it runs
"Movie.2020.UHD.2160p-WEB": `movie "Movie", tag UHD.WEB, group "WEB"`,
// the second walk of fixSourceUHD joins web sources only, and the tv
// source past the streaming service is left a bluray
"Show.S01E02.2160p.UHD.AMZN.HDTV.x265-GRP": `episode "Show", tag UHD.BluRay, group "GRP", seasons [1], episode 2`,
},
"probes-title-end.json": {
"Pardon.My.French.2021.1080p.WEB.h264-GRP": `movie "Pardon My", tag FRENCH, group "GRP"`,
Expand Down
92 changes: 70 additions & 22 deletions parse.go
Original file line number Diff line number Diff line change
Expand Up @@ -835,37 +835,78 @@ func (b *TagBuilder) start(r *Release, i int) int {
return i
}

// fixSourceUHD fixes a bare uhd source tag next to a web source tag with only
// resolution, frame rate, hdr and bit depth tags between, as the uhd marks a
// web source and not a bluray (ie, 'Movie.2022.UHD.2160p.WEB...',
// fixSourceUHD fixes a bare uhd source tag next to a web source tag, as the
// uhd marks a web source and not a bluray (ie, 'Movie.2022.UHD.2160p.WEB...',
// 'Movie.2022.2160p.WEB.UHD...' or 'Event.2026.UHD.2160p50.HLG.WEB...'). The
// first of the pair is changed, as the first source tag is collected.
//
// Next to a tv source the uhd is the resolution of a broadcast (ie,
// first of the pair is changed, as the first source tag is collected. Next to
// a tv source the uhd is the resolution of a broadcast (ie,
// 'Show.S01.UHD.HDTV...'), and the tv source is the one to collect.
//
// The walk first passes only the tags that describe the picture. When it
// finds no web or tv source that way, it walks again past the streaming
// service, the cut, the edition, the language and the other tags too, and
// joins a web source there ('Movie.2020.2160p.UHD.AMZN.WEB-DL...',
// 'Show.S01E02.2160p.UHD.NF.WEBRip...', 'Movie.2020.2160p.UHD.HYBRID.WEB-DL...').
// So a source the first walk reaches is read as it was, and the second walk
// only adds the joins the first could not make. A tv source it reaches is
// left as it is ('Show.S01.UHD.AMZN.HDTV...' stays a bluray, as before). It is not taken in a name
// that names a disc: a remux is taken from a disc, as remuxSource reads a
// remux that names no source, and a full disc or a bluray is one, so the web
// words of such a name are those of a track or of a hybrid
// ('Movie.2020.UHD.2160p.REMUX.DV.HDR10.HYBRID.AMZN.WEB-DL...').
//
// Two joins of the second walk are known and left as they are. A web group
// behind the streaming service is still a source tag here, and is joined
// ('Movie.2020.2160p.UHD.NF-WEB' is a uhd web). A uhd that is a word of the
// title of a record or a game joins across a language or an edition word
// ('Game.UHD.German.Web-GRP' gives a uhd web, and gave a bluray before; both
// are wrong).
func (b *TagBuilder) fixSourceUHD(r *Release) {
for i := range r.end {
if !r.tags[i].Is(TagTypeSource) || !strings.EqualFold(r.tags[i].Text(), "UHD") {
continue
}
for _, inc := range []int{1, -1} {
j, s := nextSource(r.tags[:r.end], i, inc)
switch {
case j == -1:
continue
case s == "WEB", s == "WEB-DL", s == "WEBRiP":
k := min(i, j)
r.tags[k] = NewTag(TagTypeSource, r.tags[i].f, []byte(r.tags[k].v[0]), []byte("UHD."+s))
case strings.Contains(s, "TV"):
r.tags[i] = r.tags[i].as(TagTypeResolution, b.resolutionf)
default:
continue
walks:
for _, wide := range []bool{false, true} {
if wide && namesDisc(r.tags[:r.end]) {
break
}
for _, inc := range []int{1, -1} {
j, s := nextSource(r.tags[:r.end], i, inc, wide)
switch {
case j == -1:
continue
case s == "WEB", s == "WEB-DL", s == "WEBRiP":
k := min(i, j)
r.tags[k] = NewTag(TagTypeSource, r.tags[i].f, []byte(r.tags[k].v[0]), []byte("UHD."+s))
case !wide && strings.Contains(s, "TV"):
r.tags[i] = r.tags[i].as(TagTypeResolution, b.resolutionf)
default:
continue
}
break walks
}
break
}
}
}

// namesDisc reports whether tags name a disc: a remux, a full disc ('BDMV')
// or a bluray source other than a bare uhd ('BluRay', 'UHD.BluRay', 'BDRiP',
// 'BRDRip', 'BDSCR').
func namesDisc(tags []Tag) bool {
return slices.ContainsFunc(tags, func(tag Tag) bool {
switch {
case tag.Is(TagTypeOther):
o := tag.Other()
return isRemux(o) || o == "BDMV"
case tag.Is(TagTypeSource) && !strings.EqualFold(tag.Text(), "UHD"):
s := strings.ToUpper(tag.Source())
return strings.Contains(s, "BLURAY") || strings.HasPrefix(s, "BD") || strings.HasPrefix(s, "BRD") || strings.HasPrefix(s, "UHD.BD")
}
return false
})
}

// fixMusic fixes music tags. Changes single cbr audio tag to the cbr container
// (ie, a comic) tag, changes 16bit arch tag to audio tag, and a single episode
// in a name with a music exclusive audio tag and no resolution to text.
Expand Down Expand Up @@ -2205,10 +2246,17 @@ func peek(tags []Tag, i int, types ...TagType) bool {

// nextSource returns the index and value of the source tag next to i in the
// direction of inc, when only whitespace, delimiters and resolution, frame
// rate, hdr and bit depth tags are between them, or -1.
func nextSource(tags []Tag, i, inc int) (int, string) {
// rate, hdr and bit depth tags are between them, or -1. When wide, collection,
// cut, edition, language and other tags may be between too: these are the
// tags a name writes in front of its source ('UHD.AMZN.WEB-DL',
// 'UHD.HYBRID.WEB-DL', 'UHD.MULTi.WEB-DL'). The codec, audio and channels
// stand behind the source and stop the walk, as past them a web word is the
// group ('UHD.x265-WEB') or the source of a track ('UHD.HEVC.DTS-HD.MA.7.1.
// AMZN.WEB-DL.Audio').
func nextSource(tags []Tag, i, inc int, wide bool) (int, string) {
for i += inc; 0 <= i && i < len(tags); i += inc {
if tags[i].Is(TagTypeWhitespace, TagTypeDelim, TagTypeResolution, TagTypeFrameRate, TagTypeHDR, TagTypeBitDepth) {
if tags[i].Is(TagTypeWhitespace, TagTypeDelim, TagTypeResolution, TagTypeFrameRate, TagTypeHDR, TagTypeBitDepth) ||
wide && tags[i].Is(TagTypeCollection, TagTypeCut, TagTypeEdition, TagTypeLanguage, TagTypeOther) {
continue
}
if tags[i].Is(TagTypeSource) {
Expand Down
11 changes: 9 additions & 2 deletions testdata/corpus/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ right, and the others were written from the name.
| `labelled/habari-known-failures.json` | 11 | habari `test/failing.json` | yes, with reasons |
| `labelled/nyaa-400.json` | 400 | a random sample of `nyaa.txt`, read by hand | yes, by us |
| `labelled/nyaa-blind-140.json` | 140 | names of `nyaa.txt` that two prototypes read differently, judged blind | yes, by us |
| `labelled/probes-title.json` | 103 | scene names built by hand, a vocabulary word anywhere in the title | yes, by us |
| `labelled/probes-title-end.json` | 60 | scene names built by hand, a vocabulary word as the last word of the title | yes, by us |
| `labelled/probes-title.json` | 112 | scene names built by hand, a vocabulary word anywhere in the title | yes, by us |
| `labelled/probes-title-end.json` | 62 | scene names built by hand, a vocabulary word as the last word of the title | yes, by us |
| `labelled/probes-brackets.json` | 368 | names with a bracket that no fansub group wrote, built by hand or real | yes, by us |
| `nyaa.txt` | 13,215 | nyaa.si listing and search pages, categories 1_2 / 1_3 / 1_4 | no |
| `sports.txt` | 2,505 | predb SPORTS and TV sections, plus documented tracker conventions | no |
Expand Down Expand Up @@ -164,6 +164,13 @@ film or a set of episodes. A name whose meaning is open in more than that is no
When you add a tag row or a rule that touches title words, add probes for it: movies, episodes,
packs, with the word first, inside and last.

The rows around a bare `UHD`, one that the lexer reads as a source of its own and that a web
source stands behind or in front of, hold the source that `UHD` must not give. A web release with `Web` in
its title or a streaming service between gives no `UHD.BluRay` (`The.Web.S01E02.2160p.UHD.NF.
WEBRip`), and a disc or a `WEB` group gives no web source (`Movie.2020.UHD.2160p.REMUX.HEVC.TrueHD.
Atmos.7.1.AMZN.WEB-DL.DDP5.1.Audio`, `Movie.2020.2160p.UHD.x265-WEB`). Most of them have no
vocabulary word in the title, and their `no_tag` is that source.

`labelled/probes-brackets.json` holds the look-alikes of a fansub name: names with a bracket that
no fansub group wrote. They are films, shows, records, books, games and applications in the shapes
of YTS, QxR, TGx, a Plex library and a tracker listing, with a word or a number that the structure
Expand Down
4 changes: 3 additions & 1 deletion testdata/corpus/labelled/probes-title-end.json
Original file line number Diff line number Diff line change
Expand Up @@ -58,5 +58,7 @@
{"file_name": "Life.Uncut.S01E01.720p.WEB.h264-GRP", "type": "episode", "title": "Life Uncut", "no_tag": "Uncut"},
{"file_name": "Family.Extended.2015.1080p.WEB.h264-GRP", "type": "movie", "title": "Family Extended", "no_tag": "Extended.Cut"},
{"file_name": "Total.Internal.2016.720p.WEB.h264-GRP", "type": "movie", "title": "Total Internal", "no_tag": "INTERNAL"},
{"file_name": "My.Dubbed.Life.2020.1080p.WEB.h264-GRP", "type": "movie", "title": "My Dubbed Life", "no_tag": "DUBBED"}
{"file_name": "My.Dubbed.Life.2020.1080p.WEB.h264-GRP", "type": "movie", "title": "My Dubbed Life", "no_tag": "DUBBED"},
{"file_name": "Charlottes.Web.2006.2160p.UHD.AMZN.WEB-DL.DDP5.1.H.265-GRP", "type": "movie", "title": "Charlottes Web", "no_tag": ["WEB", "UHD.BluRay"]},
{"file_name": "The.Web.S01E02.2160p.UHD.NF.WEBRip.x265-GRP", "type": "episode", "title": "The Web", "no_tag": ["WEB", "UHD.BluRay"]}
]
11 changes: 10 additions & 1 deletion testdata/corpus/labelled/probes-title.json
Original file line number Diff line number Diff line change
Expand Up @@ -101,5 +101,14 @@
{"file_name": "The Italian Job (1969) [Remastered] 1080p BluRay x265 10bit DTS-HD MA 2.0-GRP", "type": "movie", "title": "The Italian Job", "no_tag": "iTALiAN"},
{"file_name": "Extended Family (2023) S01E01 (1080p AMZN WEB-DL x265 HEVC 10bit EAC3 5.1 GRP)", "type": "episode", "title": "Extended Family", "no_tag": "Extended.Cut"},
{"file_name": "[GRP] The Real Housewives of Beverly Hills - 13x01 (1080p WEB h264)", "type": "episode", "title": "The Real Housewives of Beverly Hills", "no_tag": "REAL"},
{"file_name": "Uncut Gems 2019 2160p NF WEB-DL DDP5.1 Atmos DV HEVC-GRP", "type": "movie", "title": "Uncut Gems", "no_tag": "Uncut"}
{"file_name": "Uncut Gems 2019 2160p NF WEB-DL DDP5.1 Atmos DV HEVC-GRP", "type": "movie", "title": "Uncut Gems", "no_tag": "Uncut"},
{"file_name": "Web.of.Make.Believe.S01E01.2160p.UHD.NF.WEBRip.x265-GRP", "type": "episode", "title": "Web of Make Believe", "no_tag": ["WEB", "UHD.BluRay"]},
{"file_name": "Movie.2020.2160p.UHD.x265-WEB", "type": "movie", "title": "Movie", "no_tag": ["WEB", "UHD.WEB"]},
{"file_name": "Movie.2020.2160p.AMZN.WEB-DL.UHD.x265-GRP", "type": "movie", "title": "Movie", "no_tag": "UHD.BluRay"},
{"file_name": "Movie.2020.UHD.2160p-WEB", "type": "movie", "title": "Movie", "no_tag": ["WEB", "UHD.WEB"]},
{"file_name": "Movie.2020.UHD.2160p.REMUX.HEVC.TrueHD.Atmos.7.1.AMZN.WEB-DL.DDP5.1.Audio-GRP", "type": "movie", "title": "Movie", "no_tag": "UHD.WEB-DL"},
{"file_name": "Movie.2020.2160p.UHD.REMUX.DV.HDR10.HYBRID.AMZN.WEB-DL-GRP", "type": "movie", "title": "Movie", "no_tag": "UHD.WEB-DL"},
{"file_name": "Movie.2020.2160p.UHD.BDMV.HYBRID.AMZN.WEB-DL-GRP", "type": "movie", "title": "Movie", "no_tag": "UHD.WEB-DL"},
{"file_name": "Movie.2020.2160p.UHD.HYBRID.WEB-DL.BluRay.x265-GRP", "type": "movie", "title": "Movie", "no_tag": "UHD.WEB-DL"},
{"file_name": "Show.S01E02.2160p.UHD.AMZN.HDTV.x265-GRP", "type": "episode", "title": "Show", "no_tag": "UHD.BluRay"}
]
159 changes: 159 additions & 0 deletions tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1545,6 +1545,19 @@
year: 2024
codec: "H.264"
group: "GRP"
"Movie (2020) [UHD - WEB-DL]":
type: "movie"
title: "Movie"
source: "UHD.WEB-DL"
year: 2020
"Movie.2020.UHD.AMZN.WEB.x265-GRP":
type: "movie"
title: "Movie"
source: "UHD.WEB"
collection: "AMZN"
year: 2020
codec: "x265"
group: "GRP"
"Movie 2020 1080p BluRay x264 + Bonus":
type: "movie"
title: "Movie"
Expand Down Expand Up @@ -1627,12 +1640,27 @@
other: "REPACK"
group: "GRP"
site: "TGx"
"Movie (2020) 2160p UHD - WEB-DL x265":
type: "movie"
title: "Movie"
source: "UHD.WEB-DL"
resolution: "2160p"
year: 2020
codec: "x265"
"Movie (2020) [2160p HDR10+]":
type: "movie"
title: "Movie"
resolution: "2160p"
year: 2020
dynamicRange: "HDR10+"
"Movie.2020.2160p.UHD.HDR10-WEBRip.x265":
type: "movie"
title: "Movie"
source: "UHD.WEBRiP"
resolution: "2160p"
year: 2020
codec: "x265"
dynamicRange: "HDR10"
"Movie.2020.2160p.WEB-DL.H.265.DD+":
type: "movie"
title: "Movie"
Expand All @@ -1650,6 +1678,127 @@
codec: "H.265"
dynamicRange: "HDR10+"
ext: "mkv"
"Movie 2020 2160p UHD AMZN WEB-DL x265-GRP":
type: "movie"
title: "Movie"
source: "UHD.WEB-DL"
resolution: "2160p"
collection: "AMZN"
year: 2020
codec: "x265"
group: "GRP"
"Movie.2020.2160p.UHD-HDR.WEB-DL.x265-GRP":
type: "movie"
title: "Movie"
source: "UHD.WEB-DL"
resolution: "2160p"
year: 2020
codec: "x265"
dynamicRange: "HDR"
group: "GRP"
"Movie.2020.2160p.UHD.60fps.WEB-DL.x265-GRP":
type: "movie"
title: "Movie"
source: "UHD.WEB-DL"
resolution: "2160p"
framerate: "60fps"
year: 2020
codec: "x265"
group: "GRP"
"Movie.2020.2160p.UHD.AMZN.WEB-DL.DDP5.1.HDR.H.265-GRP":
type: "movie"
title: "Movie"
source: "UHD.WEB-DL"
resolution: "2160p"
collection: "AMZN"
year: 2020
codec: "H.265"
dynamicRange: "HDR"
audio: "DDP"
channels: "5.1"
group: "GRP"
"Movie.2020.2160p.UHD.Directors.Cut.WEB-DL.x265-GRP":
type: "movie"
title: "Movie"
source: "UHD.WEB-DL"
resolution: "2160p"
year: 2020
codec: "x265"
cut: "Directors.Cut"
group: "GRP"
"Movie.2020.2160p.UHD.GERMAN.WEB-DL.x265-GRP":
type: "movie"
title: "Movie"
source: "UHD.WEB-DL"
resolution: "2160p"
year: 2020
codec: "x265"
language: "GERMAN"
group: "GRP"
"Movie.2020.2160p.UHD.HYBRID.WEB-DL.DV.HDR.H.265-GRP":
type: "movie"
title: "Movie"
source: "UHD.WEB-DL"
resolution: "2160p"
year: 2020
codec: "H.265"
dynamicRange: "DV HDR"
other: "HYBRiD"
group: "GRP"
"Movie.2020.2160p.UHD.MULTi.DSNP.WEB-DL.x265-GRP":
type: "movie"
title: "Movie"
source: "UHD.WEB-DL"
resolution: "2160p"
collection: "DSNP"
year: 2020
codec: "x265"
language: "MULTi"
group: "GRP"
"Movie.2020.2160p.UHD.Open.Matte.WEB-DL.x265-GRP":
type: "movie"
title: "Movie"
source: "UHD.WEB-DL"
resolution: "2160p"
year: 2020
codec: "x265"
edition: "Open.Matte"
group: "GRP"
"Movie.2020.2160p.UHD.PROPER.WEB-DL.x265-GRP":
type: "movie"
title: "Movie"
source: "UHD.WEB-DL"
resolution: "2160p"
year: 2020
codec: "x265"
other: "PROPER"
group: "GRP"
"Movie.2020.2160p.WEB-DL-UHD.x265-GRP":
type: "movie"
title: "Movie"
source: "UHD.WEB-DL"
resolution: "2160p"
year: 2020
codec: "x265"
group: "GRP"
"Movie.2020.2160p.WEB.UHD.AMZN.WEB-DL.x265-GRP":
type: "movie"
title: "Movie"
source: "UHD.WEB"
resolution: "2160p"
collection: "AMZN"
year: 2020
codec: "x265"
group: "GRP"
"Movie_2020_2160p_UHD_AMZN_WEB-DL_x265-GRP":
type: "movie"
title: "Movie"
source: "UHD.WEB-DL"
resolution: "2160p"
collection: "AMZN"
year: 2020
codec: "x265"
group: "GRP"
"Movie.2022.1080p.BluRay.x264.8bit-GRP":
type: "movie"
title: "Movie"
Expand Down Expand Up @@ -5898,6 +6047,16 @@
episode: 2
codec: "H.264"
group: "SACD"
"Show.S01E02.2160p.UHD.NF.WEBRip.x265-GRP":
type: "episode"
title: "Show"
source: "UHD.WEBRiP"
resolution: "2160p"
collection: "NF"
series: 1
episode: 2
codec: "x265"
group: "GRP"
"Show.S01E02.AKA.Other.Title.1080p.WEB.H264-GRP":
type: "episode"
title: "Show"
Expand Down
Loading