From 076f904e2b092eb1ceadb28b9951ca6603c3c60d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=8A=88=EB=A6=AC=ED=8A=AC?= <9804cjh@naver.com> Date: Tue, 7 Sep 2021 22:05:01 +0900 Subject: [PATCH] Add unplayable video error --- play-dl/YouTube/utils/extractor.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/play-dl/YouTube/utils/extractor.ts b/play-dl/YouTube/utils/extractor.ts index 849a220..c8ec884 100644 --- a/play-dl/YouTube/utils/extractor.ts +++ b/play-dl/YouTube/utils/extractor.ts @@ -52,8 +52,8 @@ export async function video_basic_info(url : string, cookie? : string){ let player_response = JSON.parse(body.split("var ytInitialPlayerResponse = ")[1].split("}};")[0] + '}}') let initial_response = JSON.parse(body.split("var ytInitialData = ")[1].split("}};")[0] + '}}') let badge = initial_response.contents.twoColumnWatchNextResults.results.results.contents[1]?.videoSecondaryInfoRenderer?.owner?.videoOwnerRenderer?.badges && initial_response.contents.twoColumnWatchNextResults.results.results.contents[1]?.videoSecondaryInfoRenderer?.owner?.videoOwnerRenderer?.badges[0] - if(player_response.playabilityStatus.status === 'ERROR') throw new Error(`While getting info from url \n ${player_response.playabilityStatus.reason}`) - if(player_response.playabilityStatus.status === 'LOGIN_REQUIRED') throw new Error(`While getting info from url \n ${ player_response.playabilityStatus.reason || player_response.playabilityStatus.messages[0]}`) + if(player_response.playabilityStatus.status === 'ERROR' || player_response.playabilityStatus.status === 'UNPLAYABLE') throw new Error(`While getting info from url\n${player_response.playabilityStatus.reason}`) + if(player_response.playabilityStatus.status === 'LOGIN_REQUIRED') throw new Error(`While getting info from url\n${player_response.playabilityStatus.reason || player_response.playabilityStatus.messages[0]}`) let html5player = 'https://www.youtube.com' + body.split('"jsUrl":"')[1].split('"')[0] let format = [] let vid = player_response.videoDetails @@ -238,4 +238,4 @@ function parseDuration(duration: string): number { export function getContinuationToken(data:any): string { const continuationToken = data.find((x: any) => Object.keys(x)[0] === "continuationItemRenderer")?.continuationItemRenderer.continuationEndpoint?.continuationCommand?.token; return continuationToken; -} \ No newline at end of file +}