SoundCloud work + prettier

This commit is contained in:
killer069
2021-09-17 14:36:32 +05:30
parent f9876ce5c5
commit 90b13629b4
21 changed files with 1615 additions and 1162 deletions

View File

@@ -1,4 +1,4 @@
type ThumbnailType = "default" | "hqdefault" | "mqdefault" | "sddefault" | "maxresdefault" | "ultrares";
type ThumbnailType = 'default' | 'hqdefault' | 'mqdefault' | 'sddefault' | 'maxresdefault' | 'ultrares';
export class Thumbnail {
id?: string;
@@ -21,20 +21,21 @@ export class Thumbnail {
this.url = data.url || undefined;
}
displayThumbnailURL(thumbnailType: ThumbnailType = "maxresdefault"): string {
if (!["default", "hqdefault", "mqdefault", "sddefault", "maxresdefault", "ultrares"].includes(thumbnailType)) throw new Error(`Invalid thumbnail type "${thumbnailType}"!`);
if (thumbnailType === "ultrares") return this.url as string;
displayThumbnailURL(thumbnailType: ThumbnailType = 'maxresdefault'): string {
if (!['default', 'hqdefault', 'mqdefault', 'sddefault', 'maxresdefault', 'ultrares'].includes(thumbnailType))
throw new Error(`Invalid thumbnail type "${thumbnailType}"!`);
if (thumbnailType === 'ultrares') return this.url as string;
return `https://i3.ytimg.com/vi/${this.id}/${thumbnailType}.jpg`;
}
defaultThumbnailURL(id: "0" | "1" | "2" | "3" | "4"): string {
if (!id) id = "0";
if (!["0", "1", "2", "3", "4"].includes(id)) throw new Error(`Invalid thumbnail id "${id}"!`);
defaultThumbnailURL(id: '0' | '1' | '2' | '3' | '4'): string {
if (!id) id = '0';
if (!['0', '1', '2', '3', '4'].includes(id)) throw new Error(`Invalid thumbnail id "${id}"!`);
return `https://i3.ytimg.com/vi/${this.id}/${id}.jpg`;
}
toString(): string {
return this.url ? `${this.url}` : "";
return this.url ? `${this.url}` : '';
}
toJSON() {