Skip to content

Commit

Permalink
Fix Equivalent to --show-path in config file #62
Browse files Browse the repository at this point in the history
ShowPath field can be added in config.json file. When given, Destinaton field is ignored.
  • Loading branch information
simulot committed Feb 10, 2021
1 parent e9165d3 commit 7e5f07e
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 9 deletions.
8 changes: 5 additions & 3 deletions cmd/aspiratv/config.go
Expand Up @@ -22,7 +22,7 @@ func (a *app) Initialize(cmd string) {
a.logger.Fatal().Printf("[Initialize] %s", err)
}
// Check and normalize configuration file
a.Config.Check()
a.Check(&a.Config)
}

// Check ffmpeg presence
Expand Down Expand Up @@ -113,7 +113,7 @@ func (a *app) ReadConfig(configFile string) error {
}

// Check the configuration or die
func (c *config) Check() {
func (a *app) Check(c *config) {

// Expand paths
for d, p := range c.Destinations {
Expand All @@ -126,7 +126,9 @@ func (c *config) Check() {
m.Title = strings.ToLower(m.Title)
if len(m.ShowRootPath) == 0 {
if s, ok := c.Destinations[m.Destination]; !ok {
log.Fatalf("Destination %q for show %q is not defined into section Destination of %q", m.Destination, m.Show, c.ConfigFile)
if m.ShowRootPath == "" {
a.logger.Fatal().Printf("Destination %q for show %q is not defined into section Destination of %q", m.Destination, m.Show, c.ConfigFile)
}
} else {
m.ShowRootPath = filepath.Join(s, providers.PathNameCleaner(m.Show))
}
Expand Down
8 changes: 4 additions & 4 deletions cmd/aspiratv/config.json
Expand Up @@ -11,17 +11,17 @@
"enabled": true
},
"gulli": {
"enabled": true
"enabled": false
},
"artetv": {
"enabled": true
"enabled": false
}
},
"WatchList": [
{
"Show": "La maison France 5",
"Show": "Les Lapins Crétins - Invasion",
"Provider": "francetv",
"Destination": "Séries"
"ShowPath": "${HOME}/Videos/DL/TEST/LAPINS"
}
]
}
2 changes: 1 addition & 1 deletion cmd/aspiratv/main.go
Expand Up @@ -403,7 +403,7 @@ showLoop:
if m.Match.ShowRootPath == "" {
m.ShowPath = path.Join(a.Config.Destinations[m.Match.Destination], nfo.FileNameCleaner(m.Metadata.GetMediaInfo().Showtitle))
} else {
m.ShowPath = m.Match.ShowRootPath
m.ShowPath = os.ExpandEnv(m.Match.ShowRootPath)
}

mediaBaseName := filepath.Base(m.Metadata.GetMediaPath(m.ShowPath))
Expand Down
2 changes: 1 addition & 1 deletion providers/matcher/matcher.go
Expand Up @@ -18,7 +18,7 @@ type MatchRequest struct {
MaxAgedDays int // Retrive media younger than MaxAgedDays when not zero

Destination string // Destination name when found
ShowRootPath string // Show/Movie path. For expisodes, actual season will append to the path
ShowRootPath string `json:"ShowPath"` // Show/Movie path. For expisodes, actual season will append to the path
RetentionDays int // Media retention time, when not zero the system will delete old files
TitleFilter Filter // ShowTitle or Episode title must match this regexp to be downloaded
TitleExclude Filter // ShowTitle and Episode title must not match this regexp to be downloaded
Expand Down

0 comments on commit 7e5f07e

Please sign in to comment.