URL video details now include channel verified

This commit is contained in:
killer069 2021-08-31 15:08:37 +05:30
parent 34907c4eda
commit f8f4d88008
3 changed files with 7 additions and 4 deletions

4
package-lock.json generated
View File

@ -1,12 +1,12 @@
{
"name": "play-dl",
"version": "0.7.1",
"version": "0.7.2",
"lockfileVersion": 2,
"requires": true,
"packages": {
"": {
"name": "play-dl",
"version": "0.7.1",
"version": "0.7.2",
"license": "MIT",
"dependencies": {
"got": "^11.8.2"

View File

@ -1,6 +1,6 @@
{
"name": "play-dl",
"version": "0.7.1",
"version": "0.7.2",
"description": "YouTube, SoundCloud, Spotify streaming for discord.js bots",
"main": "dist/index.js",
"typings": "dist/index.d.ts",

View File

@ -30,6 +30,8 @@ export async function video_basic_info(url : string){
let new_url = 'https://www.youtube.com/watch?v=' + video_id
let body = await url_get(new_url)
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]}`)
let html5player = 'https://www.youtube.com' + body.split('"jsUrl":"')[1].split('"')[0]
@ -48,7 +50,8 @@ export async function video_basic_info(url : string){
channel : {
name : vid.author,
id : vid.channelId,
url : `https://www.youtube.com/channel/${vid.channelId}`
url : `https://www.youtube.com/channel/${vid.channelId}`,
verified : Boolean(badge?.metadataBadgeRenderer?.style?.toLowerCase().includes('verified'))
},
views : vid.viewCount,
tags : vid.keywords,