Types Improved

This commit is contained in:
killer069
2021-09-27 22:20:50 +05:30
parent 842d704bf2
commit 70d1774508
12 changed files with 104 additions and 131 deletions

View File

@@ -1,5 +1,4 @@
import { Channel } from './Channel';
import { Thumbnail } from './Thumbnail';
import { YouTubeChannel } from './Channel';
interface VideoOptions {
id?: string;
@@ -21,7 +20,6 @@ interface VideoOptions {
id: string;
icon: string;
};
videos?: Video[];
type: string;
ratings: {
likes: number;
@@ -32,9 +30,10 @@ interface VideoOptions {
tags: string[];
}
export class Video {
export class YouTubeVideo {
id?: string;
url?: string;
url: string;
type: 'video' | 'playlist' | 'channel';
title?: string;
description?: string;
durationRaw: string;
@@ -47,8 +46,7 @@ export class Video {
height: number | undefined;
url: string | undefined;
};
channel?: Channel;
videos?: Video[];
channel?: YouTubeChannel;
likes: number;
dislikes: number;
live: boolean;
@@ -60,6 +58,7 @@ export class Video {
this.id = data.id || undefined;
this.url = `https://www.youtube.com/watch?v=${this.id}`;
this.type = 'video';
this.title = data.title || undefined;
this.description = data.description || undefined;
this.durationRaw = data.duration_raw || '0:00';
@@ -75,10 +74,6 @@ export class Video {
this.tags = data.tags || [];
}
get type(): 'video' {
return 'video';
}
get toString(): string {
return this.url || '';
}