finished argument support and updated todo list

This commit is contained in:
kolaczyn
2020-07-11 12:39:34 +02:00
parent f75aa85d6c
commit 455dfeabf2
2 changed files with 9 additions and 13 deletions

View File

@ -1,25 +1,22 @@
#!/usr/bin/python
#TODO give an option to use longer version
# add subtitles download support and conversion
# support different subtitles extensions
# add video download support
# support subs and vids renaming
# make program organize file
# add alternative versions
# passing arguments into program; get rid of hardcoded values
# add debug file, I removed the old one because it wasnt working correctly
# check if you tell ffmpeg after the video is over - how does it handle it?
# if yes, add r_clamp(.). I would have to get the length of the videos
# handler error whene there are no fragments/ there's only one in function merge_overlap
import re
import os
import sys
from datetime import timedelta
# left clamps. used to make sure that eg. 00:00:02 doesn't become 23:59:52
def l_clamps(t, delta):
# it's used to make sure that eg. 00:00:02 doesn't become 23:59:52
def left_clamps(t, delta):
if t < delta:
return timedelta()
else:
@ -27,8 +24,7 @@ def l_clamps(t, delta):
# if two chunks overlap, they get merged
def merge_overlap(data):
prev=data[-1] # might delete this line late
#this also works, but for surely there's a better way to do this
prev=data[-1] # probably there's a better way to start this loop
for i, cur in enumerate(data):
if prev['fname']==cur['fname'] and prev['end'] > cur['beg'] - sides: # that means we have to merge them
cur['beg']=prev['beg']
@ -45,9 +41,9 @@ def generate_splice_data(file_names):
if i%4 == 2 and re.search(search, line): # we only need to check lines which contain text, hence the first condition
data.append({
'fname':f, #file name
'beg':l_clamps(timedelta(minutes = int(prev[3 :5]), seconds=int(prev[6: 8])), sides), #beginning timestamp
'beg':left_clamps(timedelta(minutes = int(prev[3 :5]), seconds=int(prev[6: 8])), sides), #beginning timestamp
'end':timedelta(minutes = int(prev[20:22]), seconds=int(prev[23:25])) + sides, #ending timestamp
'desc':line[:-1]}) #lines said
'desc':line[:-1]}) #said lines
if i%4 == 1:
prev = line # a timestamp line
return data
@ -71,7 +67,7 @@ def write_list_rip(data):
file_rip.write('ffmpeg -i ../original/{}.mp4 -ss 0{} -t 0{} -async 1 {}\n'.format(name, d['beg'], delta ,outname)) # slow but more accurate
elif sys.argv[2] =='fast':
true_beg = l_clamps(d['beg'], back)
true_beg = left_clamps(d['beg'], back)
d1 = d['beg'] - true_beg # we have to do it his was just in case the clip is at the beginning
file_rip.write('ffmpeg -ss 0{} -i ../original/{}.mp4 -ss 0{} -t 0{} -c copy {}\n'.format(true_beg, name, d1, delta, outname)) # fast but not accurate

2
run.sh
View File

@ -1,5 +1,5 @@
#!/bin/bash
sh clean.sh
python gen-script.py
python gen-script.py "$1" "$2"
sh rip.sh