save before yet another refactor

This commit is contained in:
kolaczyn
2020-06-25 03:44:58 +02:00
parent e92e591a78
commit a04b35f014
2 changed files with 25 additions and 4 deletions

View File

@ -1,13 +1,27 @@
#!/usr/bin/python
import re
from pathlib import Path
import os
from datetime import timedelta
search = '(pesky|bird)' # the searched phrase
sides = 6 # how much do we to both sides of a fragment
#now sides cant be bigger than 29, because of the way i hardcoded it somewhere
# to make sure that 00:00:02 doesn't become 23:59:42
def clamps(t):
if (t<timedelta(seconds=sides)):
return timedelta()
else:
return t
# if
# def merge_overlap(data): # if two chunks overlap, they get merged
# for (i, d) in enumerate(data):
# if(prev['fname']==d['fname']):
# if
# prev = d
# make it so the script rips ~10 second before the subtitle and 10 seconds after
# implement overlaping chunks recognition
# use regex instead of hardcoding
path = os.getcwd() + '/../subs/' # subtitles location
file_names = []
@ -32,8 +46,14 @@ file_rip.write('#!/bin/bash\n')
for (i, d) in enumerate(data):
name = d['fname'][:2] # get a name without an extension
outname ="../out/{}-{:0>2}.mp4".format(name, i)
# refactor time thingy and get rid of hardcoding
time_beg = '0' + str(clamps((timedelta(minutes=int(d['beg'][3:5]), seconds=int(d['beg'][6:8]))-timedelta(seconds=sides))))
time_end = '0' + str(clamps((timedelta(minutes=int(d['end'][3:5]), seconds=int(d['end'][6:8]))+timedelta(seconds=sides))))
file_list.write("file '{}'\n".format(outname))
file_rip .write('ffmpeg -ss {} -i ../original/{}.mp4 -to 00:00:12 -c copy {}\n'.format(d['beg'], name, outname))
file_rip .write('ffmpeg -ss {} -i ../original/{}.mp4 -to 00:00:{} -c copy {}\n'.format(time_beg, name, sides*2,outname))
# file_rip .write('ffmpeg -ss {} -i ../original/{}.mp4 -to 00:00:12 -c copy {}\n'.format(d['beg'], name, outname))
file_debug = open('debug.txt', 'w')