Do some scoring with scene / nuked. fix #2009
This commit is contained in:
@@ -1,11 +1,11 @@
|
|||||||
from couchpotato.core.event import addEvent
|
from couchpotato.core.event import addEvent, fireEvent
|
||||||
from couchpotato.core.helpers.encoding import toUnicode
|
from couchpotato.core.helpers.encoding import toUnicode
|
||||||
from couchpotato.core.helpers.variable import getTitle, splitString
|
from couchpotato.core.helpers.variable import getTitle, splitString
|
||||||
from couchpotato.core.logger import CPLog
|
from couchpotato.core.logger import CPLog
|
||||||
from couchpotato.core.plugins.base import Plugin
|
from couchpotato.core.plugins.base import Plugin
|
||||||
from couchpotato.core.plugins.score.scores import nameScore, nameRatioScore, \
|
from couchpotato.core.plugins.score.scores import nameScore, nameRatioScore, \
|
||||||
sizeScore, providerScore, duplicateScore, partialIgnoredScore, namePositionScore, \
|
sizeScore, providerScore, duplicateScore, partialIgnoredScore, namePositionScore, \
|
||||||
halfMultipartScore
|
halfMultipartScore, sceneScore
|
||||||
from couchpotato.environment import Env
|
from couchpotato.environment import Env
|
||||||
|
|
||||||
log = CPLog(__name__)
|
log = CPLog(__name__)
|
||||||
@@ -62,4 +62,7 @@ class Score(Plugin):
|
|||||||
if extra_score:
|
if extra_score:
|
||||||
score += extra_score(nzb)
|
score += extra_score(nzb)
|
||||||
|
|
||||||
|
# Scene / Nuke scoring
|
||||||
|
score += sceneScore(nzb['name'])
|
||||||
|
|
||||||
return score
|
return score
|
||||||
|
|||||||
@@ -1,8 +1,13 @@
|
|||||||
from couchpotato.core.event import fireEvent
|
from couchpotato.core.event import fireEvent
|
||||||
from couchpotato.core.helpers.encoding import simplifyString
|
from couchpotato.core.helpers.encoding import simplifyString
|
||||||
from couchpotato.core.helpers.variable import tryInt
|
from couchpotato.core.helpers.variable import tryInt
|
||||||
|
from couchpotato.core.logger import CPLog
|
||||||
from couchpotato.environment import Env
|
from couchpotato.environment import Env
|
||||||
import re
|
import re
|
||||||
|
import traceback
|
||||||
|
|
||||||
|
log = CPLog(__name__)
|
||||||
|
|
||||||
|
|
||||||
name_scores = [
|
name_scores = [
|
||||||
# Tags
|
# Tags
|
||||||
@@ -160,3 +165,38 @@ def halfMultipartScore(nzb_name):
|
|||||||
return -30
|
return -30
|
||||||
|
|
||||||
return 0
|
return 0
|
||||||
|
|
||||||
|
|
||||||
|
def sceneScore(nzb_name):
|
||||||
|
|
||||||
|
check_names = [nzb_name]
|
||||||
|
|
||||||
|
# Match names between "
|
||||||
|
try: check_names.append(re.search(r'([\'"])[^\1]*\1', nzb_name).group(0))
|
||||||
|
except: pass
|
||||||
|
|
||||||
|
# Match longest name between []
|
||||||
|
try: check_names.append(max(re.findall(r'[^[]*\[([^]]*)\]', nzb_name), key = len).strip())
|
||||||
|
except: pass
|
||||||
|
|
||||||
|
for name in check_names:
|
||||||
|
|
||||||
|
# Strip twice, remove possible file extensions
|
||||||
|
name = name.lower().strip(' "\'\.-_\[\]')
|
||||||
|
name = re.sub('\.([a-z0-9]{0,4})$', '', name)
|
||||||
|
name = name.strip(' "\'\.-_\[\]')
|
||||||
|
|
||||||
|
# Make sure year and groupname is in there
|
||||||
|
year = re.findall('(?P<year>19[0-9]{2}|20[0-9]{2})', name)
|
||||||
|
group = re.findall('\-([a-z0-9]+)$', name)
|
||||||
|
|
||||||
|
if len(year) > 0 and len(group) > 0:
|
||||||
|
try:
|
||||||
|
validate = fireEvent('release.validate', name, single = True)
|
||||||
|
if validate and tryInt(validate.get('score')) != 0:
|
||||||
|
log.debug('Release "%s" scored %s, reason: %s', (nzb_name, validate['score'], validate['reasons']))
|
||||||
|
return tryInt(validate.get('score'))
|
||||||
|
except:
|
||||||
|
log.error('Failed scoring scene: %s', traceback.format_exc())
|
||||||
|
|
||||||
|
return 0
|
||||||
|
|||||||
Reference in New Issue
Block a user