diff --git a/nzbtomedia/__init__.py b/nzbtomedia/__init__.py index 4f0ff2d9..775f9089 100644 --- a/nzbtomedia/__init__.py +++ b/nzbtomedia/__init__.py @@ -22,6 +22,7 @@ CONFIG_FILE = os.path.join(PROGRAM_DIR, 'autoProcessMedia.cfg') CONFIG_SPEC_FILE = os.path.join(PROGRAM_DIR, 'autoProcessMedia.cfg.spec') CONFIG_MOVIE_FILE = os.path.join(PROGRAM_DIR, 'autoProcessMovie.cfg') CONFIG_TV_FILE = os.path.join(PROGRAM_DIR, 'autoProcessTv.cfg') +TEST_FILE = os.path.join(os.path.join(PROGRAM_DIR, 'tests'), 'test.mp4') MYAPP = None from nzbtomedia.autoProcess.autoProcessComics import autoProcessComics @@ -188,7 +189,7 @@ def initialize(section=None): SABNZB_NO_OF_ARGUMENTS, SABNZB_0717_NO_OF_ARGUMENTS, CATEGORIES, TORRENT_CLIENTAGENT, USELINK, OUTPUTDIRECTORY, \ NOFLATTEN, UTORRENTPWD, UTORRENTUSR, UTORRENTWEBUI, DELUGEHOST, DELUGEPORT, DELUGEUSR, DELUGEPWD, \ TRANSMISSIONHOST, TRANSMISSIONPORT, TRANSMISSIONPWD, TRANSMISSIONUSR, COMPRESSEDCONTAINER, MEDIACONTAINER, \ - METACONTAINER, SECTIONS, ALL_FORKS, \ + METACONTAINER, SECTIONS, ALL_FORKS, TEST_FILE, \ __INITIALIZED__, AUTO_UPDATE, APP_FILENAME, USER_DELAY, APP_NAME, TRANSCODE, DEFAULTS, GIT_PATH, GIT_USER, \ GIT_BRANCH, GIT_REPO, SYS_ENCODING, NZB_CLIENTAGENT, SABNZBDHOST, SABNZBDPORT, SABNZBDAPIKEY, \ DUPLICATE, IGNOREEXTENSIONS, VEXTENSION, OUTPUTVIDEOPATH, PROCESSOUTPUT, VCODEC, VCODEC_ALLOW, VPRESET, \ diff --git a/nzbtomedia/nzbToMediaAutoFork.py b/nzbtomedia/nzbToMediaAutoFork.py index 6a554028..e9219bc5 100644 --- a/nzbtomedia/nzbToMediaAutoFork.py +++ b/nzbtomedia/nzbToMediaAutoFork.py @@ -75,7 +75,8 @@ def autoFork(section, inputCategory): r = requests.get(url, verify=False) except requests.ConnectionError: logger.info("Could not connect to %s:%s to perform auto-fork detection!" % (section, inputCategory)) - if r.ok: + r = [] + if r and r.ok: for param in params: if not 'name="%s"' %(param) in r.text: rem_params.append(param) diff --git a/nzbtomedia/transcoder/transcoder.py b/nzbtomedia/transcoder/transcoder.py index 5eca615e..7f36e4e7 100644 --- a/nzbtomedia/transcoder/transcoder.py +++ b/nzbtomedia/transcoder/transcoder.py @@ -14,11 +14,25 @@ from nzbtomedia.nzbToMediaUtil import makeDir def isVideoGood(videofile, status): fileNameExt = os.path.basename(videofile) fileName, fileExt = os.path.splitext(fileNameExt) + disable = False if fileExt not in nzbtomedia.MEDIACONTAINER or not nzbtomedia.FFPROBE or not nzbtomedia.CHECK_MEDIA: - if status: # if the download was "failed", assume bad. If it was successful, assume good. - return False - else: - return True + disable = True + else: + test_details, res = getVideoDetails(nzbtomedia.TEST_FILE) + if res !=0 or test_details.get("error"): + disable = True + logger.info("DISABLED: ffprobe failed to analyse test file. Stopping corruption check.", 'TRANSCODER') + if test_details.get("streams"): + vidStreams = [item for item in test_details["streams"] if item["codec_type"] == "video"] + audStreams = [item for item in test_details["streams"] if item["codec_type"] == "audio"] + if not (len(vidStreams) > 0 and len(audStreams) > 0): + disable = True + logger.info("DISABLED: ffprobe failed to analyse streams from test file. Stopping corruption check.", 'TRANSCODER') + if disable: + if status: # if the download was "failed", assume bad. If it was successful, assume good. + return False + else: + return True logger.info('Checking [%s] for corruption, please stand by ...' % (fileNameExt), 'TRANSCODER') video_details, result = getVideoDetails(videofile) diff --git a/tests/general.py b/tests/general.py index b2f57805..0f27fc4b 100755 --- a/tests/general.py +++ b/tests/general.py @@ -5,11 +5,17 @@ import re import nzbtomedia from nzbtomedia.nzbToMediaAutoFork import autoFork from nzbtomedia import nzbToMediaDB +from nzbtomedia.transcoder import transcoder from nzbtomedia.nzbToMediaUtil import get_downloadInfo, server_responding # Initialize the config nzbtomedia.initialize() +if transcoder.isVideoGood(nzbtomedia.TEST_FILE, 0): + print "FFPROBE Works" +else: + print "FFPROBE FAILED" + test = nzbtomedia.CFG['SickBeard','NzbDrone']['tv'].isenabled() section = nzbtomedia.CFG.findsection('tv').isenabled() print section @@ -31,4 +37,5 @@ print Language('eng') import subliminal -subliminal.cache_region.configure('dogpile.cache.memory') \ No newline at end of file +subliminal.cache_region.configure('dogpile.cache.memory') +del nzbtomedia.MYAPP \ No newline at end of file diff --git a/tests/test.mp4 b/tests/test.mp4 new file mode 100644 index 00000000..d0a72cf4 Binary files /dev/null and b/tests/test.mp4 differ