Last active
April 6, 2024 09:25
-
-
Save Ghost---Shadow/e11a4a0c00b7ac26f1c88418b3359c4b to your computer and use it in GitHub Desktop.
Calculate the total length of a youtube playlist. Just open javascript console, paste and press enter.
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
/** | |
USAGE | |
1. Open the playlist you want | |
2. Right click > Inspect element > Console | |
3. Copy this and paste. Hit enter. | |
4. For watch later make sure to click the Edit button | |
Make sure &disable_polymer=true flag is set | |
e.g. | |
https://www.youtube.com/playlist?list=WL&disable_polymer=true | |
*/ | |
const table = document.getElementById("pl-video-table") | |
const rows = Array.from(table.rows) | |
const toSeconds = s => s ? s.split(':').map(v => parseInt(v)).reverse().reduce((acc,e,i) => acc + e * Math.pow(60,i)) : 0 | |
const getTimestamp = row => toSeconds(row.children[6].children[0].children[0].innerText) | |
let seconds = rows.reduce((acc,e) => acc + getTimestamp(e),0) | |
let mins = parseInt(seconds / 60) | |
seconds %= 60 | |
let hours = parseInt(mins / 60) | |
mins %= 60 | |
console.log(hours+":"+mins+":"+seconds) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The scripts is useful but my use case is to have the individual video length and I modified the script a bit.
You can get download the CSV file.