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 {