Skip to content

Commit

Permalink
fix: fix getting some properties in videoDetails
Browse files Browse the repository at this point in the history
the endpoint changes from the previous commit also help with this fix

closes #800
closes #809
  • Loading branch information
fent committed Dec 7, 2020
1 parent 4167c31 commit fc3025d
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 4 deletions.
6 changes: 4 additions & 2 deletions lib/info-extras.js
Expand Up @@ -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,
Expand All @@ -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 {};
Expand Down
File renamed without changes.
4 changes: 2 additions & 2 deletions typings/index.d.ts
Expand Up @@ -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 {
Expand Down

0 comments on commit fc3025d

Please sign in to comment.