Reputation: 2392
I've encountered an issue with YouTube embed urls that have a large number of video ids in the playlist parameter. For example: https://www.youtube.com/embed/VIDEOID1?playlist=VIDEOID2,VIDEOID3,...,VIDEOID20
On the first load, it works, but if I refresh, it says "This video is unavailable". I then tried in other browsers, and on a different computer, and got the same error right away. I waited a few days and tried again, and it worked one time, and then went back to the error. Changing the videos in the list also has the same effect: for each unique list, it works once and then errors out. This only happens with a larger number of videos.
Digging into the html responses and doing a comparison between the times it works and the times it doesn't, I found that there is a PLAYER_VARS object in the JS on the page, and it contains a "list" property when it works, but that property is missing for the times the error occurs. I also found that the value of the "list" property can be used as a query string parameter to the embed url ("list" query string parameter), and that works consistently.
Is this a known bug and/or is there a way to work around it? The evidence seems to suggest some kind of server-side caching problem on the YouTube side.
Upvotes: 1
Views: 1198
Reputation: 1080
Looks like the supported query string is ?list=
. Such as:
https://www.youtube.com/embed/5gwJI7KSygA?list=PLsZLp_pMhGGXQmVVgP8zlSjp167bU3TQI
https://www.youtube-nocookie.com/embed/5gwJI7KSygA?list=PLsZLp_pMhGGXQmVVgP8zlSjp167bU3TQI
(privacy friendly alternative)Here's how you would embed the video with the playlist parameter:
<iframe
title="Video title goes here"
show-info="O"
src="https://www.youtube.com/embed/5gwJI7KSygA?list=PLsZLp_pMhGGXQmVVgP8zlSjp167bU3TQI"
frameborder="0"
allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture"
allowfullscreen="true"
loading="lazy"
></iframe>
Upvotes: 0
Reputation: 2392
The cause of this problem turned out to be the inclusion of a couple of videos marked private in the playlist.
Upvotes: 1