Automation add some minimal check options

This commit is contained in:
Ruud
2012-01-25 15:45:56 +01:00
parent b502b90158
commit e14be4499c
2 changed files with 56 additions and 2 deletions
@@ -3,4 +3,34 @@ from .main import Automation
def start(): def start():
return Automation() return Automation()
config = [] config = [{
'name': 'automation',
'groups': [
{
'tab': 'automation',
'name': 'automation',
'label': 'Automation',
'description': 'Enable automatic movie adding',
'options': [
{
'name': 'year',
'default': 2011,
'Label': 'Minimal year',
'type': 'int',
},
{
'name': 'votes',
'default': 1000,
'Label': 'Minimal votes',
'type': 'int',
},
{
'name': 'rating',
'default': 6.0,
'Label': 'Minimal rating',
'type': 'float',
},
],
},
],
}]
+25 -1
View File
@@ -1,6 +1,7 @@
from couchpotato.core.event import addEvent from couchpotato.core.event import addEvent, fireEvent
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.environment import Env
import time import time
log = CPLog(__name__) log = CPLog(__name__)
@@ -26,6 +27,29 @@ class Automation(Plugin):
return self.getIMDBids() return self.getIMDBids()
def search(self, name, year = None):
result = fireEvent('movie.search', q = '%s %s' % (name, year if year else ''), limit = 1, merge = True)
if len(result) > 0:
return result[0].get('imdb')
else:
return None
def isMinimal(self, identifier):
movie = fireEvent('movie.info', identifier = identifier, merge = True)
for minimal_type in ['year', 'rating', 'votes']:
type_value = movie.get(minimal_type, 0)
type_min = self.getMinimal(minimal_type)
if type_value < type_min:
log.info('%s to low for %s, need %s has %s' % (minimal_type, identifier, type_min, type_value))
return False
return True
def getMinimal(self, min_type):
return Env.setting(min_type, 'automation')
def getIMDBids(self): def getIMDBids(self):
return [] return []