Jelajahi Sumber

refactor: add types for various musicbrainz types, and expand youtube video type

Kristian Vos 5 hari lalu
induk
melakukan
4974edc9b8
1 mengubah file dengan 199 tambahan dan 10 penghapusan
  1. 199 10
      frontend/src/types/artist.ts

+ 199 - 10
frontend/src/types/artist.ts

@@ -3,28 +3,43 @@ export interface ArtistTemp {
 	musicbrainzIdentifier: string;
 }
 
+// YouTube temporary types
 export interface YoutubeVideoTemp {
 	youtubeId: string;
 	title: string;
 	duration: number;
 	rawData: {
 		snippet: {
+			categoryId: string;
 			channelId: string;
+			channelTitle: string;
+			description: string;
+			liveBroadcastContent: string;
+			publishedAt: string; // or Date?
+			tags: string[];
+			thumbnails: unknown;
+			localized: {
+				description: string;
+				title: string;
+			};
+		};
+		statistics: {
+			commentCount: number;
+			likeCount: number;
+			viewCount: number;
+		};
+		status: {
+			embeddable: boolean;
+			license: string;
+			madeForKids: boolean;
+			privacyStatus: string;
+			publicStatsViewable: boolean;
+			uploadStatus: string;
 		};
 	};
 	hide: boolean;
 }
 
-export interface ReleaseTemp {
-	media: {
-		tracks: {
-			recording: {
-				id: string;
-			};
-		}[];
-	}[];
-}
-
 export interface YoutubeChannelTemp {
 	channelId: string;
 	title: string;
@@ -32,3 +47,177 @@ export interface YoutubeChannelTemp {
 		id: string;
 	};
 }
+
+// MusicBrainz temporary types
+export interface WorkTemp {
+	id: string;
+	iswcs: string[];
+	attributes: unknown;
+	type: string;
+	language: string;
+	disambiguation: string;
+	languages: string[];
+	"type-id": string;
+	title: string;
+}
+
+export interface RelationTemp {
+	"type-id": string;
+	begin: null;
+	"source-credit": string;
+	end: null;
+	"target-credit": string;
+	direction: "forward" | string;
+	"attributes-values": unknown;
+	"target-type": string;
+	type: string;
+	attributes: unknown[];
+	ended: boolean;
+	"attributes-ids": unknown;
+}
+
+export interface URLTemp {
+	resource: string;
+	id: string;
+}
+
+export interface URLRelationTemp extends RelationTemp {
+	"target-type": "url";
+	url: URLTemp;
+}
+
+export interface WorkRelationTemp extends RelationTemp {
+	"target-type": "work";
+	work: WorkTemp;
+}
+
+export interface RecordingTemp {
+	disambiguation: string;
+	"first-release-date": string;
+	id: string;
+	length: number;
+	title: string;
+	video: boolean;
+	relations: (URLRelationTemp | WorkRelationTemp)[];
+	"artist-credit"?: {
+		artist: {
+			country: string;
+			disambiguation: string;
+			id: string;
+			name: string;
+			"sort-name": string;
+			type: string;
+			"type-id": string;
+		};
+	}[];
+}
+
+export interface TrackTemp {
+	id: string;
+	length: number;
+	number: string;
+	position: number;
+	recording: RecordingTemp;
+	title: string;
+}
+
+export interface MediaTemp {
+	format: "CD";
+	"format-id": string;
+	position: number;
+	title: string;
+	"track-count": number;
+	"track-offset": number;
+	tracks?: TrackTemp[]; // If track-count is 0, this is undefined
+}
+
+export interface AreaTemp {
+	disambigutation: string;
+	id: string;
+	"iso-3166-1-codes": string[];
+	name: string;
+	"sort-name": string;
+	type: null;
+	"type-id": null;
+}
+
+export interface ReleaseGroupTemp {
+	disambiguation: string;
+	"first-release-date": string;
+	id: string;
+	"primary-type": "Album";
+	"primary-type-id": string;
+	"secondary-types": string[];
+	"secondary-type-ids": string[];
+	title: string;
+	relations: URLRelationTemp[];
+}
+
+export interface ReleaseEventTemp {
+	area: AreaTemp;
+	date: string;
+}
+
+export interface CoverArtArchiveTemp {
+	artwork: boolean;
+	back: boolean;
+	count: number;
+	darkened: boolean;
+	front: boolean;
+}
+
+export interface ReleaseTemp {
+	status: "Official" | string;
+	"text-representation": {
+		language: "eng" | string;
+		script: "Latn" | string;
+	};
+	"packaging-id": string;
+	"status-id": string;
+	quality: "normal" | string;
+	country: string;
+	packaging: string;
+	asin: string;
+	disambiguation: string;
+	id: string;
+	media: MediaTemp[];
+	date: string;
+	title: string;
+	"release-group": ReleaseGroupTemp;
+	barcode: string;
+	"release-events": ReleaseEventTemp[];
+	"cover-art-archive": CoverArtArchiveTemp;
+	relations: URLRelationTemp[];
+}
+
+export interface MusicBrainzArtistTemp {
+	id: string;
+	type: string; // E.g. Group
+	"type-id": string;
+	score: number;
+	name: string;
+	"sort-name": string;
+	country: string;
+	area: AreaTemp;
+	"begin-area": AreaTemp;
+	disambiguation: string;
+	ipis: string[];
+	isnis: string[];
+	"life-span": {
+		begin: string; //E.g. "2005"
+		ended: null;
+	};
+	aliases: {
+		"sort-name": string;
+		name: string;
+		locale: null;
+		type: null;
+		primary: null;
+		"begin-date": null;
+		"end-date": null;
+	}[];
+	tags: {
+		count: number;
+		name: string;
+	}[];
+}