Anime character refresh
This commit is contained in:
parent
db4d362fb3
commit
d6155bf3a1
@ -1,14 +1,30 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
"github.com/animenotifier/arn"
|
||||
"github.com/fatih/color"
|
||||
)
|
||||
|
||||
func main() {
|
||||
anime, _ := arn.GetAnime("6887")
|
||||
err := anime.RefreshAnimeCharacters()
|
||||
arn.PanicOnError(err)
|
||||
color.Yellow("Refreshing anime characters...")
|
||||
|
||||
rateLimiter := time.NewTicker(500 * time.Millisecond)
|
||||
|
||||
for anime := range arn.MustStreamAnime() {
|
||||
<-rateLimiter.C
|
||||
|
||||
chars, err := anime.RefreshAnimeCharacters()
|
||||
|
||||
if err != nil {
|
||||
color.Red(err.Error())
|
||||
continue
|
||||
}
|
||||
|
||||
fmt.Printf("%s %s (%d characters)\n", anime.ID, anime.Title.Canonical, len(chars.Items))
|
||||
}
|
||||
|
||||
color.Green("Finished.")
|
||||
}
|
||||
|
@ -18,7 +18,7 @@ func main() {
|
||||
ID: kitsuCharacter.ID,
|
||||
Name: kitsuCharacter.Attributes.Name,
|
||||
Image: kitsu.FixImageURL(kitsuCharacter.Attributes.Image.Original),
|
||||
Description: kitsuCharacter.Attributes.Description,
|
||||
Description: arn.FixAnimeDescription(kitsuCharacter.Attributes.Description),
|
||||
}
|
||||
|
||||
fmt.Printf("%s %s\n", character.ID, character.Name)
|
||||
|
4
main.go
4
main.go
@ -15,6 +15,7 @@ import (
|
||||
"github.com/animenotifier/notify.moe/pages/animelistitem"
|
||||
"github.com/animenotifier/notify.moe/pages/apiview"
|
||||
"github.com/animenotifier/notify.moe/pages/best"
|
||||
"github.com/animenotifier/notify.moe/pages/character"
|
||||
"github.com/animenotifier/notify.moe/pages/dashboard"
|
||||
"github.com/animenotifier/notify.moe/pages/editanime"
|
||||
"github.com/animenotifier/notify.moe/pages/editor"
|
||||
@ -74,7 +75,8 @@ func configure(app *aero.Application) *aero.Application {
|
||||
app.Ajax("/forum/:tag", forum.Get)
|
||||
app.Ajax("/thread/:id", threads.Get)
|
||||
app.Ajax("/post/:id", posts.Get)
|
||||
app.Ajax("/tracks/:id", tracks.Get)
|
||||
app.Ajax("/track/:id", tracks.Get)
|
||||
app.Ajax("/character/:id", character.Get)
|
||||
app.Ajax("/new/thread", newthread.Get)
|
||||
app.Ajax("/new/soundtrack", newsoundtrack.Get)
|
||||
app.Ajax("/settings", settings.Get)
|
||||
|
@ -1,4 +1,4 @@
|
||||
component Character(character *arn.Character)
|
||||
a.character(href="#")
|
||||
a.character(href="/character/" + character.ID)
|
||||
img.character-image.lazy(src="", data-src=character.Image, alt=character.Name, title=character.Name)
|
||||
span.character-name= character.Name
|
@ -16,6 +16,7 @@
|
||||
|
||||
.character-image
|
||||
border-radius 3px
|
||||
box-shadow shadow-medium
|
||||
object-fit cover
|
||||
|
||||
.character-name
|
||||
|
21
pages/character/character.go
Normal file
21
pages/character/character.go
Normal file
@ -0,0 +1,21 @@
|
||||
package character
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"github.com/aerogo/aero"
|
||||
"github.com/animenotifier/arn"
|
||||
"github.com/animenotifier/notify.moe/components"
|
||||
)
|
||||
|
||||
// Get character.
|
||||
func Get(ctx *aero.Context) string {
|
||||
id := ctx.Get("id")
|
||||
character, err := arn.GetCharacter(id)
|
||||
|
||||
if err != nil {
|
||||
return ctx.Error(http.StatusNotFound, "Character not found", err)
|
||||
}
|
||||
|
||||
return ctx.HTML(components.CharacterDetails(character))
|
||||
}
|
5
pages/character/character.pixy
Normal file
5
pages/character/character.pixy
Normal file
@ -0,0 +1,5 @@
|
||||
component CharacterDetails(character *arn.Character)
|
||||
h1= character.Name
|
||||
p
|
||||
img(src=character.Image, alt=character.Name)
|
||||
p= character.Description
|
@ -8,7 +8,7 @@ import (
|
||||
"github.com/animenotifier/notify.moe/components"
|
||||
)
|
||||
|
||||
// Get post.
|
||||
// Get track.
|
||||
func Get(ctx *aero.Context) string {
|
||||
id := ctx.Get("id")
|
||||
track, err := arn.GetSoundTrack(id)
|
||||
|
Loading…
Reference in New Issue
Block a user