feat: skip banner and fanart dls if exists
All checks were successful
build / build (push) Successful in 1m54s
All checks were successful
build / build (push) Successful in 1m54s
This commit is contained in:
parent
02ebcbc3d6
commit
00d37fbb45
76
internal/metadata/art.go
Normal file
76
internal/metadata/art.go
Normal file
|
|
@ -0,0 +1,76 @@
|
||||||
|
package metadata
|
||||||
|
|
||||||
|
import (
|
||||||
|
"log"
|
||||||
|
"os"
|
||||||
|
"path/filepath"
|
||||||
|
"strings"
|
||||||
|
|
||||||
|
"git.meatbag.se/varl/subsyt/internal/dl"
|
||||||
|
"git.meatbag.se/varl/subsyt/internal/models"
|
||||||
|
)
|
||||||
|
|
||||||
|
func episodeImage(path string) {
|
||||||
|
if strings.Contains(path, "-thumb") {
|
||||||
|
log.Printf("thumbnail detected '%s'\n", path)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
thumb := strings.Replace(path, ".jpg", "-thumb.jpg", 1)
|
||||||
|
log.Printf("renaming thumbnail from '%s' to '%s'\n", path, thumb)
|
||||||
|
err := os.Rename(path, thumb)
|
||||||
|
if err != nil {
|
||||||
|
log.Printf("failed to rename '%s' to '%s\n'", path, thumb)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func showPoster(path string, show_dir string) {
|
||||||
|
poster := filepath.Join(show_dir, "poster.jpg")
|
||||||
|
log.Printf("renaming show image from '%s' to '%s'\n", path, poster)
|
||||||
|
err := os.Rename(path, poster)
|
||||||
|
if err != nil {
|
||||||
|
log.Printf("failed to rename '%s' to '%s\n'", path, poster)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func showBanner(show models.Show, showDir string) {
|
||||||
|
_, err := os.Stat(filepath.Join(showDir, "banner.jpg"))
|
||||||
|
if err == nil {
|
||||||
|
log.Printf("%s has a banner, skipping download\n", show.Title)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
for index, thumb := range show.Thumbnails {
|
||||||
|
log.Println(index, thumb)
|
||||||
|
if thumb.Id == "banner_uncropped" {
|
||||||
|
log.Println("found banner candidate")
|
||||||
|
dl.Fetch(dl.Download{
|
||||||
|
Url: thumb.Url,
|
||||||
|
OutDir: showDir,
|
||||||
|
Name: "banner.jpg",
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func showFanart(show models.Show, showDir string) {
|
||||||
|
_, err := os.Stat(filepath.Join(showDir, "fanart.jpg"))
|
||||||
|
if err == nil {
|
||||||
|
log.Printf("%s has fanart, skipping download\n", show.Title)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
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",
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
@ -8,7 +8,6 @@ import (
|
||||||
"regexp"
|
"regexp"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"git.meatbag.se/varl/subsyt/internal/dl"
|
|
||||||
"git.meatbag.se/varl/subsyt/internal/models"
|
"git.meatbag.se/varl/subsyt/internal/models"
|
||||||
"git.meatbag.se/varl/subsyt/internal/nfo"
|
"git.meatbag.se/varl/subsyt/internal/nfo"
|
||||||
)
|
)
|
||||||
|
|
@ -91,56 +90,3 @@ func Generate(outDir string, title string, dryRun bool) {
|
||||||
log.Println("failed to remove", err)
|
log.Println("failed to remove", err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func episodeImage(path string) {
|
|
||||||
if strings.Contains(path, "-thumb") {
|
|
||||||
log.Printf("thumbnail detected '%s'\n", path)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
thumb := strings.Replace(path, ".jpg", "-thumb.jpg", 1)
|
|
||||||
log.Printf("renaming thumbnail from '%s' to '%s'\n", path, thumb)
|
|
||||||
err := os.Rename(path, thumb)
|
|
||||||
if err != nil {
|
|
||||||
log.Printf("failed to rename '%s' to '%s\n'", path, thumb)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func showPoster(path string, show_dir string) {
|
|
||||||
poster := filepath.Join(show_dir, "poster.jpg")
|
|
||||||
log.Printf("renaming show image from '%s' to '%s'\n", path, poster)
|
|
||||||
err := os.Rename(path, poster)
|
|
||||||
if err != nil {
|
|
||||||
log.Printf("failed to rename '%s' to '%s\n'", path, poster)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func showBanner(show models.Show, showDir string) {
|
|
||||||
for index, thumb := range show.Thumbnails {
|
|
||||||
log.Println(index, thumb)
|
|
||||||
if thumb.Id == "banner_uncropped" {
|
|
||||||
log.Println("found banner candidate")
|
|
||||||
dl.Fetch(dl.Download{
|
|
||||||
Url: thumb.Url,
|
|
||||||
OutDir: showDir,
|
|
||||||
Name: "banner.jpg",
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
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",
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue