Hack Forums
[Python] Suggestions for a simple program to calculate the number of numbers and seconds in a - Printable Version

+- Hack Forums (https://hackforums.net)
+-- Forum: Tech (https://hackforums.net/forumdisplay.php?fid=444)
+--- Forum: Coding (https://hackforums.net/forumdisplay.php?fid=151)
+---- Forum: Software Development (https://hackforums.net/forumdisplay.php?fid=118)
+---- Thread: [Python] Suggestions for a simple program to calculate the number of numbers and seconds in a (/showthread.php?tid=6209234)



Suggestions for a simple program to calculate the number of numbers and seconds in a - littleblueguy24 - Jun 13, 2022

Curious as to the best way to grab the number of minutes and seconds in a Playlist on YouTube and add them all together and then print the output? Suggestions welcome .


RE: Suggestions for a simple program to calculate the number of numbers and seconds in a - Faith Connors - Jun 13, 2022

honestly i always just did it in the browser console after loading the page with the playlist and making sure all video thumbnails loaded (no lazy loading)

then get the class name of the timer on each thumbnail, for each isntance of a timer thing, get the data (string) and split it into minutes and seconds
add all minutes together, add all seconds together
minutes += seconds / 60
seconds %= 60
then you get a minutes:seconds representation, or further simplify to hours if needed.

but there's probably a browser plugin somewhere out there that calculates total runtime of a youtube playlist.

as for python specifically, probably safer to just use their api instead of making arbitrary requests to the playlist page itself


RE: Suggestions for a simple program to calculate the number of numbers and seconds in a - littleblueguy24 - Jun 14, 2022

(Jun 13, 2022 01:59 PM)Faith Connors Wrote:  honestly i always just did it in the browser console after loading the page with the playlist and making sure all video thumbnails loaded (no lazy loading)

then get the class name of the timer on each thumbnail, for each isntance of a timer thing, get the data (string) and split it into minutes and seconds
add all minutes together, add all seconds together
minutes += seconds / 60
seconds %= 60
then you get a minutes:seconds representation, or further simplify to hours if needed.

but there's probably a browser plugin somewhere out there that calculates total runtime of a youtube playlist.

as for python specifically, probably safer to just use their api instead of making arbitrary requests to the playlist page itself

Wound up doing it manually to get the answer now learning how to do it programmatically.