|
|
@@ -54,6 +54,8 @@ def main():
|
|
|
parser.add_argument("--file", help="Subtitle file to shift", type=str, required=True)
|
|
|
parser.add_argument("--inplace", required=False, help="Shift file in place, creating a backup", action='store_true')
|
|
|
parser.add_argument("--outfile", required=False, help="New subtitle filename", type=str)
|
|
|
+ parser.add_argument("--strip-first", required=False, help="Clear first subtitle entry", action='store_true')
|
|
|
+ parser.add_argument("--strip-last", required=False, help="Clear last subtitle entry", action='store_true')
|
|
|
|
|
|
args = parser.parse_args()
|
|
|
|
|
|
@@ -97,9 +99,20 @@ def main():
|
|
|
print(entry.formatEntry(), file=o)
|
|
|
|
|
|
print("Updating subtitle file: " + args.outfile)
|
|
|
+ lastEntryNumber = Subtitles[-1].entryNumber
|
|
|
with open(args.outfile, 'w') as o:
|
|
|
print("Shifting all entries by {} seconds".format(args.seconds))
|
|
|
- for entry in Subtitles:
|
|
|
+ for idx, entry in enumerate(Subtitles):
|
|
|
+ if idx == 0:
|
|
|
+ print("First subtitle line: {}".format(entry.text))
|
|
|
+ if args.strip_first and entry.text != "":
|
|
|
+ print("Stripping first line - {}".format(entry.text))
|
|
|
+ entry.text = ""
|
|
|
+ if idx == lastEntryNumber - 1:
|
|
|
+ print("Last subtitle line: {}".format(entry.text))
|
|
|
+ if args.strip_last and entry.text != "":
|
|
|
+ print("Stripping last line - {}".format(entry.text))
|
|
|
+ entry.text = ""
|
|
|
entry.shift(args.seconds)
|
|
|
print(entry.formatEntry(), file=o)
|
|
|
|