damonwonghv / youtube-search-api

Get Youtube Search result without any login or api key
MIT License
86 stars 30 forks source link

Cannot read properties of undefined (reading runs) #24

Open tleylan opened 1 year ago

tleylan commented 1 year ago

I only just heard about this library and I don't quite understand the usage. I see GetListByKeyword and it returns a list based upon the key word (obviously). I am more interested in a particular video however. So I tried to call: youtubesearchapi.GetVideoDetails(

Trying several different IDs (that exist) has resulted in the following error. Looking at the library code I can see it is trying to access runs but clearly it didn't find a matching object. I don't know if any existing Video ID will work or if it has to be part of playlist, channel or some such.

Would someone clarify this please? Thanks.

TypeError: Cannot read properties of undefined (reading 'runs') at Object.GetVideoDetails (D:\Repos\tube-api\node_modules\youtube-search-api\index.js:273:46) at processTicksAndRejections (node:internal/process/task_queues:95:5) at async D:\Repos\tube-api\src\app.ts:178:22

jackkingham-au commented 1 year ago

Can also confirm I'm getting the same error, using .GetVideoDetails(). Any help would be appreciated 🙂.

damonwonghv commented 1 year ago

Can you guys provide the Id you tested before?

damonwonghv commented 1 year ago

I tested some videos on youtube, it did not prompt any error. Please provide me with the Video ID.

Finalet commented 1 year ago

I am also getting an error (sometimes) on some video IDs when calling .GetVideoDetails(). Specifically, this ID jbnddQ9l0IA.

Error:

TypeError: Cannot read properties of undefined (reading 'twoColumnWatchNextResults')
    at Object.GetVideoDetails ({my_project}\node_modules\youtube-search-api\index.js:259:49)
    at processTicksAndRejections (node:internal/process/task_queues:95:5)

Sometimes initdata.contents.twoColumnWatchNextResults exists and everything works as expected, but other timers it returns initdata only with responseContext object, like below, which causes the error above. This happens once in around 5 times, while using the same video ID.

initdata: { responseContext: { webResponseContextExtensionData: [Object] } },
developerTested commented 1 year ago

I'm also getting same error when on initdata.contents.twoColumnWatchNextResults it occurred if same request sent again.