Reputation: 25
I have a YouTube playlist with 371 videos in it that each are meant to be shown on a particular day of the year.
The code looks like this for any one video:
<iframe width="560" height="315" src="https://www.youtube.com/embed/z7plt65m0Ts" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>
But I'd need to switch out the URL parameter immediately after the embed/ spot with the corresponding piece from the video of that day.
Is there a way to do this that will enable me to set the first video's date from year to year so that the days continue to match up each subsequent year as well?
Not sure if this info is needed, but the link for each story's day is here and the link for the entire youtube playlist is here
Thanks for absolutely any help. I truly hope this is possible.
Upvotes: 0
Views: 96
Reputation: 62
Try this... Using javascript.
var today = new Date();
var dd = String(today.getDate()).padStart(2, '0');
var mm = String(today.getMonth() + 1).padStart(2, '0'); //January is 0!
var yyyy = today.getFullYear();
today = mm + '/' + dd + '/' + yyyy;
if(today == "07/07/2022"){
$("iframe").attr('src','https://www.youtube.com/embed/z7plt65m0Ts');
}else if(today == "08/29/21"){
$("iframe").attr('src','some another video url');
}else if(today == "08/30/21"){
$("iframe").attr('src','some another video url');
}
Upvotes: 1