Starting with a fresh database
This commit is contained in:
parent
a762b7bec1
commit
13c87d65d8
@ -1,46 +1,46 @@
|
|||||||
package main
|
// package main
|
||||||
|
|
||||||
import (
|
// import (
|
||||||
"fmt"
|
// "fmt"
|
||||||
"sort"
|
// "sort"
|
||||||
|
|
||||||
"github.com/animenotifier/arn"
|
// "github.com/animenotifier/arn"
|
||||||
"github.com/fatih/color"
|
// "github.com/fatih/color"
|
||||||
)
|
// )
|
||||||
|
|
||||||
// AiringAnime ...
|
// // AiringAnime ...
|
||||||
func AiringAnime() {
|
// func AiringAnime() {
|
||||||
fmt.Println("Running background job: Airing Anime")
|
// fmt.Println("Running background job: Airing Anime")
|
||||||
|
|
||||||
animeList, err := arn.GetAiringAnime()
|
// animeList, err := arn.GetAiringAnime()
|
||||||
|
|
||||||
if err != nil {
|
// if err != nil {
|
||||||
color.Red("Failed fetching airing anime")
|
// color.Red("Failed fetching airing anime")
|
||||||
color.Red(err.Error())
|
// color.Red(err.Error())
|
||||||
return
|
// return
|
||||||
}
|
// }
|
||||||
|
|
||||||
sort.Sort(arn.AnimeByPopularity(animeList))
|
// sort.Sort(arn.AnimeByPopularity(animeList))
|
||||||
|
|
||||||
// Convert to small anime list
|
// // Convert to small anime list
|
||||||
var animeListSmall []*arn.AnimeSmall
|
// var animeListSmall []*arn.AnimeSmall
|
||||||
|
|
||||||
for _, anime := range animeList {
|
// for _, anime := range animeList {
|
||||||
animeListSmall = append(animeListSmall, &arn.AnimeSmall{
|
// animeListSmall = append(animeListSmall, &arn.AnimeSmall{
|
||||||
ID: anime.ID,
|
// ID: anime.ID,
|
||||||
Title: anime.Title,
|
// Title: anime.Title,
|
||||||
Image: anime.Image,
|
// Image: anime.Image,
|
||||||
Watching: anime.Watching,
|
// Watching: anime.Watching,
|
||||||
})
|
// })
|
||||||
}
|
// }
|
||||||
|
|
||||||
saveErr := arn.SetObject("Cache", "airingAnime", &arn.AiringAnimeCacheSmall{
|
// saveErr := arn.SetObject("Cache", "airingAnime", &arn.AiringAnimeCacheSmall{
|
||||||
Anime: animeListSmall,
|
// Anime: animeListSmall,
|
||||||
})
|
// })
|
||||||
|
|
||||||
if saveErr != nil {
|
// if saveErr != nil {
|
||||||
color.Red("Error saving airing anime")
|
// color.Red("Error saving airing anime")
|
||||||
color.Red(saveErr.Error())
|
// color.Red(saveErr.Error())
|
||||||
return
|
// return
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
57
jobs/sync-anime/sync-anime.go
Normal file
57
jobs/sync-anime/sync-anime.go
Normal file
@ -0,0 +1,57 @@
|
|||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"strconv"
|
||||||
|
"strings"
|
||||||
|
|
||||||
|
"github.com/animenotifier/arn"
|
||||||
|
"github.com/animenotifier/kitsu"
|
||||||
|
"github.com/fatih/color"
|
||||||
|
)
|
||||||
|
|
||||||
|
func main() {
|
||||||
|
color.Yellow("Syncing Anime")
|
||||||
|
|
||||||
|
// Get a stream of all anime
|
||||||
|
allAnime := kitsu.AllAnime()
|
||||||
|
|
||||||
|
// Iterate over the stream
|
||||||
|
for anime := range allAnime {
|
||||||
|
sync(anime)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func sync(data *kitsu.Anime) {
|
||||||
|
anime := arn.Anime{}
|
||||||
|
|
||||||
|
anime.ID, _ = strconv.Atoi(data.ID)
|
||||||
|
anime.Type = strings.ToLower(data.Attributes.ShowType)
|
||||||
|
anime.Title.Canonical = data.Attributes.CanonicalTitle
|
||||||
|
anime.Title.English = data.Attributes.Titles.En
|
||||||
|
anime.Title.Japanese = data.Attributes.Titles.JaJp
|
||||||
|
anime.Title.Romaji = data.Attributes.Titles.EnJp
|
||||||
|
anime.Title.Synonyms = data.Attributes.AbbreviatedTitles
|
||||||
|
anime.Image = data.Attributes.PosterImage.Original
|
||||||
|
anime.Summary = arn.FixAnimeDescription(data.Attributes.Synopsis)
|
||||||
|
|
||||||
|
if data.Attributes.YoutubeVideoID != "" {
|
||||||
|
anime.Trailers = append(anime.Trailers, &arn.AnimeTrailer{
|
||||||
|
Service: "Youtube",
|
||||||
|
VideoID: data.Attributes.YoutubeVideoID,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
err := anime.Save()
|
||||||
|
|
||||||
|
status := ""
|
||||||
|
|
||||||
|
if err == nil {
|
||||||
|
status = color.GreenString("✔")
|
||||||
|
} else {
|
||||||
|
status = color.RedString("✘")
|
||||||
|
}
|
||||||
|
|
||||||
|
fmt.Println(status, anime.ID, anime.Title.Canonical)
|
||||||
|
|
||||||
|
}
|
5
main.go
5
main.go
@ -7,6 +7,7 @@ import (
|
|||||||
"github.com/animenotifier/notify.moe/components"
|
"github.com/animenotifier/notify.moe/components"
|
||||||
"github.com/animenotifier/notify.moe/pages/airing"
|
"github.com/animenotifier/notify.moe/pages/airing"
|
||||||
"github.com/animenotifier/notify.moe/pages/anime"
|
"github.com/animenotifier/notify.moe/pages/anime"
|
||||||
|
"github.com/animenotifier/notify.moe/pages/dashboard"
|
||||||
"github.com/animenotifier/notify.moe/pages/forum"
|
"github.com/animenotifier/notify.moe/pages/forum"
|
||||||
"github.com/animenotifier/notify.moe/pages/forums"
|
"github.com/animenotifier/notify.moe/pages/forums"
|
||||||
"github.com/animenotifier/notify.moe/pages/genre"
|
"github.com/animenotifier/notify.moe/pages/genre"
|
||||||
@ -33,9 +34,7 @@ func main() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Ajax routes
|
// Ajax routes
|
||||||
app.Ajax("/", func(ctx *aero.Context) string {
|
app.Ajax("/", dashboard.Get)
|
||||||
return ctx.HTML("ARN 4.0 is currently under construction.<br><a href='https://paypal.me/blitzprog' target='_blank' rel='noopener'>Support the development</a>")
|
|
||||||
})
|
|
||||||
app.Ajax("/anime", search.Get)
|
app.Ajax("/anime", search.Get)
|
||||||
app.Ajax("/anime/:id", anime.Get)
|
app.Ajax("/anime/:id", anime.Get)
|
||||||
app.Ajax("/genres", genres.Get)
|
app.Ajax("/genres", genres.Get)
|
||||||
|
@ -2,18 +2,17 @@ package airing
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/aerogo/aero"
|
"github.com/aerogo/aero"
|
||||||
"github.com/animenotifier/arn"
|
|
||||||
"github.com/animenotifier/notify.moe/components"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// Get ...
|
// Get ...
|
||||||
func Get(ctx *aero.Context) string {
|
func Get(ctx *aero.Context) string {
|
||||||
airingAnimeCache := new(arn.AiringAnimeCache)
|
// airingAnimeCache := new(arn.AiringAnimeCache)
|
||||||
err := arn.GetObject("Cache", "airingAnime", airingAnimeCache)
|
// err := arn.GetObject("Cache", "airingAnime", airingAnimeCache)
|
||||||
|
|
||||||
if err != nil {
|
// if err != nil {
|
||||||
return ctx.Error(500, "Couldn't fetch airing anime", err)
|
// return ctx.Error(500, "Couldn't fetch airing anime", err)
|
||||||
}
|
// }
|
||||||
|
|
||||||
return ctx.HTML(components.Airing(airingAnimeCache.Anime))
|
// return ctx.HTML(components.Airing(airingAnimeCache.Anime))
|
||||||
|
return ctx.HTML("Coming soon.")
|
||||||
}
|
}
|
||||||
|
@ -7,25 +7,25 @@ component Anime(anime *arn.Anime)
|
|||||||
.space
|
.space
|
||||||
|
|
||||||
.anime-info
|
.anime-info
|
||||||
h2.anime-title(title=anime.Type)= anime.Title.Romaji
|
h2.anime-title(title=anime.Type)= anime.Title.Canonical
|
||||||
|
|
||||||
//- if user && user.titleLanguage === "japanese"
|
//- if user && user.titleLanguage === "japanese"
|
||||||
//- span.second-title(title=anime.Title.English !== anime.Title.Romaji ? anime.Title.English : null)= anime.Title.Romaji
|
//- span.second-title(title=anime.Title.English !== anime.Title.Romaji ? anime.Title.English : null)= anime.Title.Romaji
|
||||||
//- else
|
//- else
|
||||||
if anime.Title.Japanese != anime.Title.Romaji
|
if anime.Title.Japanese != anime.Title.Canonical
|
||||||
a.anime-alternative-title(href="http://jisho.org/search/" + anime.Title.Japanese, target="_blank", title="Look up reading on jisho.org", rel="nofollow")= anime.Title.Japanese
|
a.anime-alternative-title(href="http://jisho.org/search/" + anime.Title.Japanese, target="_blank", title="Look up reading on jisho.org", rel="nofollow")= anime.Title.Japanese
|
||||||
|
|
||||||
//- h3.anime-section-name.anime-summary-header Summary
|
//- h3.anime-section-name.anime-summary-header Summary
|
||||||
p.anime-summary= arn.FixAnimeDescription(anime.Description)
|
p.anime-summary= anime.Summary
|
||||||
|
|
||||||
if anime.YoutubeID != ""
|
if len(anime.Trailers) > 0 && anime.Trailers[0].Service == "Youtube" && anime.Trailers[0].VideoID != ""
|
||||||
h3.anime-section-name Video
|
h3.anime-section-name Video
|
||||||
.anime-trailer.video-container
|
.anime-trailer.video-container
|
||||||
iframe.video(src="https://www.youtube.com/embed/" + anime.YoutubeID + "?showinfo=0", allowfullscreen="allowfullscreen")
|
iframe.video(src="https://www.youtube.com/embed/" + anime.Trailers[0].VideoID + "?showinfo=0", allowfullscreen="allowfullscreen")
|
||||||
|
|
||||||
if anime.Tracks != nil && anime.Tracks.Opening != nil
|
//- if anime.Tracks != nil && anime.Tracks.Opening != nil
|
||||||
h3.anime-section-name Tracks
|
//- h3.anime-section-name Tracks
|
||||||
iframe.anime-track(src="https://w.soundcloud.com/player/?url=" + anime.Tracks.Opening.URI + "?auto_play=false&hide_related=true&show_comments=true&show_user=true&show_reposts=false&visual=true")
|
//- iframe.anime-track(src="https://w.soundcloud.com/player/?url=" + anime.Tracks.Opening.URI + "?auto_play=false&hide_related=true&show_comments=true&show_user=true&show_reposts=false&visual=true")
|
||||||
|
|
||||||
//- if user && friendsWatching && friendsWatching.length > 0
|
//- if user && friendsWatching && friendsWatching.length > 0
|
||||||
//- include ../messages/avatar.pug
|
//- include ../messages/avatar.pug
|
||||||
@ -35,30 +35,30 @@ component Anime(anime *arn.Anime)
|
|||||||
//- each watcher in friendsWatching
|
//- each watcher in friendsWatching
|
||||||
//- +avatar(watcher)
|
//- +avatar(watcher)
|
||||||
|
|
||||||
if len(anime.Relations) > 0
|
//- if len(anime.Relations) > 0
|
||||||
h3.anime-section-name Relations
|
//- h3.anime-section-name Relations
|
||||||
.relations
|
//- .relations
|
||||||
each relation in anime.Relations
|
//- each relation in anime.Relations
|
||||||
a.relation.ajax(href="/anime/" + toString(relation.ID), title=relation.Anime().Title.Romaji)
|
//- a.relation.ajax(href="/anime/" + toString(relation.ID), title=relation.Anime().Title.Romaji)
|
||||||
img.anime-image.relation-image(src=relation.Anime().Image, alt=relation.Anime().Title.Romaji)
|
//- img.anime-image.relation-image(src=relation.Anime().Image, alt=relation.Anime().Title.Romaji)
|
||||||
.relation-type= arn.Capitalize(relation.Type)
|
//- .relation-type= arn.Capitalize(relation.Type)
|
||||||
|
|
||||||
if len(anime.Genres) > 0
|
//- if len(anime.Genres) > 0
|
||||||
h3.anime-section-name Genres
|
//- h3.anime-section-name Genres
|
||||||
.light-button-group
|
//- .light-button-group
|
||||||
each genre in anime.Genres
|
//- each genre in anime.Genres
|
||||||
if genre != ""
|
//- if genre != ""
|
||||||
a.light-button.ajax(href="/genres/" + arn.GetGenreIDByName(genre))
|
//- a.light-button.ajax(href="/genres/" + arn.GetGenreIDByName(genre))
|
||||||
Icon(arn.GetGenreIcon(genre))
|
//- Icon(arn.GetGenreIcon(genre))
|
||||||
span= genre
|
//- span= genre
|
||||||
|
|
||||||
if len(anime.Studios) > 0
|
//- if len(anime.Studios) > 0
|
||||||
h3.anime-section-name Studios
|
//- h3.anime-section-name Studios
|
||||||
.light-button-group
|
//- .light-button-group
|
||||||
each studio in anime.Studios
|
//- each studio in anime.Studios
|
||||||
a.light-button(href="https://anilist.co/studio/" + toString(studio.ID), target="_blank")
|
//- a.light-button(href="https://anilist.co/studio/" + toString(studio.ID), target="_blank")
|
||||||
Icon("building")
|
//- Icon("building")
|
||||||
span= studio.Name
|
//- span= studio.Name
|
||||||
|
|
||||||
//- //-if crunchy
|
//- //-if crunchy
|
||||||
//- //- h3.anime-section-name Episodes
|
//- //- h3.anime-section-name Episodes
|
||||||
@ -106,18 +106,18 @@ component Anime(anime *arn.Anime)
|
|||||||
//- if providers.Nyaa && providers.Nyaa.episodes !== undefined
|
//- if providers.Nyaa && providers.Nyaa.episodes !== undefined
|
||||||
//- span(class=providers.Nyaa.episodes === 0 ? "entry-error" : "entry-ok")= providers.Nyaa.episodes + " eps"
|
//- span(class=providers.Nyaa.episodes === 0 ? "entry-error" : "entry-ok")= providers.Nyaa.episodes + " eps"
|
||||||
|
|
||||||
h3.anime-section-name Links
|
//- h3.anime-section-name Links
|
||||||
.light-button-group
|
//- .light-button-group
|
||||||
if anime.Links != nil
|
//- if anime.Links != nil
|
||||||
each link in anime.Links
|
//- each link in anime.Links
|
||||||
a.light-button(href=link.URL, target="_blank")
|
//- a.light-button(href=link.URL, target="_blank")
|
||||||
Icon("external-link")
|
//- Icon("external-link")
|
||||||
span= link.Title
|
//- span= link.Title
|
||||||
|
|
||||||
if anime.CreatedBy == ""
|
//- if anime.CreatedBy == ""
|
||||||
a.light-button(href="https://anilist.co/anime/" + toString(anime.ID), target="_blank")
|
//- a.light-button(href="https://anilist.co/anime/" + toString(anime.ID), target="_blank")
|
||||||
Icon("external-link")
|
//- Icon("external-link")
|
||||||
span AniList
|
//- span AniList
|
||||||
|
|
||||||
//- if providers.HummingBird
|
//- if providers.HummingBird
|
||||||
//- a.light-button(href="https://hummingbird.me/anime/" + providers.HummingBird.providerId, target="_blank") HummingBird
|
//- a.light-button(href="https://hummingbird.me/anime/" + providers.HummingBird.providerId, target="_blank") HummingBird
|
||||||
@ -129,7 +129,7 @@ component Anime(anime *arn.Anime)
|
|||||||
//- a.light-button(href="http://www.anime-planet.com/anime/" + providers.AnimePlanet.providerId, target="_blank") AnimePlanet
|
//- a.light-button(href="http://www.anime-planet.com/anime/" + providers.AnimePlanet.providerId, target="_blank") AnimePlanet
|
||||||
|
|
||||||
.sources
|
.sources
|
||||||
p Powered by Anilist.
|
p Powered by Kitsu.
|
||||||
//- if descriptionSource
|
//- if descriptionSource
|
||||||
//- span= " Summary by " + summarySource + "."
|
//- span= " Summary by " + summarySource + "."
|
||||||
//- //-
|
//- //-
|
||||||
|
@ -2,25 +2,24 @@ package dashboard
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/aerogo/aero"
|
"github.com/aerogo/aero"
|
||||||
"github.com/animenotifier/arn"
|
|
||||||
"github.com/animenotifier/notify.moe/components"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
const maxPosts = 5
|
const maxPosts = 5
|
||||||
|
|
||||||
// Get ...
|
// Get ...
|
||||||
func Get(ctx *aero.Context) string {
|
func Get(ctx *aero.Context) string {
|
||||||
posts, err := arn.GetPosts()
|
// posts, err := arn.GetPosts()
|
||||||
|
|
||||||
if err != nil {
|
// if err != nil {
|
||||||
return ctx.Error(500, "Error fetching posts", err)
|
// return ctx.Error(500, "Error fetching posts", err)
|
||||||
}
|
// }
|
||||||
|
|
||||||
arn.SortPostsLatestFirst(posts)
|
// arn.SortPostsLatestFirst(posts)
|
||||||
|
|
||||||
if len(posts) > maxPosts {
|
// if len(posts) > maxPosts {
|
||||||
posts = posts[:maxPosts]
|
// posts = posts[:maxPosts]
|
||||||
}
|
// }
|
||||||
|
|
||||||
return ctx.HTML(components.Dashboard(posts))
|
// return ctx.HTML(components.Dashboard(posts))
|
||||||
|
return ctx.HTML("ARN 4.0 is currently under construction.<br><a href='https://paypal.me/blitzprog' target='_blank' rel='noopener'>Support the development</a>")
|
||||||
}
|
}
|
||||||
|
@ -2,29 +2,28 @@ package search
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/aerogo/aero"
|
"github.com/aerogo/aero"
|
||||||
"github.com/animenotifier/arn"
|
|
||||||
"github.com/animenotifier/notify.moe/components"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// Get ...
|
// Get ...
|
||||||
func Get(ctx *aero.Context) string {
|
func Get(ctx *aero.Context) string {
|
||||||
titleCount := 0
|
// titleCount := 0
|
||||||
animeCount := 0
|
// animeCount := 0
|
||||||
|
|
||||||
// let info: any = await bluebird.props({
|
// // let info: any = await bluebird.props({
|
||||||
// popular: arn.db.get('Cache', 'popularAnime'),
|
// // popular: arn.db.get('Cache', 'popularAnime'),
|
||||||
// stats: arn.db.get('Cache', 'animeStats')
|
// // stats: arn.db.get('Cache', 'animeStats')
|
||||||
// })
|
// // })
|
||||||
|
|
||||||
// return response.render({
|
// // return response.render({
|
||||||
// user,
|
// // user,
|
||||||
// popularAnime: info.popular.anime,
|
// // popularAnime: info.popular.anime,
|
||||||
// animeCount: info.stats.animeCount,
|
// // animeCount: info.stats.animeCount,
|
||||||
// titleCount: info.stats.titleCount,
|
// // titleCount: info.stats.titleCount,
|
||||||
// anime: null
|
// // anime: null
|
||||||
// })
|
// // })
|
||||||
|
|
||||||
popular, _ := arn.GetPopularCache()
|
// popular, _ := arn.GetPopularCache()
|
||||||
|
|
||||||
return ctx.HTML(components.Search(popular.Anime, titleCount, animeCount))
|
// return ctx.HTML(components.Search(popular.Anime, titleCount, animeCount))
|
||||||
|
return ctx.HTML("Coming soon.")
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user