Created
April 15, 2020 21:07
-
-
Save rahul1906/082fd3e39274117f551e8395a161ca7c to your computer and use it in GitHub Desktop.
Playlist length calculator from subtitle files
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
| from glob import glob | |
| files = glob('*lang_en*') # change the regex condition here | |
| playlist_seconds = 0 | |
| for file in files : | |
| with open(file, 'r') as f: | |
| sub_title = f.read() | |
| h, m, s = sub_title.strip().split('-->')[-1].split(',')[0].strip().split(':') | |
| h, m, s = int(h), int(m), int(s) | |
| total_seconds = (h*60*60) + (m*60) + s | |
| playlist_seconds += total_seconds | |
| print(""" | |
| Total time {}h {}m | |
| """.format(playlist_seconds//3600, int(playlist_seconds%60))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment