Last active
August 10, 2023 19:49
-
-
Save aaronbeall/e9403e959c1f5323ddb9fdda211d9481 to your computer and use it in GitHub Desktop.
Total hours in YoutTube playlist
This file contains hidden or 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
(Array.from(document.querySelectorAll("#time-status #text")).map(node => node.textContent).reduce((total, text) => { | |
const [sec, min, hr = 0] = text.split(":").reverse(); | |
return total + (parseInt(hr) * 60 * 60) + (parseInt(min) * 60) + parseInt(sec); | |
}, 0) / 60 / 60).toFixed(2); | |
// Example - https://www.youtube.com/playlist?list=PLvqxe4XbcSiErm2kHuldndImavib9wh8c | |
// Result: '55.51' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment