more cleaning up

This commit is contained in:
kolaczyn
2020-06-24 23:58:40 +02:00
parent 0bb0341445
commit 09553ed73c
2 changed files with 20 additions and 17 deletions

View File

@ -5,28 +5,28 @@ import os
import time import time
from datetime import datetime, timedelta from datetime import datetime, timedelta
# # TODO:
# remove not used imports
# searched string is hardcoded. fix that
# make it so the script rips ~10 second before the subtitle and 10 seconds after
# implement overlaping chunks recognition
path = os.getcwd() + '/../subs/' # subtitles location
file_names = [] file_names = []
path = os.getcwd() + '/../subs/' # location of subtitles for file in os.listdir(path):
file_names.append(file)
file_names.sort() # not necessary, but it makes the generated script look better
for file_name in os.listdir(path): data =[]
file_names.append(file_name)
file_names.sort() # not necessary, but it makes generated files look better
data =[];
for f in file_names: for f in file_names:
file = open(path+f) file = open(path + f)
for i, line in enumerate(file): for i, line in enumerate(file):
if re.search('(pesky|bird)', line): if re.search('(pesky|bird)', line):
data.append([f, prev[0:8], prev[17:25], line]) data.append({'fname': f, 'beg': prev[0:8], 'end': prev[17:25], 'desc': line}) # get file name, time stamps and desciption
prev=line prev = line
for d in data:
print(d)
#
#
# datestring1 = data[-1][1] # datestring1 = data[-1][1]
# datestring2 = data[-1][2] # datestring2 = data[-1][2]
# #
@ -35,9 +35,9 @@ for d in data:
# #!!!! start = time.mktime(t1)-time.mktime(t2) # #!!!! start = time.mktime(t1)-time.mktime(t2)
# #!!!! print # #!!!! print
# #
# out_file = open('script.sh', 'w') # out_file = open('rip.sh', 'w')
# out_list = open('list.txt', 'w') # out_list = open('list.txt', 'w')
# for i,t in enumerate(data): # for (i, t) in enumerate(data):
# name = t[0][:2] # name = t[0][:2]
# vid_fil = 'out/'+ name + '-' + str(i)+'.mp4' # vid_fil = 'out/'+ name + '-' + str(i)+'.mp4'
# out_list.write('file \'' + vid_fil + "'\n") # out_list.write('file \'' + vid_fil + "'\n")

5
run.sh
View File

@ -1,6 +1,9 @@
#!/bin/bash #!/bin/bash
# TODO make it so the only data you need to feed the application
# is an URL of a youtube playlist/ video you want to edit
python gen-script.py python gen-script.py
bash rip.bash bash rip.bash
ffmpeg -f concat -safe 0 -i list.txt -c copy output.mp4 # splice all the clips ffmpeg -f concat -safe 0 -i list.txt -c copy output.mp4 # splice all the clips
rm list.txt rip.sh rm list.txt rip.sh # cleanup