Updated API

This commit is contained in:
Eduard Urbach 2017-06-27 14:38:36 +02:00
parent 2b471b871d
commit ab253000ef
9 changed files with 103 additions and 7 deletions

View File

@ -51,7 +51,7 @@ func updateUserIndex() {
userSearchIndex := arn.NewSearchIndex()
// Users
userStream, err := arn.AllUsers()
userStream, err := arn.StreamUsers()
if err != nil {
panic(err)

View File

@ -14,6 +14,21 @@ const maxTracks = 10
func Get(ctx *aero.Context) string {
tracks := []*arn.SoundTrack{}
tracks = append(tracks, &arn.SoundTrack{
ID: "0",
Media: []arn.ExternalMedia{
arn.ExternalMedia{
Service: "Soundcloud",
ServiceID: "145918628",
},
},
Tags: []string{
"anime:2357",
},
Created: arn.DateTimeUTC(),
CreatedBy: "4J6qpK1ve",
})
tracks = append(tracks, &arn.SoundTrack{
ID: "1",
Media: []arn.ExternalMedia{
@ -44,6 +59,51 @@ func Get(ctx *aero.Context) string {
CreatedBy: "4J6qpK1ve",
})
tracks = append(tracks, &arn.SoundTrack{
ID: "3",
Media: []arn.ExternalMedia{
arn.ExternalMedia{
Service: "Soundcloud",
ServiceID: "243839100",
},
},
Tags: []string{
"anime:9962",
},
Created: arn.DateTimeUTC(),
CreatedBy: "4J6qpK1ve",
})
tracks = append(tracks, &arn.SoundTrack{
ID: "3",
Media: []arn.ExternalMedia{
arn.ExternalMedia{
Service: "Soundcloud",
ServiceID: "207355237",
},
},
Tags: []string{
"anime:6589",
},
Created: arn.DateTimeUTC(),
CreatedBy: "4J6qpK1ve",
})
tracks = append(tracks, &arn.SoundTrack{
ID: "3",
Media: []arn.ExternalMedia{
arn.ExternalMedia{
Service: "Soundcloud",
ServiceID: "242172944",
},
},
Tags: []string{
"anime:10740",
},
Created: arn.DateTimeUTC(),
CreatedBy: "4J6qpK1ve",
})
if len(tracks) > maxTracks {
tracks = tracks[:maxTracks]
}

View File

@ -5,9 +5,9 @@ component Music(tracks []*arn.SoundTrack)
each track in tracks
.sound-track
a.sound-track-anime-link.ajax(href="/anime/" + track.MainAnime().ID)
img.sound-track-anime-image(src=track.MainAnime().Image.Small, alt=track.MainAnime().Title.Canonical, title=track.MainAnime().Title.Canonical)
img.sound-track-anime-image.lazy(data-src=track.MainAnime().Image.Small, alt=track.MainAnime().Title.Canonical, title=track.MainAnime().Title.Canonical)
iframe(src="https://w.soundcloud.com/player/?url=https://api.soundcloud.com/tracks/" + track.Media[0].ServiceID + "?auto_play=false&hide_related=true&show_comments=true&show_user=true&show_reposts=false&visual=true")
iframe.lazy(data-src="https://w.soundcloud.com/player/?url=https://api.soundcloud.com/tracks/" + track.Media[0].ServiceID + "?auto_play=false&hide_related=true&show_comments=true&show_user=true&show_reposts=false&visual=true")
.sound-track-footer
span posted by
a.ajax(href=track.CreatedByUser().Link())= track.CreatedByUser().Nick

View File

@ -6,6 +6,8 @@
iframe
width 100%
box-shadow shadow-light
.sound-track-footer
text-align right

View File

@ -11,7 +11,7 @@ func main() {
color.Yellow("Adding empty anime lists to users who don't have one")
// Get a stream of all users
allUsers, err := arn.AllUsers()
allUsers, err := arn.StreamUsers()
if err != nil {
panic(err)

View File

@ -6,7 +6,7 @@ import (
func main() {
// Get a stream of all users
allUsers, err := arn.AllUsers()
allUsers, err := arn.StreamUsers()
if err != nil {
panic(err)

View File

@ -6,7 +6,7 @@ func main() {
// color.Yellow("Deleting private user data")
// // Get a stream of all users
// allUsers, err := arn.AllUsers()
// allUsers, err := arn.StreamUsers()
// if err != nil {
// panic(err)

View File

@ -13,7 +13,7 @@ func main() {
arn.DB.DeleteTable("GoogleToUser")
// Get a stream of all users
allUsers, err := arn.AllUsers()
allUsers, err := arn.StreamUsers()
if err != nil {
panic(err)

View File

@ -0,0 +1,34 @@
package main
import (
"github.com/animenotifier/arn"
"github.com/fatih/color"
)
func main() {
// Get a stream of all anime
allAnime, err := arn.AllAnime()
if err != nil {
panic(err)
}
// Iterate over the stream
for _, anime := range allAnime {
for _, trailer := range anime.Trailers {
// trailer.ServiceID = trailer.DeprecatedVideoID
println(trailer.DeprecatedVideoID)
trailer.ServiceID = trailer.DeprecatedVideoID
}
if anime.Trailers == nil {
anime.Trailers = []*arn.ExternalMedia{}
}
err := anime.Save()
if err != nil {
color.Red("Error saving anime: %v", err)
}
}
}