Created
November 30, 2016 19:31
-
-
Save Izaron/3b5f8319b1c17128dd3421dfed4d4db7 to your computer and use it in GitHub Desktop.
This file contains 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 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() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Usage:
pip install pysubs2
. You can also clone the pysubs2 GitHub repository and install viapython setup.py install
.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.