51 lines
1.1 KiB
Go
Raw Normal View History

2018-04-12 17:05:05 +00:00
package main
import (
"flag"
"path"
"github.com/animenotifier/arn"
)
// Shell parameters
2018-10-31 09:13:18 +00:00
var objectType string
var objectID string
2018-04-12 17:05:05 +00:00
// Shell flags
func init() {
2018-10-31 09:13:18 +00:00
flag.StringVar(&objectType, "type", "all", "all | anime | character")
flag.StringVar(&objectID, "id", "", "ID of the notify.moe anime/character you want to refresh")
2018-04-12 17:05:05 +00:00
flag.Parse()
}
// InvokeShellArgs ...
func InvokeShellArgs() bool {
2018-10-31 09:13:18 +00:00
if objectID != "" {
switch objectType {
case "anime":
anime, err := arn.GetAnime(objectID)
arn.PanicOnError(err)
2018-04-12 17:05:05 +00:00
2018-10-31 09:13:18 +00:00
if anime.GetMapping("myanimelist/anime") == "" {
panic("No MAL ID")
}
readAnimeFile(path.Join(arn.Root, "jobs", "mal-download", "anime", anime.GetMapping("myanimelist/anime")+".html.gz"))
case "character":
character, err := arn.GetCharacter(objectID)
arn.PanicOnError(err)
if character.GetMapping("myanimelist/character") == "" {
panic("No MAL ID")
}
2018-04-12 17:05:05 +00:00
2018-10-31 09:13:18 +00:00
readCharacterFile(path.Join(arn.Root, "jobs", "mal-download", "character", character.GetMapping("myanimelist/character")+".html.gz"))
2018-04-12 17:05:05 +00:00
}
return true
}
return false
}