-
-
Save rbrito/dd9bd1efd253d6233d5f2af976f6b3d9 to your computer and use it in GitHub Desktop.
Remove duplicate subtitles with aeidon
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
#!/usr/bin/env python3 | |
import aeidon, sys, time | |
if len(sys.argv) < 2: | |
print("Usage: {} SUBTITLE_FILE...".format(__file__)) | |
raise SystemExit(1) | |
for fname in sys.argv[1:]: | |
print("{}:".format(fname)) | |
project = aeidon.Project() | |
project.open_main(fname, "utf_8") | |
before = len(project.subtitles) | |
for i in range(before - 1, 1, -1): | |
if project.subtitles[i] == project.subtitles[i-1]: | |
del project.subtitles[i] | |
after = len(project.subtitles) | |
print("Removed {:d} subtitles.".format(before - after)) | |
ext = project.main_file.format.extension | |
project.main_file.path = project.main_file.path[:-len(ext)] | |
project.main_file.path += ".{:.0f}{}".format(time.time(), ext) | |
print(project.main_file.path) | |
project.save_main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment