2018-04-12 17:05:05 +00:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"flag"
|
|
|
|
|
2019-06-03 09:32:43 +00:00
|
|
|
"github.com/animenotifier/notify.moe/arn"
|
2018-04-12 17:05:05 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
// Shell parameters
|
2018-10-31 23:23:41 +00:00
|
|
|
var objectType string
|
|
|
|
var objectID string
|
2018-04-12 17:05:05 +00:00
|
|
|
|
|
|
|
// Shell flags
|
|
|
|
func init() {
|
2018-10-31 23:23:41 +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 23:23:41 +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 23:23:41 +00:00
|
|
|
if anime.GetMapping("myanimelist/anime") == "" {
|
|
|
|
panic("No MAL ID")
|
|
|
|
}
|
|
|
|
|
|
|
|
syncAnime(anime, anime.GetMapping("myanimelist/anime"))
|
|
|
|
|
|
|
|
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 23:23:41 +00:00
|
|
|
syncCharacter(character, character.GetMapping("myanimelist/character"))
|
2018-04-12 17:05:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return true
|
|
|
|
}
|
|
|
|
|
|
|
|
return false
|
|
|
|
}
|