Skip to content

Instantly share code, notes, and snippets.

@rbrito
Forked from otsaloma/remove-duplicate-subs
Created June 24, 2017 16:03
Show Gist options
  • Save rbrito/dd9bd1efd253d6233d5f2af976f6b3d9 to your computer and use it in GitHub Desktop.
Save rbrito/dd9bd1efd253d6233d5f2af976f6b3d9 to your computer and use it in GitHub Desktop.
Remove duplicate subtitles with aeidon
#!/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