Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for 4k/2160p/UHD #981

Open
wants to merge 1 commit into
base: development
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions data/interfaces/default/apiBuilder.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -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)");
Expand All @@ -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)");
Expand All @@ -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");
Expand Down
24 changes: 17 additions & 7 deletions sickbeard/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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"}
Expand Down Expand Up @@ -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
Expand All @@ -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

Expand Down Expand Up @@ -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"}


Expand Down
2 changes: 1 addition & 1 deletion sickbeard/databases/mainDB.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
26 changes: 18 additions & 8 deletions sickbeard/webapi.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'}


Expand Down Expand Up @@ -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"])
Expand All @@ -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 = []
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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())
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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)

Expand All @@ -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
Expand Down
8 changes: 8 additions & 0 deletions tests/common_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"))
Expand All @@ -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"))

Expand All @@ -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__':
Expand Down