SuspiciousLookingOwl/youtubei

Failing to fetch videos

Closed this issue · 9 comments

Hello first of all kudos for this library and thanks for all your work, allow me to ask some questions...

I had the following code working about a week ago, no it fails to fetch videos..

await youtube.findOne(channel, { type: 'channel' });

Gives the following object

////////////////////////////////////////////////////////
BaseChannel {
client: Client {
http: HTTP {
cookie: 'CONSENT=PENDING+423; expires=Sun, 27-Oct-2024 19:56:32 GMT; path=/; domain=.youtube.com; Secure',
defaultHeaders: [Object],
defaultFetchOptions: {},
defaultClientOptions: [Object]
}
},
videos: ChannelVideos {
client: Client { http: [HTTP] },
items: [],
strictContinuationCheck: true,
continuation: null,
channel: [Circular *1]
},
playlists: ChannelPlaylists {
client: Client { http: [HTTP] },
items: [],
strictContinuationCheck: true,
continuation: null,
channel: [Circular *1]
},
id: 'UCItHdUEqlpfvDlcCeyZwH6w',
name: 'Men of the West',
thumbnails: Thumbnails(2) [
{
url: '//yt3.ggpht.com/dDiX7N6tEMWmKHBWTKkdQmKXdUupGPt9jgpbpR7ODMe7mnfdKP4StAUE-5DzEt6s4dulieQp=s88-c-k-c0x00ffffff-no-rj-mo',
width: 88,
height: 88
},
{
url: '//yt3.ggpht.com/dDiX7N6tEMWmKHBWTKkdQmKXdUupGPt9jgpbpR7ODMe7mnfdKP4StAUE-5DzEt6s4dulieQp=s176-c-k-c0x00ffffff-no-rj-mo',
width: 176,
height: 176
}
],
videoCount: 336,
subscriberCount: '371K subscribers'
}
////////////////////////////////////////////////////////

When then trying to fetch all videos..

await channelInfo.videos.next(0);

Throws the following error

TypeError: Cannot read properties of undefined (reading '0')
at Function.parseTabData (C:\Code\Discord bot\yadb\node_modules\youtubei\dist\cjs\classes\BaseChannel\BaseChannelParser.js:24:118)
at ChannelVideos. (C:\Code\Discord bot\yadb\node_modules\youtubei\dist\cjs\classes\BaseChannel\ChannelVideos.js:47:65)
at Generator.next ()
at fulfilled (C:\Code\Discord bot\yadb\node_modules\youtubei\dist\cjs\classes\BaseChannel\ChannelVideos.js:5:58)
at processTicksAndRejections (node:internal/process/task_queues:96:5)

Is this a cookie issue ? Am I maxed out on requests ? That's why videos are coming up as null ?? Any idea ?

I can't consistently reproduce this, sometimes it throws an error when I do channel.videos.next(0), and sometimes it doesn't, I will investigate further

const channel = await client.findOne("...", { type: "channel" });
await channel?.videos.next();

I suspect this is caused by the recent YouTube update which separates "Shorts" and "Lives" videos into its own tabs on channel page (instead of putting them together on "Videos" tab), and since YouTube doesn't push this update to all users at once, it's hard to adjust the parser for the new update.

ovnro commented

Same problem here!
Is there a fix for this?

@SuspiciousLookingOwl Thanks for the info. Do you recommend any fixes then ? Any workarounds ?

This commit should solve this issue, can you guys give it a try and let me know if it's working well?

You can install the latest dev branch by running npm i git://github.com/suspiciouslookingowl/youtubei.git#dist (you might need to npm uninstall youtubei first)

ovnro commented

Hello,

I can confirm that the fix works.
Thank you very much!

Thanks @SuspiciousLookingOwl. Does YT randomly just change the "rendererer" data? 😆

Not really "randomly", it's usually when they updated something on the UI

Available on v1.0.0-rc.6

Thanks @SuspiciousLookingOwl , I also note it has been fixed on my side.