Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Uncaught TypeError: Cannot read property 'contentDetails' of undefined #11

Open
Creativenauts opened this issue Jun 19, 2017 · 5 comments

Comments

@Creativenauts
Copy link

I continue to get the following errors:

Uncaught TypeError: Cannot read property 'contentDetails' of undefined

var b = a.items[0].contentDetails.duration,

Uncaught TypeError: Cannot read property 'high' of undefined

d += '<div class="play" data-vvv="' + b + '" data-img="' + c.items[i].snippet.thumbnails.high.url + '" title="' + c.items[i].snippet.title + '"><div class="thumb"><img src="' + c.items[i].snippet.thumbnails.default.url + '" alt=" "><span class="tm' + i + '"></span></div>';

@bachors
Copy link
Owner

bachors commented Jun 20, 2017

Can you give example of playlist id, I will try it

@Creativenauts
Copy link
Author

Here's a playlist that I'm using.

PLCVojkU9NBJ4YoJxEYu1maHNmJC_tIZHZ

I also tested on the demo site to confirm.

@bachors
Copy link
Owner

bachors commented Jun 23, 2017

Thanks @DerekBess error happened because it can not read private video. I have fixed it by adding part status to check whether the video is public or private.

Sorry if my english is not good. :)

@konstantin-petlya
Copy link

konstantin-petlya commented Jul 2, 2018

Hi, @bachors! You need to fix a bit more. If one video is 'This video is not available.' occurs the same critical error and output just a black block.

The test playlist is: https://www.youtube.com/playlist?list=PLk6n90VAXJUYJcQR_nnCs1qHn2gwWiCSY , so id: PLk6n90VAXJUYJcQR_nnCs1qHn2gwWiCSY
Look at this: http://prntscr.com/k1iylu

I guess you need to add checking for an empty (deleted etc) video item.

I tried this (https://developers.google.com/youtube/v3/docs/videos#status.uploadStatus):

if (c.items[i].status.privacyStatus == "public" && c.items[i].status.embeddable && c.items[i].status.uploadStatus == "processed" && (typeof c.items[i].status.failureReason == 'undefined')) {}

errors gone, but list show only the playlist title.

@konstantin-petlya
Copy link

I spent some time with your code and this fixes the issue:

Line 54: if (c.items[i].status.privacyStatus == "public" && (typeof c.items[i].snippet.thumbnails != "undefined")) {}

But I think better if you will fix it more fully: Skip empty/deleted/corrupted items in the list.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants