Old changes
This commit is contained in:
3
deportfolio.sh
Normal file
3
deportfolio.sh
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
# Helper for unfucking Adobe's stupid Portfolios
|
||||||
|
# TODO: Currently only merges, can we automatically extract?
|
||||||
|
pdftk $(ls -1v) cat output $1
|
||||||
@@ -115,53 +115,54 @@ def do():
|
|||||||
print("Using destreamer.js at {}".format(path_to_destreamer))
|
print("Using destreamer.js at {}".format(path_to_destreamer))
|
||||||
call("node --max-http-header-size 32768 {} --skip -k -o {} -i {}".format(path_to_destreamer, downloaded, " ".join(urls)), shell=True)
|
call("node --max-http-header-size 32768 {} --skip -k -o {} -i {}".format(path_to_destreamer, downloaded, " ".join(urls)), shell=True)
|
||||||
for entry in os.scandir(downloaded):
|
for entry in os.scandir(downloaded):
|
||||||
# Normalise names
|
|
||||||
# Put file extension to one side for safekeeping
|
# Put file extension to one side for safekeeping
|
||||||
split = entry.name.split('.')
|
split = entry.name.split('.')
|
||||||
extension = split[1]
|
extension = split[1]
|
||||||
name = split[0].replace(',', '').split('#')[0] # Discard all commas, and unique id doodad
|
if str(extension) == "mkv":
|
||||||
head, sep, tail = name.partition(' ') # Discard leading date
|
# Normalise names
|
||||||
split2 = tail.split()
|
name = split[0].replace(',', '').split('#')[0] # Discard all commas, and unique id doodad
|
||||||
date = dparser.parse(split2[-1], fuzzy=True) # Parse the date
|
head, sep, tail = name.partition(' ') # Discard leading date
|
||||||
folder_path = split2[0] + split2[1] # TODO Fragile
|
split2 = tail.split()
|
||||||
title = re.search(r'\d+-\d+\s[\d\w\s]*', tail)
|
date = dparser.parse(split2[1], fuzzy=True) # Parse the date
|
||||||
if re.match:
|
folder_path = split2[0] + split2[1] # TODO Fragile
|
||||||
title = title.group(0).strip().replace(' ', '_')
|
title = re.search(r'\d+-\d+\s[\d\w\s]*', tail)
|
||||||
# Add date back
|
if re.match:
|
||||||
if date is not None:
|
title = title.group(0).strip().replace(' ', '_')
|
||||||
title += "_" + date.strftime('%Y-%m-%d')
|
# Add date back
|
||||||
# Rename file
|
if date is not None:
|
||||||
source = entry.path
|
title += "_" + date.strftime('%Y-%m-%d')
|
||||||
filename = "{}.{}".format(title, extension)
|
# Rename file
|
||||||
dest = os.path.abspath(renamed + "/" + filename)
|
source = entry.path
|
||||||
print ("Source: " + source)
|
filename = "{}.{}".format(title, extension)
|
||||||
print ("Dest: " + dest)
|
dest = os.path.abspath(renamed + "/" + filename)
|
||||||
shutil.copy(source, dest)
|
print ("Source: " + source)
|
||||||
time.sleep(5)
|
print ("Dest: " + dest)
|
||||||
# Extract audio, process it, add it back to the video
|
shutil.copy(source, dest)
|
||||||
video_in = dest
|
time.sleep(5)
|
||||||
processed_audio = os.path.join(processed_audio_dir, filename.split(".")[0] + ".wav")
|
# Extract audio, process it, add it back to the video
|
||||||
final_output_name = os.path.join(final, filename.split(".")[0] + ".mp4")
|
video_in = dest
|
||||||
do_command("New:")
|
processed_audio = os.path.join(processed_audio_dir, filename.split(".")[0] + ".wav")
|
||||||
do_command("Import2: Filename={}".format(video_in))
|
final_output_name = os.path.join(final, filename.split(".")[0] + ".mkv")
|
||||||
time.sleep(5)
|
do_command("New:")
|
||||||
do_command("SelectAll:")
|
do_command("Import2: Filename={}".format(video_in))
|
||||||
do_command('Amplify: Ratio=2')
|
time.sleep(5)
|
||||||
time.sleep(1)
|
do_command("SelectAll:")
|
||||||
do_command("SelectAll:")
|
do_command('Amplify: Ratio=2')
|
||||||
do_command('Popmute: thresh=10 floor=100')
|
time.sleep(1)
|
||||||
time.sleep(1)
|
do_command("SelectAll:")
|
||||||
do_command("Export2: Filename={} NumChannels=2".format(processed_audio))
|
do_command('Popmute: thresh=10 floor=100')
|
||||||
time.sleep(5)
|
time.sleep(1)
|
||||||
do_command("SelectAll:")
|
do_command("Export2: Filename={} NumChannels=2".format(processed_audio))
|
||||||
do_command("RemoveTracks:")
|
time.sleep(5)
|
||||||
time.sleep(5)
|
do_command("SelectAll:")
|
||||||
# do_command('Close:') TODO THis causes audacity to wait for a input
|
do_command("RemoveTracks:")
|
||||||
# final_output_name = "output-" +
|
time.sleep(5)
|
||||||
# TODO Folderisation of output by lecture
|
# do_command('Close:') TODO THis causes audacity to wait for a input
|
||||||
print("Combining video at {} with audio at {}".format(video_in, processed_audio))
|
# final_output_name = "output-" +
|
||||||
# https://superuser.com/questions/277642/how-to-merge-audio-and-video-file-in-ffmpeg
|
# TODO Folderisation of output by lecture
|
||||||
call('ffmpeg -i {} -i {} -acodec copy -vcodec copy -map 0:v:0 -map 1:a:0 {}'.format(video_in, processed_audio, final_output_name), shell=True)
|
print("Combining video at {} with audio at {}".format(video_in, processed_audio))
|
||||||
print("\033[92mDone! Result is at {}\e[0m".format(final_output_name))
|
# https://superuser.com/questions/277642/how-to-merge-audio-and-video-file-in-ffmpeg
|
||||||
|
call('ffmpeg -i {} -i {} -acodec copy -vcodec copy -map 0:v:0 -map 1:a:0 {}'.format(video_in, processed_audio, final_output_name), shell=True)
|
||||||
|
print("\033[92mDone! Result is at {}\e[0m".format(final_output_name))
|
||||||
print("Munging complete!!!")
|
print("Munging complete!!!")
|
||||||
do()
|
do()
|
||||||
|
|||||||
Reference in New Issue
Block a user