Added converting all videofiles to .mkv

main
Jan Beníček 2024-07-06 21:58:33 +02:00
parent 77769157e6
commit 41726dff31
1 changed files with 17 additions and 5 deletions

View File

@ -41,12 +41,22 @@ def copy_file(source: str, destination: str):
def process_file(source_dir: str, file: str): def process_file(source_dir: str, file: str):
outputdir = source_dir.replace(conf.sourcedir, conf.outputdir) outputdir = source_dir.replace(conf.sourcedir, conf.outputdir)
av1file = f"AV1_{file}" outputfile = file
if videofile_test(file=file) and not outputfile.endswith(".mkv"):
name = outputfile.split(".")
name[len(name) - 1] = ".mkv"
filename = ""
for a in name:
filename = filename + a
outputfile = filename
av1file = f"AV1_{outputfile}"
if not os.path.exists(outputdir): if not os.path.exists(outputdir):
os.makedirs(outputdir) # create dir if not exist os.makedirs(outputdir) # create dir if not exist
if os.path.exists(os.path.join(outputdir, file)): if os.path.exists(os.path.join(outputdir, outputfile)):
print("Output File Exist --> Skipping") print("Output File Exist --> Skipping")
return False return False
@ -65,9 +75,11 @@ def process_file(source_dir: str, file: str):
) )
print( print(
f"Move video file: {os.path.join(conf.workdir, av1file)} --> {os.path.join(outputdir, file)}" f"Move video file: {os.path.join(conf.workdir, av1file)} --> {os.path.join(outputdir, outputfile)}"
)
copy_file(
os.path.join(conf.workdir, av1file), os.path.join(outputdir, outputfile)
) )
copy_file(os.path.join(conf.workdir, av1file), os.path.join(outputdir, file))
os.remove(os.path.join(conf.workdir, av1file)) os.remove(os.path.join(conf.workdir, av1file))
os.remove(os.path.join(conf.workdir, file)) os.remove(os.path.join(conf.workdir, file))