added flatten + media check. fixes #127 fixes #131

This commit is contained in:
clinton-hall 2013-05-23 15:39:47 +09:30
parent e9fc2b16f5
commit 99c4961f6a
5 changed files with 30 additions and 4 deletions

View file

@ -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

View file

@ -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 == "":

View file

@ -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:

View file

@ -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

View file

@ -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