From d0ab6db706c4d8abe441dca595352b8e9bf48d0c Mon Sep 17 00:00:00 2001 From: JackDandy Date: Sat, 8 Oct 2016 16:07:18 +0100 Subject: [PATCH] Change reduce time taken to parse avi RIFF metadata during post processing and other times. Change avi metadata extraction is more fault tolerant and the chance of hanging due to corrupt avi files is reduced. --- CHANGES.md | 2 ++ HACKS.txt | 2 ++ lib/hachoir_metadata/metadata.py | 4 ++-- lib/hachoir_metadata/riff.py | 8 ++++---- sickbeard/common.py | 2 +- 5 files changed, 11 insertions(+), 7 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index b985831..a5f437a 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -179,6 +179,8 @@ * Fix never set episodes without airdate to wanted * Change improve getting the local timezone information * Change hachoir_parser to close input stream if no parser is found e.g. due to file corruption +* Change reduce time taken to parse avi RIFF metadata during post processing and other times +* Change avi metadata extraction is more fault tolerant and the chance of hanging due to corrupt avi files is reduced [develop changelog] * Change send nzb data to NZBGet for Anizb instead of url diff --git a/HACKS.txt b/HACKS.txt index f9a7db8..4117a07 100644 --- a/HACKS.txt +++ b/HACKS.txt @@ -4,6 +4,8 @@ Libs with customisations... /lib/dateutil/zoneinfo/__init__.py /lib/hachoir_core/config.py /lib/hachoir_core/stream/input_helpers.py +/lib/hachoir_metadata/metadata.py +/lib/hachoir_metadata/riff.py /lib/hachoir_parser/guess.py /lib/lockfile/mkdirlockfile.py /lib/pynma/pynma.py diff --git a/lib/hachoir_metadata/metadata.py b/lib/hachoir_metadata/metadata.py index dbdc411..bb444db 100644 --- a/lib/hachoir_metadata/metadata.py +++ b/lib/hachoir_metadata/metadata.py @@ -270,7 +270,7 @@ def registerExtractor(parser, extractor): assert issubclass(extractor, RootMetadata) extractors[parser] = extractor -def extractMetadata(parser, quality=QUALITY_NORMAL): +def extractMetadata(parser, quality=QUALITY_NORMAL, scan_index=True): """ Create a Metadata class from a parser. Returns None if no metadata extractor does exist for the parser class. @@ -281,7 +281,7 @@ def extractMetadata(parser, quality=QUALITY_NORMAL): return None metadata = extractor(quality) try: - metadata.extract(parser) + metadata.extract(parser, scan_index) except HACHOIR_ERRORS, err: error("Error during metadata extraction: %s" % unicode(err)) return None diff --git a/lib/hachoir_metadata/riff.py b/lib/hachoir_metadata/riff.py index adcc0bd..e910050 100644 --- a/lib/hachoir_metadata/riff.py +++ b/lib/hachoir_metadata/riff.py @@ -23,7 +23,7 @@ class RiffMetadata(MultipleMetadata): "IDIT": "creation_date", } - def extract(self, riff): + def extract(self, riff, scan_index=True): type = riff["type"].value if type == "WAVE": self.extractWAVE(riff) @@ -32,7 +32,7 @@ class RiffMetadata(MultipleMetadata): computeAudioComprRate(self, size*8) elif type == "AVI ": if "headers" in riff: - self.extractAVI(riff["headers"]) + self.extractAVI(riff["headers"], scan_index) self.extractInfo(riff["headers"]) elif type == "ACON": self.extractAnim(riff) @@ -142,7 +142,7 @@ class RiffMetadata(MultipleMetadata): self.width = header["width"].value self.height = header["height"].value - def extractAVI(self, headers): + def extractAVI(self, headers, scan_index=True): audio_index = 1 for stream in headers.array("stream"): if "stream_hdr/stream_type" not in stream: @@ -167,7 +167,7 @@ class RiffMetadata(MultipleMetadata): self.bit_rate = float(headers["/movie/size"].value) * 8 / timedelta2seconds(self.get('duration')) # Video has index? - if "/index" in headers: + if scan_index and "/index" in headers: self.comment = _("Has audio/video index (%s)") \ % humanFilesize(headers["/index"].size/8) diff --git a/sickbeard/common.py b/sickbeard/common.py index 56e2564..b69f71c 100644 --- a/sickbeard/common.py +++ b/sickbeard/common.py @@ -261,7 +261,7 @@ class Quality: logger.log(traceback.format_exc(), logger.DEBUG) if parser: - extract = extractMetadata(parser) + extract = extractMetadata(parser, scan_index=False) if extract: try: height = extract.get('height')