Advertisement
tausciam

Cut commercials from recorded TV shows

Jan 19th, 2020
475
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.85 KB | None | 0 0
  1. from os import listdir
  2. from os.path import isfile, isdir, join, splitext
  3. import subprocess
  4.  
  5. mypath="/home/tausciam/MyCloud/Public/TVShows"
  6.  
  7. def alreadydone(fp):
  8.     extless,ext = splitext(fp)
  9.     if extless.endswith("[CUT]"):
  10.         return True
  11.     else:
  12.         myextless = extless + "[CUT]"
  13.         newname = myextless + ext
  14.         if newname in listdir(mynewpath):
  15.             return True
  16.     return False
  17.  
  18. onlydirs=[]
  19. for each in listdir(mypath):
  20.     if isdir(join(mypath,each)):
  21.         onlydirs.append(each)
  22.  
  23. for show in onlydirs:
  24.     mynewpath=join(mypath,show)
  25.     for episode in listdir(mynewpath):
  26.         if not alreadydone(episode):
  27.             root,ext = splitext(join(mynewpath,episode))
  28.             cutname=root + "[CUT]" + ext
  29.             args=["comcut",join(mynewpath,episode),cutname]
  30.             subprocess.call(args)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement