Change some error log and string
This commit is contained in:
parent
10f32f0678
commit
5c62ae9762
@ -45,7 +45,7 @@ export async function video_basic_info(url : string, cookie? : string){
|
|||||||
video_id = extractID(url)
|
video_id = extractID(url)
|
||||||
}
|
}
|
||||||
else video_id = url
|
else video_id = url
|
||||||
let new_url = 'https://www.youtube.com/watch?v=' + video_id
|
let new_url = `https://www.youtube.com/watch?v=${video_id}`
|
||||||
let body = await url_get(new_url, {
|
let body = await url_get(new_url, {
|
||||||
headers : (cookie) ? { 'cookie' : cookie } : {}
|
headers : (cookie) ? { 'cookie' : cookie } : {}
|
||||||
})
|
})
|
||||||
@ -53,13 +53,13 @@ export async function video_basic_info(url : string, cookie? : string){
|
|||||||
let initial_response = JSON.parse(body.split("var ytInitialData = ")[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]
|
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 !== 'OK') throw new Error(`While getting info from url\n${player_response.playabilityStatus.reason || player_response.playabilityStatus.messages[0]}`)
|
if(player_response.playabilityStatus.status !== 'OK') 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 html5player = `https://www.youtube.com${body.split('"jsUrl":"')[1].split('"')[0]}`
|
||||||
let format = []
|
let format = []
|
||||||
let vid = player_response.videoDetails
|
let vid = player_response.videoDetails
|
||||||
let microformat = player_response.microformat.playerMicroformatRenderer
|
let microformat = player_response.microformat.playerMicroformatRenderer
|
||||||
let video_details = {
|
let video_details = {
|
||||||
id : vid.videoId,
|
id : vid.videoId,
|
||||||
url : 'https://www.youtube.com/watch?v=' + vid.videoId,
|
url : `https://www.youtube.com/watch?v=${vid.videoId}`,
|
||||||
title : vid.title,
|
title : vid.title,
|
||||||
description : vid.shortDescription,
|
description : vid.shortDescription,
|
||||||
durationInSec : vid.lengthSeconds,
|
durationInSec : vid.lengthSeconds,
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user