Skip to content

Commit

Permalink
fix: use backup field to provide videoDetails.author fields more co…
Browse files Browse the repository at this point in the history
…nsistently
  • Loading branch information
fent committed Dec 2, 2020
1 parent 84d5118 commit e619e22
Show file tree
Hide file tree
Showing 8 changed files with 1,704 additions and 281 deletions.
12 changes: 6 additions & 6 deletions lib/info-extras.js
Original file line number Diff line number Diff line change
Expand Up @@ -108,15 +108,15 @@ exports.getAuthor = info => {
// Do nothing.
}
try {
let videoDetails = info.player_response.microformat.playerMicroformatRenderer;
let id = videoDetails.channelId || channelId;
let videoDetails = info.player_response.microformat && info.player_response.microformat.playerMicroformatRenderer;
let id = videoDetails ? videoDetails.channelId : channelId;
let author = {
id: id,
name: videoDetails.ownerChannelName,
user: videoDetails.ownerProfileUrl.split('/').slice(-1)[0],
name: videoDetails ? videoDetails.ownerChannelName : info.player_response.videoDetails.author,
user: videoDetails ? videoDetails.ownerProfileUrl.split('/').slice(-1)[0] : null,
channel_url: `https://www.youtube.com/channel/${id}`,
external_channel_url: `https://www.youtube.com/channel/${videoDetails.externalChannelId}`,
user_url: urllib.resolve(VIDEO_URL, videoDetails.ownerProfileUrl),
external_channel_url: videoDetails ? `https://www.youtube.com/channel/${videoDetails.externalChannelId}` : '',
user_url: videoDetails ? urllib.resolve(VIDEO_URL, videoDetails.ownerProfileUrl) : '',
thumbnails,
verified,
subscriber_count: subscriberCount,
Expand Down
9 changes: 8 additions & 1 deletion test/files/refresh.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,16 @@ const videos = [
transform: [
{
page: 'watch.json',
saveAs: 'no-extras',
saveAs: 'no-pmr',
fn: body => body.replace('playerMicroformatRenderer', ''),
},
{
page: 'watch.json',
saveAs: 'no-extras',
fn: body => body
.replace('playerMicroformatRenderer', '')
.replace('videoDetails', ''),
},
{
page: 'watch.html',
saveAs: 'with-cookie',
Expand Down
Loading

0 comments on commit e619e22

Please sign in to comment.