Skip to content

Instantly share code, notes, and snippets.

@aaronbeall
Last active August 10, 2023 19:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aaronbeall/e9403e959c1f5323ddb9fdda211d9481 to your computer and use it in GitHub Desktop.
Save aaronbeall/e9403e959c1f5323ddb9fdda211d9481 to your computer and use it in GitHub Desktop.
Total hours in YoutTube playlist
(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