feat: look for fanart by width
All checks were successful
build / build (push) Successful in 2m3s

This commit is contained in:
Viktor Varland 2025-04-05 11:21:35 +02:00
parent a53dbb0bec
commit 02ebcbc3d6
Signed by: varl
GPG key ID: 7459F0B410115EE8
2 changed files with 23 additions and 2 deletions

View file

@ -56,6 +56,7 @@ func Generate(outDir string, title string, dryRun bool) {
show := models.LoadShow(path)
nfo.WriteShowInfo(show, filepath.Join(showDir, "tvshow.nfo"))
showBanner(show, showDir)
showFanart(show, showDir)
case season.MatchString(path):
ep := models.LoadEpisode(path)
nfo.WriteEpisodeNFO(ep, path)
@ -126,3 +127,20 @@ func showBanner(show models.Show, showDir string) {
}
}
}
func showFanart(show models.Show, showDir string) {
c := models.Thumbnail{}
for index, thumb := range show.Thumbnails {
log.Println(index, thumb)
if thumb.Width > c.Width {
log.Println("found fanart candidate", thumb)
c = thumb
}
}
dl.Fetch(dl.Download{
Url: c.Url,
OutDir: showDir,
Name: "fanart.jpg",
})
}

View file

@ -27,8 +27,11 @@ type Show struct {
}
type Thumbnail struct {
Url string `json:"url" xml:"-"`
Id string `json:"id" xml:"-"`
Url string `json:"url" xml:"-"`
Id string `json:"id" xml:"-"`
Resolution string `json:"resolution" xml:"-"`
Height int32 `json:"height" xml:"-"`
Width int32 `json:"width" xml:"-"`
}
func LoadShow(info_path string) Show {