From 5b31a986dd0f5ccf6b3ede91e9e64a8b1210b229 Mon Sep 17 00:00:00 2001 From: Prinz23 Date: Sun, 17 Nov 2024 08:02:37 +0100 Subject: [PATCH 1/7] add parsing of 2160p releases without source tag --- sickgear/common.py | 2 ++ tests/common_tests.py | 4 +++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/sickgear/common.py b/sickgear/common.py index 20ba2777..7e160e03 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 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]) From 2494473f6868715a95bc6cd4420a02977fd5abf4 Mon Sep 17 00:00:00 2001 From: Prinz23 Date: Mon, 18 Nov 2024 06:19:57 +0100 Subject: [PATCH 2/7] add to file_quality for video height over 1100 to return 4k web too --- sickgear/common.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/sickgear/common.py b/sickgear/common.py index 7e160e03..24bc0d52 100644 --- a/sickgear/common.py +++ b/sickgear/common.py @@ -405,6 +405,8 @@ class Quality(object): if None is not height and height >= tolerance(352, 5): if height <= tolerance(720, 2): return Quality.SDTV + if 1100 < height: + return Quality.UHD4KWEB return (Quality.HDTV, Quality.FULLHDTV)[height >= tolerance(1080, 1)] return Quality.UNKNOWN From 695f9c22012eddcc7bfe1c144e3e10c14b84eaca Mon Sep 17 00:00:00 2001 From: Prinz23 Date: Mon, 18 Nov 2024 07:54:49 +0100 Subject: [PATCH 3/7] add width check --- sickgear/common.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/sickgear/common.py b/sickgear/common.py index 24bc0d52..a9386820 100644 --- a/sickgear/common.py +++ b/sickgear/common.py @@ -366,7 +366,7 @@ class Quality(object): from hachoir.metadata import extractMetadata from 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) @@ -389,11 +389,13 @@ class Quality(object): 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 @@ -403,11 +405,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 - if 1100 < height: + if 1100 < height or (None is not width and 2000 < width): return Quality.UHD4KWEB - return (Quality.HDTV, Quality.FULLHDTV)[height >= tolerance(1080, 1)] + return (Quality.HDTV, Quality.FULLHDTV)[ + height >= tolerance(1080, 1) or (None is not width and width >= tolerance(1920, 4))] return Quality.UNKNOWN @staticmethod From c4289ae091089a531203775b4dbdbaf4e2a701ff Mon Sep 17 00:00:00 2001 From: Prinz23 Date: Wed, 20 Nov 2024 07:54:42 +0100 Subject: [PATCH 4/7] change hachoir metadata extractor to best data extraction quality --- sickgear/common.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/sickgear/common.py b/sickgear/common.py index a9386820..8d349261 100644 --- a/sickgear/common.py +++ b/sickgear/common.py @@ -364,6 +364,7 @@ class Quality(object): from hachoir.parser import createParser from hachoir.metadata import extractMetadata + from hachoir.metadata.metadata_item import QUALITY_BEST from hachoir.stream import InputStreamError parser = height = width = None @@ -383,7 +384,7 @@ 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: From b0566f7a53cdf78a34dbacd4e0d30804781aff55 Mon Sep 17 00:00:00 2001 From: Prinz23 Date: Wed, 20 Nov 2024 08:04:09 +0100 Subject: [PATCH 5/7] also set image dimensions getter to best quality --- sickgear/image_cache.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) 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 From 1168a23a66b5a45a36dba4d7bd79974ab6255095 Mon Sep 17 00:00:00 2001 From: Prinz23 Date: Wed, 20 Nov 2024 10:46:41 +0100 Subject: [PATCH 6/7] unify the hachoir imports to from lib. --- sickgear/common.py | 8 ++++---- sickgear/providers/generic.py | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/sickgear/common.py b/sickgear/common.py index 8d349261..6d97554f 100644 --- a/sickgear/common.py +++ b/sickgear/common.py @@ -362,10 +362,10 @@ class Quality(object): from sickgear import logger if os.path.isfile(filename): - from hachoir.parser import createParser - from hachoir.metadata import extractMetadata - from hachoir.metadata.metadata_item import QUALITY_BEST - 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 = width = None msg = 'Hachoir can\'t parse file "%s" content quality because it found error: %s' 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 From cfc178e25a223fa66e9c89b11f558c25f5bbe68d Mon Sep 17 00:00:00 2001 From: JackDandy Date: Mon, 25 Nov 2024 13:27:30 +0000 Subject: [PATCH 7/7] Change update readme --- CHANGES.md | 1 + 1 file changed, 1 insertion(+) 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)