From f4da466d17a2a8fc6d19e2fd337c21eb3bfce120 Mon Sep 17 00:00:00 2001 From: killer069 <65385476+killer069@users.noreply.github.com> Date: Tue, 1 Feb 2022 09:35:39 +0530 Subject: [PATCH 1/2] Stream issues fixed Stream issues fixed + Playlist icons issues fixed --- play-dl/YouTube/classes/WebmSeeker.ts | 11 ++++++++++- play-dl/YouTube/utils/extractor.ts | 6 +----- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/play-dl/YouTube/classes/WebmSeeker.ts b/play-dl/YouTube/classes/WebmSeeker.ts index 95e77de..3c2c82b 100644 --- a/play-dl/YouTube/classes/WebmSeeker.ts +++ b/play-dl/YouTube/classes/WebmSeeker.ts @@ -30,6 +30,7 @@ export class WebmSeeker extends Duplex { headerparsed: boolean; seekfound: boolean; private data_size: number; + private offset: number; private data_length: number; private sec: number; private time: number; @@ -44,6 +45,7 @@ export class WebmSeeker extends Duplex { this.seekfound = false; this.data_length = 0; this.data_size = 0; + this.offset = 0 this.sec = sec; this.time = Math.floor(sec / 10) * 10; } @@ -91,7 +93,7 @@ export class WebmSeeker extends Duplex { } else continue; } if (clusterlength === 0) return position; - return Math.round(position + (time_left / 20) * (clusterlength / 500)); + return this.offset + Math.round(position + (time_left / 20) * (clusterlength / 500)); } _write(chunk: Buffer, _: BufferEncoding, callback: (error?: Error | null) => void): void { @@ -142,6 +144,9 @@ export class WebmSeeker extends Duplex { if (parse instanceof Error) return parse; // stop parsing the header once we have found the correct cue + + if(ebmlID.name === "seekHead") this.offset = oldCursor + if ( ebmlID.name === 'cueClusterPosition' && this.header.segment.cues!.length > 2 && @@ -211,6 +216,10 @@ export class WebmSeeker extends Duplex { } private getClosestBlock(): Error | undefined { + if(this.sec === 0){ + this.seekfound = true + return this.readTag() + } if (!this.chunk) return new Error('Chunk is missing'); this.cursor = 0; let positionFound = false; diff --git a/play-dl/YouTube/utils/extractor.ts b/play-dl/YouTube/utils/extractor.ts index c2d012b..6c8afca 100644 --- a/play-dl/YouTube/utils/extractor.ts +++ b/play-dl/YouTube/utils/extractor.ts @@ -726,11 +726,7 @@ function getNormalPlaylist(response: any, body: any): YouTubePlayList { author.videoOwnerRenderer.navigationEndpoint.commandMetadata.webCommandMetadata.url || author.videoOwnerRenderer.navigationEndpoint.browseEndpoint.canonicalBaseUrl }`, - icons: author.videoOwnerRenderer.thumbnail.thumbnails.length - ? author.videoOwnerRenderer.thumbnail.thumbnails[ - author.videoOwnerRenderer.thumbnail.thumbnails.length - 1 - ] - : null + icons: author.videoOwnerRenderer.thumbnail.thumbnails ?? [] } : {}, thumbnail: data.thumbnailRenderer.playlistVideoThumbnailRenderer?.thumbnail.thumbnails.length From f6b7204b33a4ce6d6540a0ffadedcade99a8f676 Mon Sep 17 00:00:00 2001 From: killer069 <65385476+killer069@users.noreply.github.com> Date: Tue, 1 Feb 2022 09:38:31 +0530 Subject: [PATCH 2/2] Prettier code --- play-dl/YouTube/classes/WebmSeeker.ts | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/play-dl/YouTube/classes/WebmSeeker.ts b/play-dl/YouTube/classes/WebmSeeker.ts index 3c2c82b..ab819f3 100644 --- a/play-dl/YouTube/classes/WebmSeeker.ts +++ b/play-dl/YouTube/classes/WebmSeeker.ts @@ -45,7 +45,7 @@ export class WebmSeeker extends Duplex { this.seekfound = false; this.data_length = 0; this.data_size = 0; - this.offset = 0 + this.offset = 0; this.sec = sec; this.time = Math.floor(sec / 10) * 10; } @@ -145,7 +145,7 @@ export class WebmSeeker extends Duplex { // stop parsing the header once we have found the correct cue - if(ebmlID.name === "seekHead") this.offset = oldCursor + if (ebmlID.name === 'seekHead') this.offset = oldCursor; if ( ebmlID.name === 'cueClusterPosition' && @@ -216,9 +216,9 @@ export class WebmSeeker extends Duplex { } private getClosestBlock(): Error | undefined { - if(this.sec === 0){ - this.seekfound = true - return this.readTag() + if (this.sec === 0) { + this.seekfound = true; + return this.readTag(); } if (!this.chunk) return new Error('Chunk is missing'); this.cursor = 0;