Migration to nano
This commit is contained in:
parent
c60f53ed76
commit
b0d03fe8ef
@ -10,6 +10,7 @@ import (
|
||||
|
||||
func main() {
|
||||
color.Yellow("Refreshing episode information for each anime.")
|
||||
defer arn.Node.Close()
|
||||
|
||||
if InvokeShellArgs() {
|
||||
return
|
||||
@ -19,7 +20,7 @@ func main() {
|
||||
mediumPriority := []*arn.Anime{}
|
||||
lowPriority := []*arn.Anime{}
|
||||
|
||||
for anime := range arn.MustStreamAnime() {
|
||||
for anime := range arn.StreamAnime() {
|
||||
if anime.GetMapping("shoboi/anime") == "" {
|
||||
continue
|
||||
}
|
||||
|
@ -9,6 +9,7 @@ import (
|
||||
|
||||
func main() {
|
||||
color.Yellow("Refreshing osu information")
|
||||
defer arn.Node.Close()
|
||||
|
||||
ticker := time.NewTicker(500 * time.Millisecond)
|
||||
|
||||
|
@ -11,6 +11,7 @@ import (
|
||||
|
||||
func main() {
|
||||
color.Yellow("Updating search index")
|
||||
defer arn.Node.Close()
|
||||
|
||||
flow.Parallel(
|
||||
updateAnimeIndex,
|
||||
@ -26,13 +27,7 @@ func updateAnimeIndex() {
|
||||
animeSearchIndex := arn.NewSearchIndex()
|
||||
|
||||
// Anime
|
||||
animeStream, err := arn.StreamAnime()
|
||||
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
for anime := range animeStream {
|
||||
for anime := range arn.StreamAnime() {
|
||||
if anime.Title.Canonical != "" {
|
||||
animeSearchIndex.TextToID[strings.ToLower(anime.Title.Canonical)] = anime.ID
|
||||
}
|
||||
@ -64,21 +59,14 @@ func updateAnimeIndex() {
|
||||
fmt.Println(len(animeSearchIndex.TextToID), "anime titles")
|
||||
|
||||
// Save in database
|
||||
err = arn.DB.Set("SearchIndex", "Anime", animeSearchIndex)
|
||||
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
arn.DB.Set("SearchIndex", "Anime", animeSearchIndex)
|
||||
}
|
||||
|
||||
func updateUserIndex() {
|
||||
userSearchIndex := arn.NewSearchIndex()
|
||||
|
||||
// Users
|
||||
userStream, err := arn.StreamUsers()
|
||||
arn.PanicOnError(err)
|
||||
|
||||
for user := range userStream {
|
||||
for user := range arn.StreamUsers() {
|
||||
if user.HasNick() {
|
||||
userSearchIndex.TextToID[strings.ToLower(user.Nick)] = user.ID
|
||||
}
|
||||
@ -87,36 +75,28 @@ func updateUserIndex() {
|
||||
fmt.Println(len(userSearchIndex.TextToID), "user names")
|
||||
|
||||
// Save in database
|
||||
err = arn.DB.Set("SearchIndex", "User", userSearchIndex)
|
||||
arn.PanicOnError(err)
|
||||
arn.DB.Set("SearchIndex", "User", userSearchIndex)
|
||||
}
|
||||
|
||||
func updatePostIndex() {
|
||||
postSearchIndex := arn.NewSearchIndex()
|
||||
|
||||
// Users
|
||||
postStream, err := arn.StreamPosts()
|
||||
arn.PanicOnError(err)
|
||||
|
||||
for post := range postStream {
|
||||
for post := range arn.StreamPosts() {
|
||||
postSearchIndex.TextToID[strings.ToLower(post.Text)] = post.ID
|
||||
}
|
||||
|
||||
fmt.Println(len(postSearchIndex.TextToID), "posts")
|
||||
|
||||
// Save in database
|
||||
err = arn.DB.Set("SearchIndex", "Post", postSearchIndex)
|
||||
arn.PanicOnError(err)
|
||||
arn.DB.Set("SearchIndex", "Post", postSearchIndex)
|
||||
}
|
||||
|
||||
func updateThreadIndex() {
|
||||
threadSearchIndex := arn.NewSearchIndex()
|
||||
|
||||
// Users
|
||||
threadStream, err := arn.StreamThreads()
|
||||
arn.PanicOnError(err)
|
||||
|
||||
for thread := range threadStream {
|
||||
for thread := range arn.StreamThreads() {
|
||||
threadSearchIndex.TextToID[strings.ToLower(thread.Title)] = thread.ID
|
||||
threadSearchIndex.TextToID[strings.ToLower(thread.Text)] = thread.ID
|
||||
}
|
||||
@ -124,6 +104,5 @@ func updateThreadIndex() {
|
||||
fmt.Println(len(threadSearchIndex.TextToID)/2, "threads")
|
||||
|
||||
// Save in database
|
||||
err = arn.DB.Set("SearchIndex", "Thread", threadSearchIndex)
|
||||
arn.PanicOnError(err)
|
||||
arn.DB.Set("SearchIndex", "Thread", threadSearchIndex)
|
||||
}
|
||||
|
@ -1,7 +1,6 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"strings"
|
||||
|
||||
@ -12,6 +11,7 @@ import (
|
||||
|
||||
func main() {
|
||||
color.Yellow("Syncing Anime")
|
||||
defer arn.Node.Close()
|
||||
|
||||
// In case we refresh only one anime
|
||||
if InvokeShellArgs() {
|
||||
@ -127,19 +127,7 @@ func sync(data *kitsu.Anime) *arn.Anime {
|
||||
}
|
||||
|
||||
// Save in database
|
||||
err = anime.Save()
|
||||
status := ""
|
||||
|
||||
if err == nil {
|
||||
status = color.GreenString("✔")
|
||||
} else {
|
||||
color.Red(err.Error())
|
||||
|
||||
data, _ := json.MarshalIndent(anime, "", "\t")
|
||||
fmt.Println(string(data))
|
||||
|
||||
status = color.RedString("✘")
|
||||
}
|
||||
anime.Save()
|
||||
|
||||
// Episodes
|
||||
episodes, err := arn.GetAnimeEpisodes(anime.ID)
|
||||
@ -149,7 +137,7 @@ func sync(data *kitsu.Anime) *arn.Anime {
|
||||
}
|
||||
|
||||
// Log
|
||||
fmt.Println(status, anime.ID, anime.Title.Canonical)
|
||||
fmt.Println(color.GreenString("✔"), anime.ID, anime.Title.Canonical)
|
||||
|
||||
return anime
|
||||
}
|
||||
|
@ -10,13 +10,14 @@ import (
|
||||
|
||||
func main() {
|
||||
color.Yellow("Syncing Shoboi Anime")
|
||||
defer arn.Node.Close()
|
||||
|
||||
// Priority queues
|
||||
highPriority := []*arn.Anime{}
|
||||
mediumPriority := []*arn.Anime{}
|
||||
lowPriority := []*arn.Anime{}
|
||||
|
||||
for anime := range arn.MustStreamAnime() {
|
||||
for anime := range arn.StreamAnime() {
|
||||
if anime.GetMapping("shoboi/anime") != "" {
|
||||
continue
|
||||
}
|
||||
@ -51,7 +52,7 @@ func refreshQueue(queue []*arn.Anime) {
|
||||
|
||||
for _, anime := range queue {
|
||||
if sync(anime) {
|
||||
arn.PanicOnError(anime.Save())
|
||||
anime.Save()
|
||||
count++
|
||||
}
|
||||
}
|
||||
|
@ -21,9 +21,7 @@ func main() {
|
||||
idList := twistAnime.KitsuIDs()
|
||||
|
||||
// Save index in cache
|
||||
arn.DB.Set("Cache", "animetwist index", &arn.ListOfIDs{
|
||||
IDList: idList,
|
||||
})
|
||||
arn.DB.Set("IDList", "animetwist index", idList)
|
||||
|
||||
color.Yellow("Refreshing twist.moe links for %d anime", len(idList))
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user