Implemented music page

This commit is contained in:
2017-06-27 16:23:57 +02:00
parent c32166f38c
commit 50cd062140
8 changed files with 45 additions and 159 deletions

View File

@ -1,13 +1,9 @@
package main
import (
"encoding/json"
"io/ioutil"
"log"
"os"
"os/signal"
"path"
"path/filepath"
"strings"
"syscall"
@ -21,30 +17,8 @@ var discord *discordgo.Session
func main() {
var err error
exe, err := os.Executable()
if err != nil {
panic(err)
}
dir := path.Dir(exe)
var apiKeysPath string
apiKeysPath, err = filepath.Abs(dir + "/../../security/api-keys.json")
if err != nil {
panic(err)
}
var apiKeys arn.APIKeys
data, _ := ioutil.ReadFile(apiKeysPath)
err = json.Unmarshal(data, &apiKeys)
if err != nil {
panic(err)
}
discord, _ = discordgo.New()
discord.Token = "Bot " + apiKeys.Discord.Token
discord.Token = "Bot " + arn.APIKeys.Discord.Token
// Verify a Token was provided
if discord.Token == "" {

View File

@ -46,9 +46,15 @@ func sync(data *kitsu.Anime) {
anime.EpisodeCount = attr.EpisodeCount
anime.EpisodeLength = attr.EpisodeLength
anime.Status = attr.Status
anime.NSFW = attr.Nsfw
anime.Summary = arn.FixAnimeDescription(attr.Synopsis)
// NSFW
if attr.Nsfw {
anime.NSFW = 1
} else {
anime.NSFW = 0
}
// Rating
overall, convertError := strconv.ParseFloat(attr.AverageRating, 64)
@ -59,10 +65,10 @@ func sync(data *kitsu.Anime) {
anime.Rating.Overall = overall
// Trailers
anime.Trailers = []arn.ExternalMedia{}
anime.Trailers = []*arn.ExternalMedia{}
if attr.YoutubeVideoID != "" {
anime.Trailers = append(anime.Trailers, arn.ExternalMedia{
anime.Trailers = append(anime.Trailers, &arn.ExternalMedia{
Service: "Youtube",
ServiceID: attr.YoutubeVideoID,
})