From 2e2609b3a684ff9085c7641831fbf4ebc1a0d809 Mon Sep 17 00:00:00 2001 From: Eduard Urbach Date: Tue, 27 Mar 2018 00:10:32 +0200 Subject: [PATCH] Added anime type and fixed image in player --- scripts/AudioPlayer.ts | 5 ++- scripts/Types/Anime.d.ts | 85 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 88 insertions(+), 2 deletions(-) create mode 100644 scripts/Types/Anime.d.ts diff --git a/scripts/AudioPlayer.ts b/scripts/AudioPlayer.ts index edae08c4..ccc04af7 100644 --- a/scripts/AudioPlayer.ts +++ b/scripts/AudioPlayer.ts @@ -1,4 +1,5 @@ import { AnimeNotifier } from "./AnimeNotifier" +import { Anime } from "./Types/Anime" export class AudioPlayer { arn: AnimeNotifier @@ -269,10 +270,10 @@ export class AudioPlayer { if(animeId !== "") { this.animeInfo.classList.remove("hidden") 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.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["became visible"]() } diff --git a/scripts/Types/Anime.d.ts b/scripts/Types/Anime.d.ts new file mode 100644 index 00000000..1cdf1e71 --- /dev/null +++ b/scripts/Types/Anime.d.ts @@ -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; +} \ No newline at end of file