Advertisement
Guest User

MKVree pool issues

a guest
Apr 28th, 2012
159
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.74 KB | None | 0 0
  1. ### WINDOWS ONLY ATM ###
  2.  
  3. ### IMPORTS ###
  4. import glob
  5. import os
  6. import subprocess
  7. from time import strftime
  8. from multiprocessing import Pool
  9. from colorama import init, Fore, Back, Style
  10.  
  11. ### INITIATION ###
  12. init()
  13. print(Style.BRIGHT)
  14.  
  15. ### WELCOME ###
  16. print(Fore.CYAN + 'Welcome to ' + Fore.BLUE + 'MKVree' + Fore.CYAN + '! :D' + Fore.RESET + '\n')
  17.  
  18. ### FUNCTION ###
  19. def convert(file, mkvmerge_path, mkvmerge_args_raw):#, log):
  20.     if file.count('_fix') == 0:
  21.         print(Fore.WHITE + '> Started work on ' + file + '.')
  22.         mkvmerge_args = mkvmerge_args_raw.replace('{FILE}', file[:-4]) # replace placeholders; cut .mkv from the filename
  23.         convertCMD = mkvmerge_path + ' ' + mkvmerge_args
  24.         subprocess.call(convertCMD)#, stdout=log)
  25.         os.remove(file) # remove old file after successful conversion (NEEDS ERROR CHECKING!!)
  26.         os.rename(file[:-4] + '_fix.mkv', file) # rename converted file to it's original's name
  27.         print(Fore.GREEN + '> Finished work on ' + file + '.')
  28.  
  29. ### MAIN ###
  30. if __name__ == '__main__':
  31.     #log = open(strftime('%d-%m-%Y_%H-%M-%S') + '_MKVree.log', 'w')
  32.  
  33.     mkvmerge_path     = os.getcwd() + '\\mkvmerge\\mkvmerge.exe'
  34.     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"'
  35.     # use {FILE} as placeholder for the filename
  36.    
  37.     pool = Pool()
  38.    
  39.     for file in glob.iglob('*.mkv'):
  40.         if file.count('_fix') == 0:
  41.             pool.apply_async(convert, (file, mkvmerge_path, mkvmerge_args_raw))#, log))
  42.            
  43.     pool.close()
  44.     pool.join()
  45.  
  46. #log.close()
  47.  
  48. ### HANG ###
  49. while True:
  50.     i = input(Fore.WHITE + '>>> ')
  51.     print(i)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement