Merge pull request #645 from JackDandy/feature/ChangeFileQualityCheck

Change handle all Hachoir library errors.
This commit is contained in:
JackDandy 2016-02-10 22:15:23 +00:00
commit 3bcb4498ca
6 changed files with 16 additions and 5 deletions

View file

@ -26,6 +26,9 @@
* Add force episode recent search to API
* Change process episodes with utf8 dir and nzb names, handle failed episodes without a dir, add log output streaming
* Change move dateutil-zoneinfo.tar.gz file to data files /cache
* Change handle all Hachoir library parser errors and replace its Unicode enforcement
* Allow episode status "Skipped" to be changed to "Downloaded"
* Allow found "Skipped" episode files to be set "Unknown" quality
### 0.11.5 (2016-02-01 19:40:00 UTC)

View file

@ -3,6 +3,7 @@ Libs with customisations...
/lib/cachecontrol/caches/file_cache.py
/lib/dateutil/zoneinfo/__init__.py
/lib/hachoir_core/config.py
/lib/hachoir_core/stream/input_helpers.py
/lib/pynma/pynma.py
/lib/requests/packages/urllib3/connectionpool.py
/lib/requests/packages/urllib3/util/ssl_.py

View file

@ -10,7 +10,7 @@ def FileInputStream(filename, real_filename=None, **args):
not able to convert filename to real unicode string (ie. you have to
use unicode(name, 'replace') or unicode(name, 'ignore')).
"""
assert isinstance(filename, unicode)
# assert isinstance(filename, unicode)
if not real_filename:
real_filename = filename
try:

View file

@ -21,6 +21,7 @@ import operator
import platform
import re
import uuid
import traceback
import sickbeard
import logger
@ -234,6 +235,7 @@ class Quality:
def fileQuality(filename):
from sickbeard import encodingKludge as ek
from sickbeard.exceptions import ex
if ek.ek(os.path.isfile, filename):
from hachoir_parser import createParser
@ -241,10 +243,14 @@ class Quality:
from hachoir_core.stream import InputStreamError
parser = height = None
msg = u'Hachoir can\'t parse file "%s" content quality because it found error: %s'
try:
parser = createParser(filename)
parser = ek.ek(createParser, filename)
except InputStreamError as e:
logger.log('Hachoir can\'t parse file content quality because it found error: %s' % e.text, logger.WARNING)
logger.log(msg % (filename, e.text), logger.WARNING)
except Exception as e:
logger.log(msg % (filename, ex(e)), logger.ERROR)
logger.log(traceback.format_exc(), logger.DEBUG)
if parser:
extract = extractMetadata(parser)

View file

@ -698,7 +698,8 @@ class TVShow(object):
new_quality = Quality.fileQuality(file)
logger.log(u'Since this file was renamed, file %s was checked and quality "%s" found'
% (file, Quality.qualityStrings[new_quality]), logger.DEBUG)
if Quality.UNKNOWN != new_quality:
status, quality = sickbeard.common.Quality.splitCompositeStatus(cur_ep.status)
if Quality.UNKNOWN != new_quality or SKIPPED == status:
cur_ep.status = Quality.compositeStatus(DOWNLOADED, new_quality)
# check for status/quality changes as long as it's a new file

View file

@ -1719,7 +1719,7 @@ class Home(MainHandler):
if int(
status) in Quality.DOWNLOADED and epObj.status not in Quality.SNATCHED + Quality.SNATCHED_PROPER + Quality.DOWNLOADED + [
IGNORED] and not ek.ek(os.path.isfile, epObj.location):
IGNORED, SKIPPED] and not ek.ek(os.path.isfile, epObj.location):
logger.log(
u'Refusing to change status of ' + curEp + " to DOWNLOADED because it's not SNATCHED/DOWNLOADED",
logger.ERROR)