Last active
August 8, 2021 07:03
-
-
Save KiaraGrouwstra/f5b6dc6d26cbb3a5ebd4ba3a579acfa5 to your computer and use it in GitHub Desktop.
Youtube playlist duration
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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