From fc3025d2fc394769b47a59e2cb7d1bcfc9bd5d41 Mon Sep 17 00:00:00 2001 From: fent <933490+fent@users.noreply.github.com> Date: Mon, 7 Dec 2020 00:19:48 -0700 Subject: [PATCH] fix: fix getting some properties in `videoDetails` the endpoint changes from the previous commit also help with this fix closes #800 closes #809 --- lib/info-extras.js | 6 ++++-- test/{info-test.js => basic-info-test.js} | 0 typings/index.d.ts | 4 ++-- 3 files changed, 6 insertions(+), 4 deletions(-) rename test/{info-test.js => basic-info-test.js} (100%) diff --git a/lib/info-extras.js b/lib/info-extras.js index 3e4f82f3..2d70f218 100644 --- a/lib/info-extras.js +++ b/lib/info-extras.js @@ -109,7 +109,7 @@ exports.getAuthor = info => { } try { let videoDetails = info.player_response.microformat && info.player_response.microformat.playerMicroformatRenderer; - let id = videoDetails ? videoDetails.channelId : channelId; + let id = (videoDetails && videoDetails.channelId) || channelId || info.player_response.videoDetails.channelId; let author = { id: id, name: videoDetails ? videoDetails.ownerChannelName : info.player_response.videoDetails.author, @@ -121,7 +121,9 @@ exports.getAuthor = info => { verified, subscriber_count: subscriberCount, }; - utils.deprecate(author, 'avatar', author.thumbnails[0].url, 'author.avatar', 'author.thumbnails[0].url'); + if (thumbnails.length) { + utils.deprecate(author, 'avatar', author.thumbnails[0].url, 'author.avatar', 'author.thumbnails[0].url'); + } return author; } catch (err) { return {}; diff --git a/test/info-test.js b/test/basic-info-test.js similarity index 100% rename from test/info-test.js rename to test/basic-info-test.js diff --git a/typings/index.d.ts b/typings/index.d.ts index 6f9dc359..86c2d9bf 100644 --- a/typings/index.d.ts +++ b/typings/index.d.ts @@ -146,13 +146,13 @@ declare module 'ytdl-core' { id: string; name: string; avatar: string; // to remove later - thumbnails: thumbnail[]; + thumbnails?: thumbnail[]; verified: boolean; user?: string; channel_url: string; external_channel_url?: string; user_url?: string; - subscriber_count: number; + subscriber_count?: number; } interface MicroformatRenderer {