diff --git a/CHANGES.md b/CHANGES.md index c0d7f9fa..f9026efc 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -8,6 +8,7 @@ * Add menu Shows/"TVDb Cards" * Add a persons available socials (Youtube, LinkedIn, Reddit, Fansite, TikTok, Wikidata) * Change increase viewable history menu items from 13 to 15 +* Change add parsing of 2160p releases that don't have a source tag ### 3.32.8 (2024-10-07 00:30:00 UTC) diff --git a/sickgear/common.py b/sickgear/common.py index 20ba2777..6d97554f 100644 --- a/sickgear/common.py +++ b/sickgear/common.py @@ -344,6 +344,8 @@ class Quality(object): return Quality.UHD4KBLURAY if name_has([webfmt]): return Quality.UHD4KWEB + # for some non scene releases that have no source in name + return Quality.UHD4KWEB return Quality.UNKNOWN @@ -360,11 +362,12 @@ class Quality(object): from sickgear import logger if os.path.isfile(filename): - from hachoir.parser import createParser - from hachoir.metadata import extractMetadata - from hachoir.stream import InputStreamError + from lib.hachoir.parser import createParser + from lib.hachoir.metadata import extractMetadata + from lib.hachoir.metadata.metadata_item import QUALITY_BEST + from lib.hachoir.stream import InputStreamError - parser = height = None + parser = height = width = None msg = 'Hachoir can\'t parse file "%s" content quality because it found error: %s' try: parser = createParser(filename) @@ -381,17 +384,19 @@ class Quality(object): parser.parse_exif = False parser.parse_photoshop_content = False parser.parse_comments = False - extract = extractMetadata(parser, **args) + extract = extractMetadata(parser, quality=QUALITY_BEST, **args) except (BaseException, Exception) as e: logger.warning(msg % (filename, ex(e))) if extract: try: height = extract.get('height') + width = extract.get('width') except (AttributeError, ValueError): try: for metadata in extract.iterGroups(): if re.search('(?i)video', metadata.header): height = metadata.get('height') + width = metadata.get('width') break except (AttributeError, ValueError): pass @@ -401,9 +406,12 @@ class Quality(object): tolerance = (lambda value, percent: int(round(value - (value * percent / 100.0)))) if None is not height and height >= tolerance(352, 5): - if height <= tolerance(720, 2): + if height <= tolerance(720, 2) and (None is width or width < tolerance(1280, 2)): return Quality.SDTV - return (Quality.HDTV, Quality.FULLHDTV)[height >= tolerance(1080, 1)] + if 1100 < height or (None is not width and 2000 < width): + return Quality.UHD4KWEB + return (Quality.HDTV, Quality.FULLHDTV)[ + height >= tolerance(1080, 1) or (None is not width and width >= tolerance(1920, 4))] return Quality.UNKNOWN @staticmethod diff --git a/sickgear/image_cache.py b/sickgear/image_cache.py index 09f8910c..396d2ca1 100644 --- a/sickgear/image_cache.py +++ b/sickgear/image_cache.py @@ -40,6 +40,7 @@ if False: from lib.hachoir.parser import createParser, guessParser from lib.hachoir.metadata import extractMetadata +from lib.hachoir.metadata.metadata_item import QUALITY_BEST from lib.hachoir.stream import StringInputStream cache_img_base = {'tvmaze': TVINFO_TVMAZE, 'themoviedb': TVINFO_TMDB, 'thetvdb': TVINFO_TVDB, 'imdb': TVINFO_IMDB} @@ -379,7 +380,7 @@ class ImageCache(object): img_parser.parse_comments = False img_parser.parse_exif = False img_parser.parse_photoshop_content = False - img_metadata = extractMetadata(img_parser) + img_metadata = extractMetadata(img_parser, quality=QUALITY_BEST) except (BaseException, Exception) as e: logger.debug(f'Unable to extract metadata from {image}, not using file. Error: {ex(e)}') return diff --git a/sickgear/providers/generic.py b/sickgear/providers/generic.py index 3f088120..ebf3227a 100644 --- a/sickgear/providers/generic.py +++ b/sickgear/providers/generic.py @@ -41,8 +41,8 @@ from ..sgdatetime import SGDatetime from ..tv import TVEpisode, TVShow from cfscrape import CloudflareScraper -from hachoir.parser import guessParser -from hachoir.stream import FileInputStream +from lib.hachoir.parser import guessParser +from lib.hachoir.stream import FileInputStream from lxml_etree import etree import requests import requests.cookies diff --git a/tests/common_tests.py b/tests/common_tests.py index b255b592..cfc87874 100644 --- a/tests/common_tests.py +++ b/tests/common_tests.py @@ -126,7 +126,8 @@ quality_tests = { 'Test.Show.S01E02.2160p.WEBRip.h264-GROUP', 'Test.Show.S01E02.2160p.WEBRip.x264-GROUP', 'Test.Show.S01E02.2160p.WEBRip.x265-GROUP', - 'Test.Show.S01E02.2160p.WEBRip.vp9-GROUP'], + 'Test.Show.S01E02.2160p.WEBRip.vp9-GROUP', + 'Test.Show.S02E01.The.Name.2160p.DV.HDR.Opus.AV1'], common.Quality.UHD4KBLURAY: [ 'Test.Show.S01E02.2160p.BluRay.h264-GROUP', 'Test.Show.S01E02.2160p.BluRay.x264-GROUP', @@ -3110,6 +3111,7 @@ class QualityTests(unittest.TestCase): (('The.Show.S03E05.1080p.NF.WEB-DL.DD5.1.HDR.HEVC-Group', False), common.Quality.FULLHDWEBDL), (('The.Show.S01E10.Name.2160p.UHD.BluRay.REMUX.HDR.HEVC.DTS-HD.MA.5.1', False), common.Quality.UHD4KBLURAY), (('Show.S01E07.2160p.4K.UHD.10bit.NF.WEBRip.5.1.x265.HEVC-Group', False), common.Quality.UHD4KWEB), + (('Test.Show.S02E01.The.Name.2160p.DV.HDR.Opus.AV1', False), common.Quality.UHD4KWEB), ]) for q, l in iteritems(quality_tests): self.check_sceneQuality([((v, False), q) for v in l])