52 lines
991 B
Go
Raw Normal View History

2018-04-12 16:57:28 +00:00
package main
import (
"flag"
"github.com/aerogo/crawler"
"github.com/animenotifier/arn"
)
// Shell parameters
2018-10-30 00:35:30 +00:00
var objectType string
var objectID string
var newOnly bool
2018-04-12 16:57:28 +00:00
// Shell flags
func init() {
2018-10-30 00:35:30 +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")
flag.BoolVar(&newOnly, "new", false, "Skip existing entries and only download new ones")
2018-04-12 16:57:28 +00:00
flag.Parse()
}
// InvokeShellArgs ...
func InvokeShellArgs() bool {
2018-10-30 00:35:30 +00:00
if objectID != "" {
2018-04-12 16:57:28 +00:00
// Create crawler
malCrawler := crawler.New(
headers,
delayBetweenRequests,
1,
)
2018-10-30 00:35:30 +00:00
switch objectType {
case "anime":
anime, err := arn.GetAnime(objectID)
arn.PanicOnError(err)
queueAnime(anime, malCrawler)
case "character":
character, err := arn.GetCharacter(objectID)
arn.PanicOnError(err)
queueCharacter(character, malCrawler)
}
2018-04-12 16:57:28 +00:00
// Wait
malCrawler.Wait()
return true
}
return false
}