Release list: filter by quality, codec, HDR, DV and language

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-10-20 20:30:12 +02:00
co-authored by Claude Sonnet 5.5
parent b34f88ef3e
commit 47b9459a5e
9 changed files with 131 additions and 27 deletions
+31 -1
View File
@@ -27,12 +27,16 @@ type Release struct {
FullSeason bool `json:"fullSeason"`
Quality struct {
Quality struct {
Name string `json:"name"`
Name string `json:"name"`
Resolution int `json:"resolution"`
} `json:"quality"`
} `json:"quality"`
Languages []struct {
Name string `json:"name"`
} `json:"languages"`
CustomFormats []struct {
Name string `json:"name"`
} `json:"customFormats"`
}
// QualityName returns the release's quality, e.g. "Bluray-1080p".
@@ -64,3 +68,29 @@ func (c *Client) Grab(ctx context.Context, r Release) error {
body := map[string]any{"guid": r.GUID, "indexerId": r.IndexerID}
return c.Do(ctx, http.MethodPost, "release", nil, body, nil)
}
// Attrs derives the filterable properties from what the release announces:
// its title, quality, custom formats and languages. Codec and HDR only show up
// when the uploader put them into the title.
func (r Release) Attrs() FileAttrs {
names := []string{r.Title, r.Quality.Quality.Name}
for _, cf := range r.CustomFormats {
names = append(names, cf.Name)
}
text := strings.Join(names, " ")
a := FileAttrs{Resolution: r.Quality.Quality.Resolution, Codec: codecOf(text)}
if a.Resolution == 0 {
if m := reRes.FindStringSubmatch(text); m != nil {
a.Resolution = atoi(m[1])
}
}
a.DV = reDV.MatchString(text)
a.HDR = reHDR.MatchString(text)
for _, l := range r.Languages {
if l.Name != "" {
a.Languages = append(a.Languages, l.Name)
}
}
return a
}