Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ### WINDOWS ONLY ATM ###
- ### IMPORTS ###
- import glob
- import os
- import subprocess
- from time import strftime
- from multiprocessing import Pool
- from colorama import init, Fore, Back, Style
- ### INITIATION ###
- init()
- print(Style.BRIGHT)
- ### WELCOME ###
- print(Fore.CYAN + 'Welcome to ' + Fore.BLUE + 'MKVree' + Fore.CYAN + '! :D' + Fore.RESET + '\n')
- ### FUNCTION ###
- def convert(file, mkvmerge_path, mkvmerge_args_raw):#, log):
- if file.count('_fix') == 0:
- print(Fore.WHITE + '> Started work on ' + file + '.')
- mkvmerge_args = mkvmerge_args_raw.replace('{FILE}', file[:-4]) # replace placeholders; cut .mkv from the filename
- convertCMD = mkvmerge_path + ' ' + mkvmerge_args
- subprocess.call(convertCMD)#, stdout=log)
- os.remove(file) # remove old file after successful conversion (NEEDS ERROR CHECKING!!)
- os.rename(file[:-4] + '_fix.mkv', file) # rename converted file to it's original's name
- print(Fore.GREEN + '> Finished work on ' + file + '.')
- ### MAIN ###
- if __name__ == '__main__':
- #log = open(strftime('%d-%m-%Y_%H-%M-%S') + '_MKVree.log', 'w')
- mkvmerge_path = os.getcwd() + '\\mkvmerge\\mkvmerge.exe'
- mkvmerge_args_raw = '-o "{FILE}_fix.mkv" --engage keep_bitstream_ar_info -A -S --compression -1:none "{FILE}.mkv" -D -S --compression -1:none "{FILE}.mkv" -A -D "{FILE}.mkv"'
- # use {FILE} as placeholder for the filename
- pool = Pool()
- for file in glob.iglob('*.mkv'):
- if file.count('_fix') == 0:
- pool.apply_async(convert, (file, mkvmerge_path, mkvmerge_args_raw))#, log))
- pool.close()
- pool.join()
- #log.close()
- ### HANG ###
- while True:
- i = input(Fore.WHITE + '>>> ')
- print(i)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement