Fixed megacheck warnings

This commit is contained in:
Eduard Urbach 2018-10-31 18:13:18 +09:00
parent 4e2da206ca
commit 6ee4b0248d
2 changed files with 39 additions and 24 deletions

View File

@ -27,22 +27,24 @@ func main() {
return
}
filepath.Walk(path.Join(arn.Root, "jobs/mal-download/anime"), func(name string, info os.FileInfo, err error) error {
if err != nil {
fmt.Println(err)
return err
}
if objectType == "all" || objectType == "anime" {
filepath.Walk(path.Join(arn.Root, "jobs/mal-download/anime"), func(name string, info os.FileInfo, err error) error {
if err != nil {
fmt.Println(err)
return err
}
if info.IsDir() {
return nil
}
if info.IsDir() {
return nil
}
if !strings.HasSuffix(name, ".html.gz") {
return nil
}
if !strings.HasSuffix(name, ".html.gz") {
return nil
}
return readAnimeFile(name)
})
return readAnimeFile(name)
})
}
}
func readAnimeFile(name string) error {

View File

@ -8,28 +8,41 @@ import (
)
// Shell parameters
var animeID string
var objectType string
var objectID string
// Shell flags
func init() {
flag.StringVar(&animeID, "id", "", "ID of the notify.moe anime you want to refresh")
flag.StringVar(&objectType, "type", "all", "all | anime | character")
flag.StringVar(&objectID, "id", "", "ID of the notify.moe anime/character you want to refresh")
flag.Parse()
}
// InvokeShellArgs ...
func InvokeShellArgs() bool {
if animeID != "" {
anime, err := arn.GetAnime(animeID)
if objectID != "" {
switch objectType {
case "anime":
anime, err := arn.GetAnime(objectID)
arn.PanicOnError(err)
if err != nil {
panic(err)
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")
}
readCharacterFile(path.Join(arn.Root, "jobs", "mal-download", "character", character.GetMapping("myanimelist/character")+".html.gz"))
}
if anime.GetMapping("myanimelist/anime") == "" {
panic("No MAL ID")
}
readAnimeFile(path.Join(arn.Root, "jobs/mal-download/anime", "anime-"+anime.GetMapping("myanimelist/anime")+".html"))
return true
}