Browse Source

Simpler quality guessing

pull/51/merge
Ruud 14 years ago
parent
commit
1c42aec362
  1. 33
      couchpotato/core/plugins/quality/main.py

33
couchpotato/core/plugins/quality/main.py

@ -13,11 +13,11 @@ log = CPLog(__name__)
class QualityPlugin(Plugin): class QualityPlugin(Plugin):
qualities = [ 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': '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': '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': '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': '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': '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']}, {'identifier': 'r5', 'size': (600, 1000), 'label': 'R5', 'alternative': [], 'allow': ['dvdr'], 'ext':['avi', 'mpg', 'mpeg']},
@ -114,47 +114,38 @@ class QualityPlugin(Plugin):
return True return True
def guess(self, files, extra = {}, loose = False): def guess(self, files, extra = {}, loose = False):
found = False
print files, extra
for file in files: for file in files:
size = (os.path.getsize(file) / 1024 / 1024) size = (os.path.getsize(file) / 1024 / 1024)
words = re.split('\W+', file.lower()) words = re.split('\W+', file.lower())
for quality in self.all(): for quality in self.all():
correctSize = False
if size >= quality['size_min'] and size <= quality['size_max']:
correctSize = True
# Check tags # Check tags
if quality['identifier'] in words: if quality['identifier'] in words:
log.debug('Found via identifier "%s" in %s' % (quality['identifier'], file)) log.debug('Found via identifier "%s" in %s' % (quality['identifier'], file))
found = True return quality
if list(set(quality.get('alternative', [])) & set(words)): if list(set(quality.get('alternative', [])) & set(words)):
log.debug('Found via alt %s in %s' % (quality.get('alternative'), file)) log.debug('Found %s via alt %s in %s' % (quality['identifier'], quality.get('alternative'), file))
found = True return quality
if list(set(quality.get('tags', [])) & set(words)): if list(set(quality.get('tags', [])) & set(words)):
log.debug('Found via tag %s in %s' % (quality.get('tags'), file)) log.debug('Found %s via tag %s in %s' % (quality['identifier'], quality.get('tags'), file))
found = True return quality
# Check on unreliable stuff # Check on unreliable stuff
if loose: if loose:
# Check extension + filesize # Check extension + filesize
if list(set(quality.get('ext', [])) & set(words)) and correctSize: if list(set(quality.get('ext', [])) & set(words)) and size >= quality['size_min'] and size <= quality['size_max']:
log.debug('Found via ext %s in %s' % (quality.get('ext'), words)) log.debug('Found %s via ext %s in %s' % (quality['identifier'], quality.get('ext'), words))
found = True return quality
# Last check on resolution only # Last check on resolution only
if quality.get('width', 480) == extra.get('resolution_width', 0): 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))) log.debug('Found %s via resolution_width: %s == %s' % (quality['identifier'], quality.get('width', 480), extra.get('resolution_width', 0)))
found = True return quality
if found:
return quality
# Try again with loose testing # Try again with loose testing
quality = self.guess(files, extra = extra, loose = True) quality = self.guess(files, extra = extra, loose = True)

Loading…
Cancel
Save