Updated anime images tool

This commit is contained in:
Eduard Urbach 2018-02-23 11:00:37 +01:00
parent cc9b90a711
commit 0911881a87

View File

@ -25,11 +25,13 @@ var ticker = time.NewTicker(50 * time.Millisecond)
// Shell parameters // Shell parameters
var from int var from int
var to int var to int
var useCache bool
// Shell flags // Shell flags
func init() { func init() {
flag.IntVar(&from, "from", 0, "From index") flag.IntVar(&from, "from", 0, "From index")
flag.IntVar(&to, "to", 0, "To index") flag.IntVar(&to, "to", 0, "To index")
flag.BoolVar(&useCache, "cache", false, "Use cache")
flag.Parse() flag.Parse()
} }
@ -83,8 +85,12 @@ func work(anime *arn.Anime) error {
kitsuOriginal := fmt.Sprintf("https://media.kitsu.io/anime/poster_images/%s/original", anime.ID) kitsuOriginal := fmt.Sprintf("https://media.kitsu.io/anime/poster_images/%s/original", anime.ID)
system := ipo.System{ // Define the input sources
Inputs: []ipo.Input{ sources := []ipo.Input{}
// If we use the file system cache, start by searching those files
if useCache {
sources = append(sources,
&inputs.FileSystemImage{ &inputs.FileSystemImage{
URL: path.Join(originals, anime.ID+".png"), URL: path.Join(originals, anime.ID+".png"),
}, },
@ -97,19 +103,28 @@ func work(anime *arn.Anime) error {
&inputs.FileSystemImage{ &inputs.FileSystemImage{
URL: path.Join(originals, anime.ID+".gif"), URL: path.Join(originals, anime.ID+".gif"),
}, },
&inputs.NetworkImage{ )
URL: kitsuOriginal + anime.ImageExtension, }
},
&inputs.NetworkImage{ // Afterwards, use the network sources
URL: kitsuOriginal + ".png", sources = append(sources,
}, &inputs.NetworkImage{
&inputs.NetworkImage{ URL: kitsuOriginal + anime.ImageExtension,
URL: kitsuOriginal + ".jpg",
},
&inputs.NetworkImage{
URL: kitsuOriginal + ".jpeg",
},
}, },
&inputs.NetworkImage{
URL: kitsuOriginal + ".png",
},
&inputs.NetworkImage{
URL: kitsuOriginal + ".jpg",
},
&inputs.NetworkImage{
URL: kitsuOriginal + ".jpeg",
},
)
// Define the system
system := ipo.System{
Inputs: sources,
Outputs: []ipo.Output{ Outputs: []ipo.Output{
// Original // Original
&outputs.ImageFile{ &outputs.ImageFile{