From ab253000ef1d5e8cbfa2b18e2612671fc0d813df Mon Sep 17 00:00:00 2001 From: Eduard Urbach Date: Tue, 27 Jun 2017 14:38:36 +0200 Subject: [PATCH] Updated API --- jobs/search-index/main.go | 2 +- pages/music/music.go | 60 ++++++++++++++++++++++++++ pages/music/music.pixy | 4 +- pages/music/music.scarlet | 2 + patches/add-anime-lists/main.go | 2 +- patches/add-last-seen/main.go | 2 +- patches/delete-private-data/main.go | 2 +- patches/user-references/main.go | 2 +- patches/video-id-to-service-id/main.go | 34 +++++++++++++++ 9 files changed, 103 insertions(+), 7 deletions(-) create mode 100644 patches/video-id-to-service-id/main.go diff --git a/jobs/search-index/main.go b/jobs/search-index/main.go index d4b90078..0033b956 100644 --- a/jobs/search-index/main.go +++ b/jobs/search-index/main.go @@ -51,7 +51,7 @@ func updateUserIndex() { userSearchIndex := arn.NewSearchIndex() // Users - userStream, err := arn.AllUsers() + userStream, err := arn.StreamUsers() if err != nil { panic(err) diff --git a/pages/music/music.go b/pages/music/music.go index 66ced1d2..9ce4719c 100644 --- a/pages/music/music.go +++ b/pages/music/music.go @@ -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] } diff --git a/pages/music/music.pixy b/pages/music/music.pixy index 0d291360..f2b60d80 100644 --- a/pages/music/music.pixy +++ b/pages/music/music.pixy @@ -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 \ No newline at end of file diff --git a/pages/music/music.scarlet b/pages/music/music.scarlet index 66ab4050..c6170788 100644 --- a/pages/music/music.scarlet +++ b/pages/music/music.scarlet @@ -6,6 +6,8 @@ iframe width 100% + + box-shadow shadow-light .sound-track-footer text-align right diff --git a/patches/add-anime-lists/main.go b/patches/add-anime-lists/main.go index 51eb9275..88776a6f 100644 --- a/patches/add-anime-lists/main.go +++ b/patches/add-anime-lists/main.go @@ -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) diff --git a/patches/add-last-seen/main.go b/patches/add-last-seen/main.go index ca8fcc3c..d2c3f228 100644 --- a/patches/add-last-seen/main.go +++ b/patches/add-last-seen/main.go @@ -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) diff --git a/patches/delete-private-data/main.go b/patches/delete-private-data/main.go index 51a134a0..94df6456 100644 --- a/patches/delete-private-data/main.go +++ b/patches/delete-private-data/main.go @@ -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) diff --git a/patches/user-references/main.go b/patches/user-references/main.go index 46ad2777..31a7d454 100644 --- a/patches/user-references/main.go +++ b/patches/user-references/main.go @@ -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) diff --git a/patches/video-id-to-service-id/main.go b/patches/video-id-to-service-id/main.go new file mode 100644 index 00000000..2436f116 --- /dev/null +++ b/patches/video-id-to-service-id/main.go @@ -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) + } + } +}