Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
from pysubs2 import *
import sys
def main(argv=sys.argv):
if len(argv) <= 2:
print("Usage: python subtitle-glue.py output-file input-files")
return
subs = SSAFile()
for i in range(2, len(argv)):
try:
new_subs = load(argv[i])
for ev in new_subs:
subs.append(ev)
except Exception as e:
print("Input file exception: " + str(e) + " (" + argv[i] + ")")
return
subs.sort()
output = argv[1]
try:
subs.save(output)
except Exception as e:
print("Output file exception: " + str(e) + " (" + output + ")")
return
print("Subtitles saved successfully at " + output)
if __name__ == "__main__":
main()
@Izaron

This comment has been minimized.

Copy link
Owner Author

@Izaron Izaron commented Nov 30, 2016

Usage:

  1. Install http://pythonhosted.org/pysubs2/. Just use pip: pip install pysubs2. You can also clone the pysubs2 GitHub repository and install via python setup.py install.
  2. Download this file
  3. Run in terminal python subtitle-glue.py output-file input-files. Count of input files may be from 1 to infinity.
    Example: python subtitle-glue.py result.ass first-part.srt second-part.srt
    Supported formats are SRT, ASS, SUB.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment