Update fansub-util repository

This commit is contained in:
LightArrowsEXE 2019-07-16 13:41:24 +02:00
parent dbbe0f9486
commit b712c60cbd
6 changed files with 111 additions and 14 deletions

View file

@ -2,7 +2,7 @@
"""
This script appends CRC-32s to the end of the files in a directory.
This is intended for anime fansubbing releases.
You can change what it checks by modifying the 'ext' (extension) on L46.
You can change what it checks by modifying the 'ext' (extension) on L47.
Can be run both from the command line, and imported.
"""
import argparse
@ -45,4 +45,4 @@ if __name__ == "__main__":
parser.parse_args()
args = parser.parse_args()
ext = '*.mkv'
main(ext, args.recursive)
main(ext, args.recursive)

View file

@ -1,3 +1,4 @@
#!/usr/bin/env python
"""
Encodes audio from m2ts sources
@ -28,8 +29,8 @@ else:
for f in filelist:
print(f)
if not re.search(r'\.(wav|m4a|flac)$', f):
subprocess.call(["ffmpeg", "-hide_banner", "-loglevel", "panic", f"-i", f,"-vn", f"{os.path.splitext(f)[0]}.wav"])
if not re.search(r'\.(wav|m4a|flac|lwi)$', f):
subprocess.call(["ffmpeg", "-hide_banner", "-loglevel", "panic", "-i", f,"-vn", f"{os.path.splitext(f)[0]}.wav"])
if not os.path.exists(f'{f[0]}.m4a') or os.path.exists(f'{f[0]}.flac'):
if args.flac:
subprocess.call(["ffmpeg", "-hide_banner", "-i", f"{os.path.splitext(f)[0]}.wav", "-vn", "-c:a flac", "-sample_fmt s16","compression_level 12", f"{os.path.splitext(f)[0]}.flac"])
@ -44,5 +45,3 @@ for f in filelist:
os.remove(f"{os.path.splitext(f)[0]}.wav")
except OSError:
pass

View file

@ -17,8 +17,8 @@ def generate_keyframes():
else:
files = glob.glob('*')
if args.ext:
ext_in = args.ext
if args.extension:
ext_in = args.extension
else:
ext_in = "mkv"
@ -48,6 +48,6 @@ if __name__ == "__main__":
parser = argparse.ArgumentParser()
parser.add_argument("-R", "--recursive",
help="check recursively", action="store_true")
parser.add_argument("-E", "--ext", help="pick extension to generate keyframes for")
parser.add_argument("-E", "--extension", help="pick extension to generate keyframes for")
args = parser.parse_args()
generate_keyframes()

View file

@ -11,7 +11,8 @@ import os
import time
parser = argparse.ArgumentParser()
parser.add_argument("-R", "--recursive", help="check recursively", action="store_true")
parser.add_argument("-R", "--recursive",
help="check recursively", action="store_true")
parser.add_argument("-E", "--extension", help="change extension")
args = parser.parse_args()
@ -37,7 +38,8 @@ for f in filelist:
cleaned_directory = os.path.join(os.getcwd(), new_directory)
if not os.path.exists(cleaned_directory):
os.makedirs(new_directory)
print(f"Created a new directory. Moving cleaned files into {cleaned_directory}")
print(
f"Created a new directory. Moving cleaned files into {cleaned_directory}")
shutil.copy(f, cleaned_directory)
os.remove(f)
except Exception:
@ -52,9 +54,9 @@ if args.recursive:
filelist = glob.glob('**/*', recursive=True)
else:
filelist = glob.glob('*')
for f in filelist:
print(f"'{f}'")
print('\n\nPlease ensure that all the relevant files are included')
print('\n\nPlease ensure that all the relevant files are included')

View file

@ -0,0 +1,41 @@
"""
Cleaning encoding directory of everything but vpy's and py's.
Please note that this does NOT remove empty directories and does not have ANY exceptions. It will only keep mkv's.
"""
import argparse
import glob
import shutil
import os
import time
parser = argparse.ArgumentParser()
parser.add_argument("-R", "--recursive",
help="check recursively", action="store_true")
parser.parse_args()
args = parser.parse_args()
if args.recursive:
filelist = glob.glob('**\*.*', recursive=True)
else:
filelist = glob.glob('*.*')
for f in filelist:
if f.endswith('.py') or f.endswith('.vpy'):
if os.path.isfile(f):
try:
shutil.copy(f, os.getcwd())
os.remove(f)
print(f"Moving '{f}' to current directory.")
except Exception:
pass
else:
os.remove(f)
print(f"Cleaned '{f}'")
print('-------------------------------------------------\nPrinting remaining files in directory...')
time.sleep(3)
print('-------------------------------------------------\nRemaining files:\n\n')
for f in filelist:
print(f"'{f}'")
print('\n\nPlease ensure that all the relevant files are included.')

55
remux.py Normal file
View file

@ -0,0 +1,55 @@
#!/usr/bin/env python
"""
Generic script for remuxing files from a certain filetype into another.
Flags:
-R - Check recursively
-i - change input extension
-o - change output extension
TO-DO: clean up
"""
import os
import glob
import argparse
import subprocess
import time
parser = argparse.ArgumentParser()
parser.add_argument("-R", "--recursive",
help="check recursively", action="store_true")
parser.add_argument("-i", "--input_ext",
help="set input's extension (default: mkv)")
parser.add_argument("-o", "--output_ext",
help="set output's extension (default: mp4)")
args = parser.parse_args()
if args.recursive:
filelist = glob.glob('**/*', recursive=True)
else:
filelist = glob.glob('*')
if args.input_ext:
ext_in = args.input_ext
if ext_in.startswith("."):
ext_in = ext_in[1:]
else:
ext_in = "mkv"
if args.output_ext:
ext_out = args.output_ext
if ext_out.startswith("."):
ext_out = ext_out[1:]
else:
ext_out = "mp4"
print(f"Remuxing all {ext_in} to {ext_out}\n")
time.sleep(1)
for f in filelist:
if f.endswith(ext_in):
subprocess.call(["ffmpeg", "-hide_banner", "-loglevel", "panic", "-i", f"{os.path.splitext(f)[0]}.{ext_in}", "-c", "copy", f"{os.path.splitext(f)[0]}.{ext_out}"])
print(f"Remuxing:\n{f} ->\n{os.path.splitext(f)[0]}.{ext_out}\n")
else:
pass