From 99c4961f6a19eef5b749a1e1bd2add9e941f6b1c Mon Sep 17 00:00:00 2001 From: clinton-hall Date: Thu, 23 May 2013 15:39:47 +0930 Subject: [PATCH] added flatten + media check. fixes #127 fixes #131 --- TorrentToMedia.py | 2 +- autoProcess/autoProcessTV.py | 21 +++++++++++++++++++++ autoProcess/migratecfg.py | 2 +- autoProcessMedia.cfg.sample | 4 ++-- changelog.txt | 5 +++++ 5 files changed, 30 insertions(+), 4 deletions(-) diff --git a/TorrentToMedia.py b/TorrentToMedia.py index 1c86c2dd..17d330e5 100755 --- a/TorrentToMedia.py +++ b/TorrentToMedia.py @@ -223,7 +223,6 @@ if __name__ == "__main__": # EXAMPLE VALUES: clientAgent = config.get("Torrent", "clientAgent") # utorrent | deluge | transmission | other useLink = config.get("Torrent", "useLink") # no | hard | sym - minSampleSize = int(config.get("Torrent", "minSampleSize")) # 200 (in MB) outputDirectory = config.get("Torrent", "outputDirectory") # /abs/path/to/complete/ categories = (config.get("Torrent", "categories")).split(',') # music,music_videos,pictures,software @@ -236,6 +235,7 @@ if __name__ == "__main__": compressedContainer = (config.get("Extensions", "compressedExtensions")).split(',') # .zip,.rar,.7z mediaContainer = (config.get("Extensions", "mediaExtensions")).split(',') # .mkv,.avi,.divx metaContainer = (config.get("Extensions", "metaExtensions")).split(',') # .nfo,.sub,.srt + minSampleSize = int(config.get("Extensions", "minSampleSize")) # 200 (in MB) cpsCategory = config.get("CouchPotato", "cpsCategory") # movie sbCategory = config.get("SickBeard", "sbCategory") # tv diff --git a/autoProcess/autoProcessTV.py b/autoProcess/autoProcessTV.py index d8c66047..27fb0fa9 100644 --- a/autoProcess/autoProcessTV.py +++ b/autoProcess/autoProcessTV.py @@ -26,6 +26,7 @@ import shutil import Transcoder from nzbToMediaEnv import * +from nzbToMediaUtil import * from nzbToMediaSceneExceptions import process_all_exceptions Logger = logging.getLogger() @@ -106,9 +107,29 @@ def processEpisode(dirName, nzbName=None, failed=False): except (ConfigParser.NoOptionError, ValueError): delete_failed = 0 + mediaContainer = (config.get("Extensions", "mediaExtensions")).split(',') + minSampleSize = int(config.get("Extensions", "minSampleSize")) process_all_exceptions(nzbName.lower(), dirName) + # Now check if movie files exist in destination: + video = int(0) + for dirpath, dirnames, filenames in os.walk(dirName): + for file in filenames: + filePath = os.path.join(dirpath, file) + fileExtension = os.path.splitext(file)[1] + if fileExtension in mediaContainer: # If the file is a video file + if is_sample(filePath, nzbName, minSampleSize): + Logger.debug("Removing sample file: %s", filePath) + os.unlink(filePath) # remove samples + else: + video = video + 1 + if video > 0: # Check that a video exists. if not, assume failed. + flatten(dirName) # to make sure SickBeard can find the video (not in sub-folder) + else: + Logger.warning("No media files found in directory %s. Processing this as a failed download", dirName) + status = int(1) + failed = True #allows manual call of postprocess script if we have specified a watch_dir. Check that here. if nzbName == "Manual Run" and watch_dir == "": diff --git a/autoProcess/migratecfg.py b/autoProcess/migratecfg.py index aee07160..ca207ffc 100644 --- a/autoProcess/migratecfg.py +++ b/autoProcess/migratecfg.py @@ -99,7 +99,7 @@ def migrate(): pass for item in original: option, value = item - if option in ["compressedExtensions", "mediaExtensions", "metaExtensions"]: + if option in ["compressedExtensions", "mediaExtensions", "metaExtensions", "minSampleSize"]: section = "Extensions" # these were moved if option == "useLink": # Sym links supported now as well. try: diff --git a/autoProcessMedia.cfg.sample b/autoProcessMedia.cfg.sample index 6f043057..9df20158 100644 --- a/autoProcessMedia.cfg.sample +++ b/autoProcessMedia.cfg.sample @@ -82,8 +82,6 @@ web_root = clientAgent = other ###### useLink - Set to hard for physical links, sym for symbolic links, and no to not use links useLink = hard -###### minSampleSize - Minimum required size to consider a file not an sample file (in MB, eg 200mb) -minSampleSize = 200 ###### outputDirectory - Default output directory (categories will be appended as sub directory to outputDirectory) outputDirectory = /abs/path/to/complete/ ###### Other categories/labels defined for your downloader. Does not include CouchPotato, SickBeard, HeadPhones, Mylar categories. @@ -99,6 +97,8 @@ deleteOriginal = 0 compressedExtensions = .zip,.rar,.7z,.gz,.bz,.tar,.arj,.1,.01,.001 mediaExtensions = .mkv,.avi,.divx,.xvid,.mov,.wmv,.mp4,.mpg,.mpeg,.vob,.iso metaExtensions = .nfo,.sub,.srt,.jpg,.gif +###### minSampleSize - Minimum required size to consider a media file not a sample file (in MB, eg 200mb) +minSampleSize = 200 [Transcoder] transcode = 0 diff --git a/changelog.txt b/changelog.txt index 6ce0900d..2b49a527 100644 --- a/changelog.txt +++ b/changelog.txt @@ -4,10 +4,15 @@ VX.X Impacts All Add option to set the "wait_for" period. This is how long the script waits to see if the movie changes status in CouchPotato. +minSampleSize now moved to [extensions] section and availabe for nzbs and torrents. + +Impacts NZBs +Added Flatten of input directory and test for media files (including sample deletion) in autoProcessTV Impacts Torrents Fixed Delete_Original option + V8.1 04/05/2013 Impacts All