-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathfix_sbv_linebreaks.py
executable file
·48 lines (36 loc) · 1.38 KB
/
fix_sbv_linebreaks.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#!/usr/bin/python3
# -*- coding: utf-8 -*-
#==============================================================================
# File: .../fix_sbv_linebreaks.py
#
# This File fixes the Youtube Fuckup when youtube syncs an sbv-File and breaks
# the lines where it shouldn't.
#
# You will need the Transcript File and the sbv File
#==============================================================================
import sys
from www.transforms import fix_sbv_linebreaks
if __name__ == '__main__':
# Check if enough arguments are given on the command line
if len(sys.argv) < 3:
sys.exit("Two files needed as input! Try again.")
transcript_file = sys.argv[1]
sbv_file = sys.argv[2]
# Check if the sbv-filename fits
if sbv_file[-4:] != ".sbv":
sys.exit("The second file has to be the *.sbv file. Try again.")
# Check the Transcript File and read it in an array
transcript = ''
try:
with open(transcript_file, 'r') as f:
transcript = f.read()
except IOError as e:
sys.exit("Transcript file is not readable or does not exist: {}".format(e))
# Check the sbv file and read it into an array
sbv = ''
try:
with open(sbv_file, 'r') as f:
sbv = f.read()
except IOError as e:
sys.exit("SBV file is not readable or does not exist: {}".format(e))
print(fix_sbv_linebreaks(transcript, sbv))