Simpler quality guessing
This commit is contained in:
@@ -13,11 +13,11 @@ log = CPLog(__name__)
|
||||
class QualityPlugin(Plugin):
|
||||
|
||||
qualities = [
|
||||
{'identifier': 'bd50', 'size': (15000, 60000), 'label': 'BR-Disk', 'width': 1920, 'alternative': ['bd25'], 'allow': ['1080p'], 'ext':[], 'tags': ['x264', 'h264', 'bluray']},
|
||||
{'identifier': 'bd50', 'size': (15000, 60000), 'label': 'BR-Disk', 'width': 1920, 'alternative': ['bd25'], 'allow': ['1080p'], 'ext':[], 'tags': []},
|
||||
{'identifier': '1080p', 'size': (5000, 20000), 'label': '1080P', 'width': 1920, 'alternative': [], 'allow': [], 'ext':['mkv', 'm2ts'], 'tags': ['x264', 'h264', 'bluray']},
|
||||
{'identifier': '720p', 'size': (3500, 10000), 'label': '720P', 'width': 1280, 'alternative': [], 'allow': [], 'ext':['mkv', 'm2ts'], 'tags': ['x264', 'h264', 'bluray']},
|
||||
{'identifier': 'brrip', 'size': (700, 7000), 'label': 'BR-Rip', 'alternative': ['bdrip'], 'allow': ['720p'], 'ext':['avi']},
|
||||
{'identifier': 'dvdr', 'size': (3000, 10000), 'label': 'DVD-R', 'alternative': [], 'allow': [], 'ext':['iso', 'img'], 'tags': ['pal', 'ntsc']},
|
||||
{'identifier': 'dvdr', 'size': (3000, 10000), 'label': 'DVD-R', 'alternative': [], 'allow': [], 'ext':['iso', 'img'], 'tags': ['pal', 'ntsc', 'video_ts', 'audio_ts']},
|
||||
{'identifier': 'dvdrip', 'size': (600, 2400), 'label': 'DVD-Rip', 'alternative': ['dvdrip'], 'allow': [], 'ext':['avi', 'mpg', 'mpeg']},
|
||||
{'identifier': 'scr', 'size': (600, 1600), 'label': 'Screener', 'alternative': ['dvdscr', 'ppvrip'], 'allow': ['dvdr'], 'ext':['avi', 'mpg', 'mpeg']},
|
||||
{'identifier': 'r5', 'size': (600, 1000), 'label': 'R5', 'alternative': [], 'allow': ['dvdr'], 'ext':['avi', 'mpg', 'mpeg']},
|
||||
@@ -114,47 +114,38 @@ class QualityPlugin(Plugin):
|
||||
return True
|
||||
|
||||
def guess(self, files, extra = {}, loose = False):
|
||||
found = False
|
||||
|
||||
print files, extra
|
||||
|
||||
for file in files:
|
||||
size = (os.path.getsize(file) / 1024 / 1024)
|
||||
words = re.split('\W+', file.lower())
|
||||
|
||||
for quality in self.all():
|
||||
correctSize = False
|
||||
|
||||
if size >= quality['size_min'] and size <= quality['size_max']:
|
||||
correctSize = True
|
||||
|
||||
# Check tags
|
||||
if quality['identifier'] in words:
|
||||
log.debug('Found via identifier "%s" in %s' % (quality['identifier'], file))
|
||||
found = True
|
||||
return quality
|
||||
|
||||
if list(set(quality.get('alternative', [])) & set(words)):
|
||||
log.debug('Found via alt %s in %s' % (quality.get('alternative'), file))
|
||||
found = True
|
||||
log.debug('Found %s via alt %s in %s' % (quality['identifier'], quality.get('alternative'), file))
|
||||
return quality
|
||||
|
||||
if list(set(quality.get('tags', [])) & set(words)):
|
||||
log.debug('Found via tag %s in %s' % (quality.get('tags'), file))
|
||||
found = True
|
||||
log.debug('Found %s via tag %s in %s' % (quality['identifier'], quality.get('tags'), file))
|
||||
return quality
|
||||
|
||||
# Check on unreliable stuff
|
||||
if loose:
|
||||
# Check extension + filesize
|
||||
if list(set(quality.get('ext', [])) & set(words)) and correctSize:
|
||||
log.debug('Found via ext %s in %s' % (quality.get('ext'), words))
|
||||
found = True
|
||||
if list(set(quality.get('ext', [])) & set(words)) and size >= quality['size_min'] and size <= quality['size_max']:
|
||||
log.debug('Found %s via ext %s in %s' % (quality['identifier'], quality.get('ext'), words))
|
||||
return quality
|
||||
|
||||
# Last check on resolution only
|
||||
if quality.get('width', 480) == extra.get('resolution_width', 0):
|
||||
log.debug('Found via resoludtion_width: %s == %s' % (quality.get('width', 480), extra.get('resolution_width', 0)))
|
||||
found = True
|
||||
log.debug('Found %s via resolution_width: %s == %s' % (quality['identifier'], quality.get('width', 480), extra.get('resolution_width', 0)))
|
||||
return quality
|
||||
|
||||
if found:
|
||||
return quality
|
||||
|
||||
# Try again with loose testing
|
||||
quality = self.guess(files, extra = extra, loose = True)
|
||||
|
||||
Reference in New Issue
Block a user