Skip to content

Instantly share code, notes, and snippets.

@coderobe
Last active March 23, 2024 20:28
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 coderobe/65db029255122de630c4498daeb4ec86 to your computer and use it in GitHub Desktop.
Save coderobe/65db029255122de630c4498daeb4ec86 to your computer and use it in GitHub Desktop.
get total content play time of a youtube playlist in seconds
// open a playlist, or Watch Later (https://www.youtube.com/playlist?list=WL)
// run. doesn't work? that means the playlist is truncated. scroll all the way down and try again.
// output is in seconds. divide by 3600 for fractional hours.
ytInitialData[b="contents"]["twoColumnBrowseResults"+(i="Renderer")]
.tabs[0]["tab"+i]
.content["sectionList"+i][b][0]["itemSection"+i][b][0][(g="playlistVideo")+"List"+i][b]
.reduce((N,y,_,a)=>a[(z=y[g+i]).videoId]??=N+=+z.lengthSeconds,0)
// authors: coderobe, ilbelkyr
@coderobe
Copy link
Author

this snippet is small enough to fit in a tweet btw
https://twitter.com/coderobe/status/1771631600024895952

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment