From 2ad7fd9bce85d0f0e83a686dde6d773c91474ec9 Mon Sep 17 00:00:00 2001 From: killer069 <65385476+killer069@users.noreply.github.com> Date: Tue, 24 Aug 2021 18:55:15 +0530 Subject: [PATCH] PlayList fixes --- play-dl/YouTube/utils/extractor.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/play-dl/YouTube/utils/extractor.ts b/play-dl/YouTube/utils/extractor.ts index 808913e..37540b7 100644 --- a/play-dl/YouTube/utils/extractor.ts +++ b/play-dl/YouTube/utils/extractor.ts @@ -112,12 +112,14 @@ export async function playlist_info(url : string) { if(url.search('(\\?|\\&)list\\=') === -1) throw new Error('This is not a PlayList URL') let Playlist_id = url.split('list=')[1].split('&')[0] + if(Playlist_id.length !== 34) throw new Error('This is not a PlayList URL') let new_url = `https://www.youtube.com/playlist?list=${Playlist_id}` let body = await url_get(new_url) let response = JSON.parse(body.split("var ytInitialData = ")[1].split(";")[0]) if(response.alerts){ - if(response.alerts[0].alertRenderer?.type === 'ERROR') throw new Error(`While parsing playlist url\n ${response.alerts[0].alertRenderer.text.runs[0].text}`) + if(response.alerts[0].alertWithButtonRenderer?.type === 'INFO') throw new Error(`While parsing playlist url\n ${response.alerts[0].alertWithButtonRenderer.text.simpleText}`) + else if(response.alerts[0].alertRenderer?.type === 'ERROR') throw new Error(`While parsing playlist url\n ${response.alerts[0].alertRenderer.text.runs[0].text}`) else throw new Error('While parsing playlist url\n Unknown Playlist Error') }