Added shell parameters to MAL jobs

This commit is contained in:
Eduard Urbach 2018-04-12 19:05:05 +02:00
parent 87b11eb50d
commit c60c171a2f
4 changed files with 84 additions and 2 deletions

View File

@ -5,6 +5,7 @@ import (
"errors" "errors"
"fmt" "fmt"
"os" "os"
"path"
"path/filepath" "path/filepath"
"strings" "strings"
@ -21,9 +22,12 @@ func main() {
defer color.Green("Finished.") defer color.Green("Finished.")
defer arn.Node.Close() defer arn.Node.Close()
// readFile("../mal-download/files/anime-31240.html") // Invoke via parameters
if InvokeShellArgs() {
return
}
filepath.Walk("../mal-download/files", func(name string, info os.FileInfo, err error) error { filepath.Walk(path.Join(arn.Root, "jobs/mal-download/files"), func(name string, info os.FileInfo, err error) error {
if err != nil { if err != nil {
fmt.Println(err) fmt.Println(err)
return err return err

37
jobs/mal-parse/shell.go Normal file
View File

@ -0,0 +1,37 @@
package main
import (
"flag"
"path"
"github.com/animenotifier/arn"
)
// Shell parameters
var animeID string
// Shell flags
func init() {
flag.StringVar(&animeID, "id", "", "ID of the notify.moe anime you want to refresh")
flag.Parse()
}
// InvokeShellArgs ...
func InvokeShellArgs() bool {
if animeID != "" {
anime, err := arn.GetAnime(animeID)
if err != nil {
panic(err)
}
if anime.GetMapping("myanimelist/anime") == "" {
panic("No MAL ID")
}
readFile(path.Join(arn.Root, "jobs/mal-download/files", "anime-"+anime.GetMapping("myanimelist/anime")+".html"))
return true
}
return false
}

View File

@ -19,6 +19,11 @@ func main() {
defer color.Green("Finished.") defer color.Green("Finished.")
defer arn.Node.Close() defer arn.Node.Close()
// Invoke via parameters
if InvokeShellArgs() {
return
}
// Sync the most important ones first // Sync the most important ones first
allAnime := arn.AllAnime() allAnime := arn.AllAnime()
arn.SortAnimeByQuality(allAnime) arn.SortAnimeByQuality(allAnime)

36
jobs/mal-sync/shell.go Normal file
View File

@ -0,0 +1,36 @@
package main
import (
"flag"
"github.com/animenotifier/arn"
)
// Shell parameters
var animeID string
// Shell flags
func init() {
flag.StringVar(&animeID, "id", "", "ID of the notify.moe anime you want to refresh")
flag.Parse()
}
// InvokeShellArgs ...
func InvokeShellArgs() bool {
if animeID != "" {
anime, err := arn.GetAnime(animeID)
if err != nil {
panic(err)
}
if anime.GetMapping("myanimelist/anime") == "" {
panic("No MAL ID")
}
sync(anime, anime.GetMapping("myanimelist/anime"))
return true
}
return false
}