From e59b69828515f20e027a7a2c79d6a3f67d805556 Mon Sep 17 00:00:00 2001 From: Michael Allen Date: Sat, 19 Nov 2016 14:03:54 -0500 Subject: [PATCH] Add support for 4k/2160p/UHD --- data/interfaces/default/apiBuilder.tmpl | 5 +++++ sickbeard/common.py | 24 ++++++++++++++++------- sickbeard/databases/mainDB.py | 2 +- sickbeard/webapi.py | 26 +++++++++++++++++-------- tests/common_tests.py | 8 ++++++++ 5 files changed, 49 insertions(+), 16 deletions(-) diff --git a/data/interfaces/default/apiBuilder.tmpl b/data/interfaces/default/apiBuilder.tmpl index b31ea2fe7b..029420ec3e 100644 --- a/data/interfaces/default/apiBuilder.tmpl +++ b/data/interfaces/default/apiBuilder.tmpl @@ -199,6 +199,7 @@ addOption("quality", "SD", "&initial=sdtv|sddvd"); addOption("quality", "HD", "&initial=hdtv|fullhdtv|hdwebdl|fullhdwebdl|hdbluray|fullhdbluray"); addOption("quality", "HD720p", "&initial=hdtv|hdwebdl|hdbluray"); addOption("quality", "HD1080p", "&initial=fullhdtv|fullhdwebdl|fullhdbluray"); +addOption("quality", "HD2160p", "&initial=quadhdwebdl|quadhdbluray"); addOption("quality", "ANY", "&initial=sdtv|sddvd|hdtv|fullhdtv|hdwebdl|fullhdwebdl|hdbluray|fullhdbluray|unknown"); endOptGroup("quality"); addOptGroup("quality", "Inital (Custom)"); @@ -209,8 +210,10 @@ addList("quality", "RawHD TV", "&initial=rawhdtv", "quality-archive"); addList("quality", "1080p HD TV", "&initial=fullhdtv", "quality-archive"); addList("quality", "720p Web-DL", "&initial=hdwebdl", "quality-archive"); addList("quality", "1080p Web-DL", "&initial=fullhdwebdl", "quality-archive"); +addList("quality", "2160p Web-DL", "&initial=quadhdwebdl", "quality-archive"); addList("quality", "720p BluRay", "&initial=hdbluray", "quality-archive"); addList("quality", "1080p BluRay", "&initial=fullhdbluray", "quality-archive"); +addList("quality", "2160p BluRay", "&initial=quadhdbluray", "quality-archive"); addList("quality", "Unknown", "&initial=unknown", "quality-archive"); endOptGroup("quality"); addOptGroup("quality", "Random (Custom)"); @@ -226,8 +229,10 @@ addList("quality-archive", "RawHD TV", "&archive=rawhdtv"); addList("quality-archive", "1080p HD TV", "&archive=fullhdtv"); addList("quality-archive", "720p Web-DL", "&archive=hdwebdl"); addList("quality-archive", "1080p Web-DL", "&archive=fullhdwebdl"); +addList("quality-archive", "2160p Web-DL", "&archive=quadhdwebdl"); addList("quality-archive", "720p BluRay", "&archive=hdbluray"); addList("quality-archive", "1080p BluRay", "&archive=fullhdbluray"); +addList("quality-archive", "2160p BluRay", "&archive=quadhdbluray"); endOptGroup("quality-archive"); addOptGroup("quality-archive", "Random (Custom)"); addList("quality-archive", "HD TV/1080p BluRay", "&archive=hdtv|fullhdbluray"); diff --git a/sickbeard/common.py b/sickbeard/common.py index da4244fb7b..e9cae6990f 100644 --- a/sickbeard/common.py +++ b/sickbeard/common.py @@ -81,6 +81,8 @@ class Quality: FULLHDWEBDL = 1 << 6 # 64 -- 1080p web-dl HDBLURAY = 1 << 7 # 128 FULLHDBLURAY = 1 << 8 # 256 + QUADHDWEBDL = 1 << 9 # 512 + QUADHDBLURAY = 1 << 10 # 1024 # put these bits at the other end of the spectrum, far enough out that they shouldn't interfere UNKNOWN = 1 << 15 # 32768 @@ -95,7 +97,9 @@ class Quality: HDWEBDL: "720p WEB-DL", FULLHDWEBDL: "1080p WEB-DL", HDBLURAY: "720p BluRay", - FULLHDBLURAY: "1080p BluRay"} + FULLHDBLURAY: "1080p BluRay", + QUADHDWEBDL: "2160p WEB-DL", + QUADHDBLURAY: "2160p BluRay"} statusPrefixes = {DOWNLOADED: "Downloaded", SNATCHED: "Snatched"} @@ -145,13 +149,13 @@ def nameQuality(name): checkName = lambda namelist, func: func([re.search(x, name, re.I) for x in namelist]) - if checkName(["(pdtv|hdtv|dsr|tvrip).(xvid|x264)"], all) and not checkName(["(720|1080)[pi]"], all) and not checkName(["hr.ws.pdtv.x264"], any): + if checkName(["(pdtv|hdtv|dsr|tvrip).(xvid|x264)"], all) and not checkName(["(720|1080|2160)[pi]"], all) and not checkName(["hr.ws.pdtv.x264"], any): return Quality.SDTV - elif checkName(["web.dl|webrip", "xvid|x264|h.?264"], all) and not checkName(["(720|1080)[pi]"], all): + elif checkName(["web.dl|webrip", "xvid|x264|h.?264"], all) and not checkName(["(720|1080|2160)[pi]"], all): return Quality.SDTV - elif checkName(["(dvdrip|bdrip)(.ws)?.(xvid|divx|x264)"], any) and not checkName(["(720|1080)[pi]"], all): + elif checkName(["(dvdrip|bdrip)(.ws)?.(xvid|divx|x264)"], any) and not checkName(["(720|1080|2160)[pi]"], all): return Quality.SDDVD - elif checkName(["720p", "hdtv", "x264"], all) or checkName(["hr.ws.pdtv.x264"], any) and not checkName(["(1080)[pi]"], all): + elif checkName(["720p", "hdtv", "x264"], all) or checkName(["hr.ws.pdtv.x264"], any) and not checkName(["(1080|2160)[pi]"], all): return Quality.HDTV elif checkName(["720p|1080i", "hdtv", "mpeg-?2"], all) or checkName(["1080[pi].hdtv", "h.?264"], all): return Quality.RAWHDTV @@ -165,6 +169,10 @@ def nameQuality(name): return Quality.HDBLURAY elif checkName(["1080p", "bluray|hddvd", "x264"], all): return Quality.FULLHDBLURAY + elif checkName(["2160p", "web.dl|webrip"], all): + return Quality.QUADHDWEBDL + elif checkName(["2160p", "ultra.hd.bluray", "x264|x265"], all): + return Quality.QUADHDBLURAY else: return Quality.UNKNOWN @@ -218,13 +226,15 @@ def statusFromName(name, assume=True): HD = Quality.combineQualities([Quality.HDTV, Quality.FULLHDTV, Quality.HDWEBDL, Quality.FULLHDWEBDL, Quality.HDBLURAY, Quality.FULLHDBLURAY], []) # HD720p + HD1080p HD720p = Quality.combineQualities([Quality.HDTV, Quality.HDWEBDL, Quality.HDBLURAY], []) HD1080p = Quality.combineQualities([Quality.FULLHDTV, Quality.FULLHDWEBDL, Quality.FULLHDBLURAY], []) -ANY = Quality.combineQualities([Quality.SDTV, Quality.SDDVD, Quality.HDTV, Quality.FULLHDTV, Quality.HDWEBDL, Quality.FULLHDWEBDL, Quality.HDBLURAY, Quality.FULLHDBLURAY, Quality.UNKNOWN], []) # SD + HD +HD2160p = Quality.combineQualities([Quality.QUADHDWEBDL, Quality.QUADHDBLURAY], []) +ANY = Quality.combineQualities([Quality.SDTV, Quality.SDDVD, Quality.HDTV, Quality.FULLHDTV, Quality.HDWEBDL, Quality.FULLHDWEBDL, Quality.HDBLURAY, Quality.FULLHDBLURAY, Quality.QUADHDWEBDL, Quality.QUADHDBLURAY, Quality.UNKNOWN], []) # SD + HD -qualityPresets = (SD, HD, HD720p, HD1080p, ANY) +qualityPresets = (SD, HD, HD720p, HD1080p, HD2160p, ANY) qualityPresetStrings = {SD: "SD", HD: "HD", HD720p: "HD720p", HD1080p: "HD1080p", + HD2160p: "HD2160p", ANY: "Any"} diff --git a/sickbeard/databases/mainDB.py b/sickbeard/databases/mainDB.py index 69ec455e52..ea2b4efda8 100644 --- a/sickbeard/databases/mainDB.py +++ b/sickbeard/databases/mainDB.py @@ -337,7 +337,7 @@ def execute(self): # update ANY -- shift existing qualities and add new 1080p qualities, note that rawHD was not added to the ANY template old_any = common.Quality.combineQualities([common.Quality.SDTV, common.Quality.SDDVD, common.Quality.HDTV, common.Quality.HDWEBDL >> 2, common.Quality.HDBLURAY >> 3, common.Quality.UNKNOWN], []) - new_any = common.Quality.combineQualities([common.Quality.SDTV, common.Quality.SDDVD, common.Quality.HDTV, common.Quality.FULLHDTV, common.Quality.HDWEBDL, common.Quality.FULLHDWEBDL, common.Quality.HDBLURAY, common.Quality.FULLHDBLURAY, common.Quality.UNKNOWN], []) + new_any = common.Quality.combineQualities([common.Quality.SDTV, common.Quality.SDDVD, common.Quality.HDTV, common.Quality.FULLHDTV, common.Quality.HDWEBDL, common.Quality.FULLHDWEBDL, common.Quality.HDBLURAY, common.Quality.FULLHDBLURAY, common.Quality.QUADHDWEBDL, common.Quality.QUADHDBLURAY, common.Quality.UNKNOWN], []) # update qualities (including templates) logger.log(u"[1/4] Updating pre-defined templates and the quality for each show...", logger.MESSAGE) diff --git a/sickbeard/webapi.py b/sickbeard/webapi.py index ca97a7e7ea..0061f16524 100644 --- a/sickbeard/webapi.py +++ b/sickbeard/webapi.py @@ -632,8 +632,10 @@ def _getQualityMap(): Quality.FULLHDTV: 'fullhdtv', Quality.HDWEBDL: 'hdwebdl', Quality.FULLHDWEBDL: 'fullhdwebdl', + Quality.QUADHDWEBDL: 'quadhdwebdl', Quality.HDBLURAY: 'hdbluray', Quality.FULLHDBLURAY: 'fullhdbluray', + Quality.QUADHDBLURAY: 'quadhdbluray', Quality.UNKNOWN: 'unknown'} @@ -1598,8 +1600,8 @@ class CMD_SickBeardSetDefaults(ApiCall): def __init__(self, args, kwargs): # required # optional - self.initial, args = self.check_params(args, kwargs, "initial", None, False, "list", ["sdtv", "sddvd", "hdtv", "rawhdtv", "fullhdtv", "hdwebdl", "fullhdwebdl", "hdbluray", "fullhdbluray", "unknown"]) - self.archive, args = self.check_params(args, kwargs, "archive", None, False, "list", ["sddvd", "hdtv", "rawhdtv", "fullhdtv", "hdwebdl", "fullhdwebdl", "hdbluray", "fullhdbluray"]) + self.initial, args = self.check_params(args, kwargs, "initial", None, False, "list", ["sdtv", "sddvd", "hdtv", "rawhdtv", "fullhdtv", "hdwebdl", "fullhdwebdl", "quadhdwebdl", "hdbluray", "fullhdbluray", "quadhdbluray", "unknown"]) + self.archive, args = self.check_params(args, kwargs, "archive", None, False, "list", ["sddvd", "hdtv", "rawhdtv", "fullhdtv", "hdwebdl", "fullhdwebdl", "quadhdwebdl", "hdbluray", "fullhdbluray", "quadhdbluray"]) self.future_show_paused, args = self.check_params(args, kwargs, "future_show_paused", None, False, "bool", []) self.flatten_folders, args = self.check_params(args, kwargs, "flatten_folders", None, False, "bool", []) self.status, args = self.check_params(args, kwargs, "status", None, False, "string", ["wanted", "skipped", "archived", "ignored"]) @@ -1616,8 +1618,10 @@ def run(self): 'fullhdtv': Quality.FULLHDTV, 'hdwebdl': Quality.HDWEBDL, 'fullhdwebdl': Quality.FULLHDWEBDL, + 'quadhdwebdl': Quality.QUADHDWEBDL, 'hdbluray': Quality.HDBLURAY, 'fullhdbluray': Quality.FULLHDBLURAY, + 'quadhdbluray': Quality.QUADHDBLURAY, 'unknown': Quality.UNKNOWN} iqualityID = [] @@ -1750,8 +1754,8 @@ def __init__(self, args, kwargs): self.location, args = self.check_params(args, kwargs, "location", None, True, "string", []) self.tvdbid, args = self.check_params(args, kwargs, "tvdbid", None, True, "int", []) # optional - self.initial, args = self.check_params(args, kwargs, "initial", None, False, "list", ["sdtv", "sddvd", "hdtv", "rawhdtv", "fullhdtv", "hdwebdl", "fullhdwebdl", "hdbluray", "fullhdbluray", "unknown"]) - self.archive, args = self.check_params(args, kwargs, "archive", None, False, "list", ["sddvd", "hdtv", "rawhdtv", "fullhdtv", "hdwebdl", "fullhdwebdl", "hdbluray", "fullhdbluray"]) + self.initial, args = self.check_params(args, kwargs, "initial", None, False, "list", ["sdtv", "sddvd", "hdtv", "rawhdtv", "fullhdtv", "hdwebdl", "fullhdwebdl", "quadhdwebdl", "hdbluray", "fullhdbluray", "quadhdbluray", "unknown"]) + self.archive, args = self.check_params(args, kwargs, "archive", None, False, "list", ["sddvd", "hdtv", "rawhdtv", "fullhdtv", "hdwebdl", "fullhdwebdl", "quadhdwebdl", "hdbluray", "fullhdbluray", "quadhdbluray"]) self.flatten_folders, args = self.check_params(args, kwargs, "flatten_folders", str(sickbeard.FLATTEN_FOLDERS_DEFAULT), False, "bool", []) # super, missing, help ApiCall.__init__(self, args, kwargs) @@ -1784,8 +1788,10 @@ def run(self): 'fullhdtv': Quality.FULLHDTV, 'hdwebdl': Quality.HDWEBDL, 'fullhdwebdl': Quality.FULLHDWEBDL, + 'quadhdwebdl': Quality.QUADHDWEBDL, 'hdbluray': Quality.HDBLURAY, 'fullhdbluray': Quality.FULLHDBLURAY, + 'quadhdbluray': Quality.QUADHDBLURAY, 'unknown': Quality.UNKNOWN} # use default quality as a failsafe @@ -1831,8 +1837,8 @@ def __init__(self, args, kwargs): self.tvdbid, args = self.check_params(args, kwargs, "tvdbid", None, True, "int", []) # optional self.location, args = self.check_params(args, kwargs, "location", None, False, "string", []) - self.initial, args = self.check_params(args, kwargs, "initial", None, False, "list", ["sdtv", "sddvd", "hdtv", "rawhdtv", "fullhdtv", "hdwebdl", "fullhdwebdl", "hdbluray", "fullhdbluray", "unknown"]) - self.archive, args = self.check_params(args, kwargs, "archive", None, False, "list", ["sddvd", "hdtv", "rawhdtv", "fullhdtv", "hdwebdl", "fullhdwebdl", "hdbluray", "fullhdbluray"]) + self.initial, args = self.check_params(args, kwargs, "initial", None, False, "list", ["sdtv", "sddvd", "hdtv", "rawhdtv", "fullhdtv", "hdwebdl", "fullhdwebdl", "quadhdwebdl", "hdbluray", "fullhdbluray", "quadhdbluray", "unknown"]) + self.archive, args = self.check_params(args, kwargs, "archive", None, False, "list", ["sddvd", "hdtv", "rawhdtv", "fullhdtv", "hdwebdl", "fullhdwebdl", "quadhdwebdl", "hdbluray", "fullhdbluray", "quadhdbluray"]) self.flatten_folders, args = self.check_params(args, kwargs, "flatten_folders", str(sickbeard.FLATTEN_FOLDERS_DEFAULT), False, "bool", []) self.status, args = self.check_params(args, kwargs, "status", None, False, "string", ["wanted", "skipped", "archived", "ignored"]) self.lang, args = self.check_params(args, kwargs, "lang", "en", False, "string", self.valid_languages.keys()) @@ -1864,8 +1870,10 @@ def run(self): 'fullhdtv': Quality.FULLHDTV, 'hdwebdl': Quality.HDWEBDL, 'fullhdwebdl': Quality.FULLHDWEBDL, + 'quadhdwebdl': Quality.QUADHDWEBDL, 'hdbluray': Quality.HDBLURAY, 'fullhdbluray': Quality.FULLHDBLURAY, + 'quadhdbluray': Quality.QUADHDBLURAY, 'unknown': Quality.UNKNOWN} # use default quality as a failsafe @@ -2219,8 +2227,8 @@ def __init__(self, args, kwargs): # optional # this for whatever reason removes hdbluray not sdtv... which is just wrong. reverting to previous code.. plus we didnt use the new code everywhere. # self.archive, args = self.check_params(args, kwargs, "archive", None, False, "list", _getQualityMap().values()[1:]) - self.initial, args = self.check_params(args, kwargs, "initial", None, False, "list", ["sdtv", "sddvd", "hdtv", "rawhdtv", "fullhdtv", "hdwebdl", "fullhdwebdl", "hdbluray", "fullhdbluray", "unknown"]) - self.archive, args = self.check_params(args, kwargs, "archive", None, False, "list", ["sddvd", "hdtv", "rawhdtv", "fullhdtv", "hdwebdl", "fullhdwebdl", "hdbluray", "fullhdbluray"]) + self.initial, args = self.check_params(args, kwargs, "initial", None, False, "list", ["sdtv", "sddvd", "hdtv", "rawhdtv", "fullhdtv", "hdwebdl", "fullhdwebdl", "quadhdwebdl", "hdbluray", "fullhdbluray", "quadhdbluray", "unknown"]) + self.archive, args = self.check_params(args, kwargs, "archive", None, False, "list", ["sddvd", "hdtv", "rawhdtv", "fullhdtv", "hdwebdl", "fullhdwebdl", "quadhdwebdl", "hdbluray", "fullhdbluray", "quadhdbluray"]) # super, missing, help ApiCall.__init__(self, args, kwargs) @@ -2239,8 +2247,10 @@ def run(self): 'fullhdtv': Quality.FULLHDTV, 'hdwebdl': Quality.HDWEBDL, 'fullhdwebdl': Quality.FULLHDWEBDL, + 'quadhdwebdl': Quality.QUADHDWEBDL, 'hdbluray': Quality.HDBLURAY, 'fullhdbluray': Quality.FULLHDBLURAY, + 'quadhdbluray': Quality.QUADHDBLURAY, 'unknown': Quality.UNKNOWN} # use default quality as a failsafe diff --git a/tests/common_tests.py b/tests/common_tests.py index 76cb7a1f8d..b33532ec38 100644 --- a/tests/common_tests.py +++ b/tests/common_tests.py @@ -78,6 +78,9 @@ def test_FULLHDWEBDL(self): self.assertEqual(common.Quality.FULLHDWEBDL, common.Quality.nameQuality("Test Show S01E02 1080p iTunes H 264 AAC-GROUP")) self.assertEqual(common.Quality.FULLHDWEBDL, common.Quality.nameQuality("Test_Show_S01E02_1080p_iTunes_H_264_AAC-GROUP")) + def test_QUADHDWEBDL(self): + self.assertEqual(common.Quality.QUADHDWEBDL, common.Quality.nameQuality("Test.Show.S01E02.2160p.WEBRip.x264-GROUP")) + def test_HDBLURAY(self): self.assertEqual(common.Quality.HDBLURAY, common.Quality.nameQuality("Test.Show.S01E02.720p.BluRay.x264-GROUP")) self.assertEqual(common.Quality.HDBLURAY, common.Quality.nameQuality("Test.Show.S01E02.720p.HDDVD.x264-GROUP")) @@ -86,6 +89,9 @@ def test_FULLHDBLURAY(self): self.assertEqual(common.Quality.FULLHDBLURAY, common.Quality.nameQuality("Test.Show.S01E02.1080p.BluRay.x264-GROUP")) self.assertEqual(common.Quality.FULLHDBLURAY, common.Quality.nameQuality("Test.Show.S01E02.1080p.HDDVD.x264-GROUP")) + def test_QUADHDBLURAY(self): + self.assertEqual(common.Quality.QUADHDBLURAY, common.Quality.nameQuality("Test.Show.S01E02.2160p.Ultra.HD.BluRay.x264-GROUP")) + def test_UNKNOWN(self): self.assertEqual(common.Quality.UNKNOWN, common.Quality.nameQuality("Test.Show.S01E02-SiCKBEARD")) @@ -97,8 +103,10 @@ def test_reverse_parsing(self): self.assertEqual(common.Quality.FULLHDTV, common.Quality.nameQuality("Test Show - S01E02 - 1080p HD TV - GROUP")) self.assertEqual(common.Quality.HDWEBDL, common.Quality.nameQuality("Test Show - S01E02 - 720p WEB-DL - GROUP")) self.assertEqual(common.Quality.FULLHDWEBDL, common.Quality.nameQuality("Test Show - S01E02 - 1080p WEB-DL - GROUP")) + self.assertEqual(common.Quality.QUADHDWEBDL, common.Quality.nameQuality("Test Show - S01E02 - 2160p WEBRip - GROUP")) self.assertEqual(common.Quality.HDBLURAY, common.Quality.nameQuality("Test Show - S01E02 - 720p BluRay - GROUP")) self.assertEqual(common.Quality.FULLHDBLURAY, common.Quality.nameQuality("Test Show - S01E02 - 1080p BluRay - GROUP")) + self.assertEqual(common.Quality.QUADHDBLURAY, common.Quality.nameQuality("Test Show - S01E02 - 2160p BluRay - GROUP")) self.assertEqual(common.Quality.UNKNOWN, common.Quality.nameQuality("Test Show - S01E02 - Unknown - SiCKBEARD")) if __name__ == '__main__':