-
-
Save VijayKM01/9ea7a40ceca0c38fee6d3678bf35f22c 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 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
| /** | |
| 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 | |
| EDIT: Not all playlists have hours. | |
| */ | |
| 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