Advertisement
tzanany

torecTvSubsCopy

Sep 21st, 2013
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.50 KB | None | 0 0
  1. ########################################################
  2. #                Made By RealGame
  3. #                Site: http://RealGame.co.il
  4. ########################################################
  5. from os import path, mkdir, getenv, listdir, walk, remove
  6. from shutil import rmtree, copy
  7. from zipfile import ZipFile
  8. from re import match
  9. from difflib import SequenceMatcher
  10.  
  11. #Get Paths:
  12. downPath = raw_input("Please Enter Download Folder Path:\n")
  13. #downPath = "C:\\Bitorrent_Downloads\\Greys.Anatomy.S08.720p.HDTV.x264-TL"
  14. subsPath = raw_input("Please Enter Subtitles Zip Path:\n")
  15. #subsPath = "C:\\Downloads\\Greys_Anatomy.S08.[www.torec.net].zip"
  16.  
  17. tmpExtPath = path.join(getenv("TEMP"), path.basename(subsPath))
  18. if not path.exists(tmpExtPath):
  19.     mkdir(tmpExtPath)
  20.  
  21. ZipFile(subsPath).extractall(tmpExtPath)
  22. listOfExtrcatedFiles = files = [f for f in listdir(tmpExtPath) if match(r'.*\.zip', f)]
  23.  
  24. for zipFile in listOfExtrcatedFiles:
  25.     zipPath = path.join(tmpExtPath, zipFile)
  26.     ZipFile(zipPath).extractall(tmpExtPath)
  27.     remove(zipPath)
  28.    
  29. listOfFolders = listOfExtrcatedFiles = files = [f for f in listdir(downPath) if path.isdir(path.join(downPath, f))]
  30.  
  31. for r,d,f in walk(tmpExtPath):
  32.     for files in f:
  33.         for folder in listOfFolders:
  34.             if SequenceMatcher(None, folder, path.splitext(files)[0]).ratio() >= 0.98 :
  35.                 copy(path.join(tmpExtPath, files), path.join(downPath, folder))
  36.                 break
  37.                
  38. rmtree(tmpExtPath, ignore_errors=True)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement