Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
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
51 changes: 28 additions & 23 deletions cmd/upbrr/cli_options.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ type cliOptions struct {
EpisodeTitle string
ManualYear int
ManualDate string
UseSeasonEpisode bool
NoSeason bool
NoYear bool
NoAKA bool
Expand Down Expand Up @@ -197,6 +198,8 @@ func parseCLIOptions(args []string) (cliOptions, map[string]bool, []string, erro
fs.IntVar(&opts.ManualYear, "manual-year", 0, "Override release year")
fs.IntVar(&opts.ManualYear, "year", 0, "Override release year")
fs.StringVar(&opts.ManualDate, "daily", "", "Set daily episode air date")
fs.BoolVar(&opts.UseSeasonEpisode, "season-episode", false, "Use season/episode naming for daily releases")
fs.BoolVar(&opts.UseSeasonEpisode, "use-season-episode", false, "Use season/episode naming for daily releases")
fs.BoolVar(&opts.NoSeason, "no-season", false, "Remove season and episode from name")
fs.BoolVar(&opts.NoYear, "no-year", false, "Remove year from name")
fs.BoolVar(&opts.NoAKA, "no-aka", false, "Remove AKA from name")
Expand Down Expand Up @@ -467,6 +470,7 @@ func cliFlagAliases() map[string]string {
"manual-episode-title": "episode-title",
"met": "episode-title",
"year": "manual-year",
"use-season-episode": "season-episode",
"reg": "region",
"df": "descfile",
"pb": "desclink",
Expand Down Expand Up @@ -601,7 +605,7 @@ func cliHelpSections(name string) []helpSection {
{title: "Tracker IDs", names: []string{"ptp", "blu", "aither", "lst", "oe", "hdb", "btn", "bhd", "ulcx"}},
{title: "Release Overrides", names: []string{
"category", "type", "source", "resolution", "tag", "service", "distributor", "original-language",
"edition", "season", "episode", "episode-title", "manual-year", "daily", "region", "no-season", "no-year",
"edition", "season", "episode", "episode-title", "manual-year", "daily", "season-episode", "region", "no-season", "no-year",
"no-aka", "no-tag", "no-edition", "no-dub", "no-dual", "dual-audio",
}},
{title: "Metadata IDs", names: []string{"tmdb", "imdb", "mal", "tvdb", "tvmaze"}},
Expand Down Expand Up @@ -723,27 +727,28 @@ func buildCLIRequest(opts cliOptions, visited map[string]bool, paths []string, s
InteractionMode: opts.interactionMode(),
},
ReleaseNameOverrides: buildReleaseNameOverrides(visited, releaseOverrideInput{
Category: opts.Category,
Type: opts.Type,
Source: opts.Source,
Resolution: opts.Resolution,
Tag: opts.Tag,
Service: opts.Service,
Edition: opts.Edition,
Season: opts.Season,
Episode: opts.Episode,
EpisodeTitle: opts.EpisodeTitle,
ManualYear: opts.ManualYear,
ManualDate: opts.ManualDate,
NoSeason: opts.NoSeason,
NoYear: opts.NoYear,
NoAKA: opts.NoAKA,
NoTag: opts.NoTag,
NoEdition: opts.NoEdition,
NoDub: opts.NoDub,
NoDual: opts.NoDual,
DualAudio: opts.DualAudio,
Region: opts.Region,
Category: opts.Category,
Type: opts.Type,
Source: opts.Source,
Resolution: opts.Resolution,
Tag: opts.Tag,
Service: opts.Service,
Edition: opts.Edition,
Season: opts.Season,
Episode: opts.Episode,
EpisodeTitle: opts.EpisodeTitle,
ManualYear: opts.ManualYear,
ManualDate: opts.ManualDate,
UseSeasonEpisode: opts.UseSeasonEpisode,
NoSeason: opts.NoSeason,
NoYear: opts.NoYear,
NoAKA: opts.NoAKA,
NoTag: opts.NoTag,
NoEdition: opts.NoEdition,
NoDub: opts.NoDub,
NoDual: opts.NoDual,
DualAudio: opts.DualAudio,
Region: opts.Region,
}),
SkipDupeCheck: opts.SkipDupeCheck,
SkipDupeAsActual: opts.SkipDupeAsActual,
Expand Down Expand Up @@ -780,7 +785,7 @@ func buildCLIRequest(opts cliOptions, visited map[string]bool, paths []string, s
return api.Request{}, err
}
req.TrackerIDOverrides = trackerIDs
if visited["tmdb"] {
if visited["tmdb"] && !visited["category"] {
_, category, err := parseTMDBID(opts.TMDB)
if err != nil {
return api.Request{}, err
Expand Down
28 changes: 28 additions & 0 deletions cmd/upbrr/cli_options_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -571,6 +571,34 @@ func TestBuildCLIRequestTMDBCompatibilityParsing(t *testing.T) {
}
}

func TestBuildCLIRequestExplicitCategoryBeatsTMDBInference(t *testing.T) {
opts, visited, paths, err := parseCLIOptions([]string{"--category", "tv", "--tmdb", "movie/123", "movie.mkv"})
if err != nil {
t.Fatalf("parse: %v", err)
}
req, err := buildCLIRequest(opts, visited, paths, 4)
if err != nil {
t.Fatalf("build request: %v", err)
}
if req.ReleaseNameOverrides.Category == nil || *req.ReleaseNameOverrides.Category != "tv" {
t.Fatalf("expected explicit category to win, got %#v", req.ReleaseNameOverrides.Category)
}
}

func TestBuildCLIRequestUseSeasonEpisodeOverride(t *testing.T) {
opts, visited, paths, err := parseCLIOptions([]string{"--season-episode", "show.mkv"})
if err != nil {
t.Fatalf("parse: %v", err)
}
req, err := buildCLIRequest(opts, visited, paths, 4)
if err != nil {
t.Fatalf("build request: %v", err)
}
if req.ReleaseNameOverrides.UseSeasonEpisode == nil || !*req.ReleaseNameOverrides.UseSeasonEpisode {
t.Fatalf("expected use season episode override, got %#v", req.ReleaseNameOverrides.UseSeasonEpisode)
}
}

func TestParseCLIOptionsRejectsInvalidTMDBCompatibilityValue(t *testing.T) {
if _, _, _, err := parseCLIOptions([]string{"--tmdb", "movie/not-a-number", "movie.mkv"}); err == nil {
t.Fatal("expected invalid tmdb compatibility input to fail")
Expand Down
46 changes: 25 additions & 21 deletions cmd/upbrr/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -679,27 +679,28 @@ func resolveExportDBPath(configPath string, configProvided bool) (string, error)
}

type releaseOverrideInput struct {
Category string
Type string
Source string
Resolution string
Tag string
Service string
Edition string
Season string
Episode string
EpisodeTitle string
ManualYear int
ManualDate string
NoSeason bool
NoYear bool
NoAKA bool
NoTag bool
NoEdition bool
NoDub bool
NoDual bool
DualAudio bool
Region string
Category string
Type string
Source string
Resolution string
Tag string
Service string
Edition string
Season string
Episode string
EpisodeTitle string
ManualYear int
ManualDate string
UseSeasonEpisode bool
NoSeason bool
NoYear bool
NoAKA bool
NoTag bool
NoEdition bool
NoDub bool
NoDual bool
DualAudio bool
Region string
}

func buildReleaseNameOverrides(visited map[string]bool, input releaseOverrideInput) api.ReleaseNameOverrides {
Expand Down Expand Up @@ -740,6 +741,9 @@ func buildReleaseNameOverrides(visited map[string]bool, input releaseOverrideInp
if visited["daily"] {
overrides.ManualDate = stringPtr(input.ManualDate)
}
if visited["season-episode"] {
overrides.UseSeasonEpisode = boolPtr(input.UseSeasonEpisode)
}
if visited["no-season"] {
overrides.NoSeason = boolPtr(input.NoSeason)
}
Expand Down
Loading
Loading