Added anime type and fixed image in player

This commit is contained in:
Eduard Urbach 2018-03-27 00:10:32 +02:00
parent 3799bc5330
commit 2e2609b3a6
2 changed files with 88 additions and 2 deletions

View File

@ -1,4 +1,5 @@
import { AnimeNotifier } from "./AnimeNotifier" import { AnimeNotifier } from "./AnimeNotifier"
import { Anime } from "./Types/Anime"
export class AudioPlayer { export class AudioPlayer {
arn: AnimeNotifier arn: AnimeNotifier
@ -269,10 +270,10 @@ export class AudioPlayer {
if(animeId !== "") { if(animeId !== "") {
this.animeInfo.classList.remove("hidden") this.animeInfo.classList.remove("hidden")
let animeResponse = await fetch("/api/anime/" + animeId) let animeResponse = await fetch("/api/anime/" + animeId)
let anime = await animeResponse.json() let anime = await animeResponse.json() as Anime
this.animeLink.title = anime.title.canonical this.animeLink.title = anime.title.canonical
this.animeLink.href = "/anime/" + anime.id this.animeLink.href = "/anime/" + anime.id
this.animeImage.dataset.src = "//media.notify.moe/images/anime/medium/" + anime.id + ".jpg" this.animeImage.dataset.src = "//media.notify.moe/images/anime/medium/" + anime.id + ".jpg?" + anime.image.lastModified.toString()
this.animeImage.classList.remove("hidden") this.animeImage.classList.remove("hidden")
this.animeImage["became visible"]() this.animeImage["became visible"]()
} }

85
scripts/Types/Anime.d.ts vendored Normal file
View File

@ -0,0 +1,85 @@
declare module anime {
export interface Title {
canonical: string;
romaji: string;
english: string;
japanese: string;
hiragana: string;
synonyms: any[];
}
export interface AverageColor {
hue: number;
saturation: number;
lightness: number;
}
export interface Image {
extension: string;
width: number;
height: number;
averageColor: AverageColor;
lastModified: number;
}
export interface Count {
overall: number;
story: number;
visuals: number;
soundtrack: number;
}
export interface Rating {
overall: number;
story: number;
visuals: number;
soundtrack: number;
count: Count;
}
export interface Popularity {
watching: number;
completed: number;
planned: number;
hold: number;
dropped: number;
}
export interface Trailer {
service: string;
serviceId: string;
}
export interface Mapping {
service: string;
serviceId: string;
}
}
export interface Anime {
id: string;
type: string;
title: anime.Title;
summary: string;
status: string;
genres: string[];
startDate: string;
endDate: string;
episodeCount: number;
episodeLength: number;
source: string;
image: anime.Image;
firstChannel: string;
rating: anime.Rating;
popularity: anime.Popularity;
trailers: anime.Trailer[];
mappings: anime.Mapping[];
studios: string[];
producers: string[];
licensors: string[];
links?: any;
created: string;
createdBy: string;
edited: string;
editedBy: string;
}