finished argument support and updated todo list
This commit is contained in:
@ -1,25 +1,22 @@
|
|||||||
#!/usr/bin/python
|
#!/usr/bin/python
|
||||||
|
|
||||||
#TODO give an option to use longer version
|
|
||||||
# add subtitles download support and conversion
|
# add subtitles download support and conversion
|
||||||
# support different subtitles extensions
|
# support different subtitles extensions
|
||||||
# add video download support
|
|
||||||
# support subs and vids renaming
|
# 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
|
# 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?
|
# 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
|
# 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 re
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
from datetime import timedelta
|
from datetime import timedelta
|
||||||
|
|
||||||
# left clamps. used to make sure that eg. 00:00:02 doesn't become 23:59:52
|
# it's used to make sure that eg. 00:00:02 doesn't become 23:59:52
|
||||||
def l_clamps(t, delta):
|
def left_clamps(t, delta):
|
||||||
if t < delta:
|
if t < delta:
|
||||||
return timedelta()
|
return timedelta()
|
||||||
else:
|
else:
|
||||||
@ -27,8 +24,7 @@ def l_clamps(t, delta):
|
|||||||
|
|
||||||
# if two chunks overlap, they get merged
|
# if two chunks overlap, they get merged
|
||||||
def merge_overlap(data):
|
def merge_overlap(data):
|
||||||
prev=data[-1] # might delete this line late
|
prev=data[-1] # probably there's a better way to start this loop
|
||||||
#this also works, but for surely there's a better way to do this
|
|
||||||
for i, cur in enumerate(data):
|
for i, cur in enumerate(data):
|
||||||
if prev['fname']==cur['fname'] and prev['end'] > cur['beg'] - sides: # that means we have to merge them
|
if prev['fname']==cur['fname'] and prev['end'] > cur['beg'] - sides: # that means we have to merge them
|
||||||
cur['beg']=prev['beg']
|
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
|
if i%4 == 2 and re.search(search, line): # we only need to check lines which contain text, hence the first condition
|
||||||
data.append({
|
data.append({
|
||||||
'fname':f, #file name
|
'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
|
'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:
|
if i%4 == 1:
|
||||||
prev = line # a timestamp line
|
prev = line # a timestamp line
|
||||||
return data
|
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
|
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':
|
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
|
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
|
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
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user