Skip to content

Instantly share code, notes, and snippets.

@rgson
Created February 9, 2019 21:16
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 rgson/9ad3b42244ed4bde6fb0e211bde1587f to your computer and use it in GitHub Desktop.
Save rgson/9ad3b42244ed4bde6fb0e211bde1587f to your computer and use it in GitHub Desktop.
Calculates the total duration of a YouTube playlist.
/*
Calculates the total duration of a YouTube playlist.
Run the snippet in Chrome Dev Tools while on the playlist's page,
e.g. https://www.youtube.com/playlist?list=WL
Ensure that the playlist is fully visible first.
Long playlists are loaded 100 videos at a time.
*/
new Date(1000 *
[...document.getElementsByTagName('ytd-thumbnail-overlay-time-status-renderer')]
.map(e => e
.textContent
.split(':')
.reverse()
.map((n, i) => n * Math.pow(60, i)))
.flat()
.reduce((a, b) => a + b, 0))
.toISOString()
.substr(11, 8);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment