feat(filters): support daily shows (#1462)

* feat(database): Add month, day columns to release table

* feat(database): Add month, day columns to postgres release table

* feat(filters): support daily show format

* feat(filters): check smart episode daily

* fix(tests): rss

* feat(filters): add daily shows elements to form

* enhancement(web): minimize html in MoviesAndTV tab

* feat(filters): smart episode check proper and repack

* feat(filters): smart episode do not allow multiple latest

* feat(filters): smart episode check group with repack

* feat(filters): smart episode allow multiple current releases

---------

Co-authored-by: s0up4200 <soup@r4tio.dev>
Co-authored-by: ze0s <43699394+zze0s@users.noreply.github.com>
Co-authored-by: martylukyy <35452459+martylukyy@users.noreply.github.com>
This commit is contained in:
kenstir 2024-05-15 10:38:10 -04:00 committed by GitHub
parent 2a3dcfbf05
commit 4fceccd611
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
15 changed files with 270 additions and 56 deletions

View file

@ -62,6 +62,22 @@ const (
FilterMaxDownloadsEver FilterMaxDownloadsUnit = "EVER"
)
type SmartEpisodeParams struct {
Title string
Season int
Episode int
Year int
Month int
Day int
Repack bool
Proper bool
Group string
}
func (p *SmartEpisodeParams) IsDailyEpisode() bool {
return p.Year != 0 && p.Month != 0 && p.Day != 0
}
type FilterQueryParams struct {
Sort map[string]string
Filters struct {
@ -106,6 +122,8 @@ type Filter struct {
MatchOther []string `json:"match_other,omitempty"`
ExceptOther []string `json:"except_other,omitempty"`
Years string `json:"years,omitempty"`
Months string `json:"months,omitempty"`
Days string `json:"days,omitempty"`
Artists string `json:"artists,omitempty"`
Albums string `json:"albums,omitempty"`
MatchReleaseTypes []string `json:"match_release_types,omitempty"` // Album,Single,EP
@ -215,6 +233,8 @@ type FilterUpdate struct {
MatchOther *[]string `json:"match_other,omitempty"`
ExceptOther *[]string `json:"except_other,omitempty"`
Years *string `json:"years,omitempty"`
Months *string `json:"months,omitempty"`
Days *string `json:"days,omitempty"`
Artists *string `json:"artists,omitempty"`
Albums *string `json:"albums,omitempty"`
MatchReleaseTypes *[]string `json:"match_release_types,omitempty"` // Album,Single,EP
@ -309,6 +329,8 @@ func (f *Filter) Sanitize() error {
}
f.Years = sanitize.FilterString(f.Years)
f.Months = sanitize.FilterString(f.Months)
f.Days = sanitize.FilterString(f.Days)
f.Artists = sanitize.FilterString(f.Artists)
f.Albums = sanitize.FilterString(f.Albums)
@ -460,6 +482,14 @@ func (f *Filter) CheckFilter(r *Release) ([]string, bool) {
f.addRejectionF("year not matching. got: %d want: %v", r.Year, f.Years)
}
if f.Months != "" && !containsIntStrings(r.Month, f.Months) {
f.addRejectionF("month not matching. got: %d want: %v", r.Month, f.Months)
}
if f.Days != "" && !containsIntStrings(r.Day, f.Days) {
f.addRejectionF("day not matching. got: %d want: %v", r.Day, f.Days)
}
if f.MatchCategories != "" {
var categories []string
categories = append(categories, r.Categories...)

View file

@ -1340,6 +1340,44 @@ func TestFilter_CheckFilter(t *testing.T) {
},
want: true,
},
{
name: "match_daily",
fields: &Release{
TorrentName: "Daily talk show 2022 04 20 Someone 1080p WEB-DL h264-GROUP",
Category: "TV",
Uploader: "Uploader1",
},
args: args{
filter: Filter{
Enabled: true,
MatchCategories: "*tv*",
Shows: "Daily talk show",
Years: "2022",
Months: "04",
Days: "20",
},
},
want: true,
},
{
name: "daily_dont_match",
fields: &Release{
TorrentName: "Daily talk show 2022 04 20 Someone 1080p WEB-DL h264-GROUP",
Category: "TV",
Uploader: "Uploader1",
},
args: args{
filter: Filter{
Enabled: true,
MatchCategories: "*tv*",
Shows: "Daily talk show",
Years: "2022",
Months: "05",
},
rejections: []string{"month not matching. got: 4 want: 05"},
},
want: false,
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
@ -1911,6 +1949,8 @@ func TestFilter_CheckFilter1(t *testing.T) {
MatchHDR: tt.fields.MatchHDR,
ExceptHDR: tt.fields.ExceptHDR,
Years: tt.fields.Years,
Months: tt.fields.Months,
Days: tt.fields.Days,
Artists: tt.fields.Artists,
Albums: tt.fields.Albums,
MatchReleaseTypes: tt.fields.MatchReleaseTypes,

View file

@ -12,6 +12,7 @@ import (
"net/http"
"net/http/cookiejar"
"os"
"slices"
"strconv"
"strings"
"time"
@ -35,7 +36,7 @@ type ReleaseRepo interface {
GetIndexerOptions(ctx context.Context) ([]string, error)
Stats(ctx context.Context) (*ReleaseStats, error)
Delete(ctx context.Context, req *DeleteReleaseRequest) error
CanDownloadShow(ctx context.Context, title string, season int, episode int) (bool, error)
CheckSmartEpisodeCanDownload(ctx context.Context, p *SmartEpisodeParams) (bool, error)
UpdateBaseURL(ctx context.Context, indexer string, oldBaseURL, newBaseURL string) error
GetActionStatus(ctx context.Context, req *GetReleaseActionStatusRequest) (*ReleaseActionStatus, error)
@ -68,6 +69,8 @@ type Release struct {
Season int `json:"season"`
Episode int `json:"episode"`
Year int `json:"year"`
Month int `json:"month"`
Day int `json:"day"`
Resolution string `json:"resolution"`
Source string `json:"source"`
Codec []string `json:"codec"`
@ -316,10 +319,14 @@ func (r *Release) ParseString(title string) {
r.Codec = rel.Codec
r.Container = rel.Container
r.HDR = rel.HDR
r.Other = rel.Other
r.Artists = rel.Artist
r.Language = rel.Language
r.Other = rel.Other
r.Proper = slices.Contains(r.Other, "PROPER")
r.Repack = slices.Contains(r.Other, "REPACK")
if r.Title == "" {
r.Title = rel.Title
}
@ -334,6 +341,12 @@ func (r *Release) ParseString(title string) {
if r.Year == 0 {
r.Year = rel.Year
}
if r.Month == 0 {
r.Month = rel.Month
}
if r.Day == 0 {
r.Day = rel.Day
}
if r.Group == "" {
r.Group = rel.Group