mirror of
https://github.com/SickGear/SickGear.git
synced 2024-11-28 23:53:37 +00:00
add width check
This commit is contained in:
parent
2494473f68
commit
695f9c2201
1 changed files with 7 additions and 4 deletions
|
@ -366,7 +366,7 @@ class Quality(object):
|
||||||
from hachoir.metadata import extractMetadata
|
from hachoir.metadata import extractMetadata
|
||||||
from hachoir.stream import InputStreamError
|
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'
|
msg = 'Hachoir can\'t parse file "%s" content quality because it found error: %s'
|
||||||
try:
|
try:
|
||||||
parser = createParser(filename)
|
parser = createParser(filename)
|
||||||
|
@ -389,11 +389,13 @@ class Quality(object):
|
||||||
if extract:
|
if extract:
|
||||||
try:
|
try:
|
||||||
height = extract.get('height')
|
height = extract.get('height')
|
||||||
|
width = extract.get('width')
|
||||||
except (AttributeError, ValueError):
|
except (AttributeError, ValueError):
|
||||||
try:
|
try:
|
||||||
for metadata in extract.iterGroups():
|
for metadata in extract.iterGroups():
|
||||||
if re.search('(?i)video', metadata.header):
|
if re.search('(?i)video', metadata.header):
|
||||||
height = metadata.get('height')
|
height = metadata.get('height')
|
||||||
|
width = metadata.get('width')
|
||||||
break
|
break
|
||||||
except (AttributeError, ValueError):
|
except (AttributeError, ValueError):
|
||||||
pass
|
pass
|
||||||
|
@ -403,11 +405,12 @@ class Quality(object):
|
||||||
|
|
||||||
tolerance = (lambda value, percent: int(round(value - (value * percent / 100.0))))
|
tolerance = (lambda value, percent: int(round(value - (value * percent / 100.0))))
|
||||||
if None is not height and height >= tolerance(352, 5):
|
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.SDTV
|
||||||
if 1100 < height:
|
if 1100 < height or (None is not width and 2000 < width):
|
||||||
return Quality.UHD4KWEB
|
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
|
return Quality.UNKNOWN
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
|
|
Loading…
Reference in a new issue