Skip to content

Instantly share code, notes, and snippets.

@KiaraGrouwstra
Last active August 8, 2021 07:03
Show Gist options
  • Save KiaraGrouwstra/f5b6dc6d26cbb3a5ebd4ba3a579acfa5 to your computer and use it in GitHub Desktop.
Save KiaraGrouwstra/f5b6dc6d26cbb3a5ebd4ba3a579acfa5 to your computer and use it in GitHub Desktop.
Youtube playlist duration
// run on the page of a Youtube playlist to obtain the total playlist time in hours
Array.from(document.getElementsByClassName('ytd-thumbnail-overlay-time-status-renderer'))
.map(x=> {
var nums = x.innerText.split(':').map(Number);
var [h, m, s] = nums[2] !== undefined ? nums : [0, ...nums];
return 3600*h+60*m + s;
})
.reduce((a,b)=>a+b) / 3600
// also see: https://www.quora.com/How-can-the-full-duration-time-of-a-YouTube-playlist-be-obtained
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment