Automation base
Working IMDB Watchlists
This commit is contained in:
@@ -0,0 +1,6 @@
|
||||
from .main import Automation
|
||||
|
||||
def start():
|
||||
return Automation()
|
||||
|
||||
config = []
|
||||
@@ -0,0 +1,20 @@
|
||||
from couchpotato.core.event import addEvent, fireEvent
|
||||
from couchpotato.core.logger import CPLog
|
||||
from couchpotato.core.plugins.base import Plugin
|
||||
from couchpotato.environment import Env
|
||||
|
||||
log = CPLog(__name__)
|
||||
|
||||
|
||||
class Automation(Plugin):
|
||||
|
||||
def __init__(self):
|
||||
|
||||
if not Env.setting('development'):
|
||||
addEvent('app.load', self.addMovies)
|
||||
|
||||
def addMovies(self):
|
||||
|
||||
movies = fireEvent('automation.get_movies', merge = True)
|
||||
for imdb_id in movies:
|
||||
fireEvent('movie.add', params = {'identifier': imdb_id}, force_readd = False)
|
||||
@@ -0,0 +1,34 @@
|
||||
from couchpotato.core.event import addEvent
|
||||
from couchpotato.core.logger import CPLog
|
||||
from couchpotato.core.plugins.base import Plugin
|
||||
import time
|
||||
|
||||
log = CPLog(__name__)
|
||||
|
||||
|
||||
class Automation(Plugin):
|
||||
|
||||
enabled_option = 'automation_enabled'
|
||||
|
||||
interval = 86400
|
||||
last_checked = 0
|
||||
|
||||
def __init__(self):
|
||||
addEvent('automation.get_movies', self._getMovies)
|
||||
|
||||
def _getMovies(self):
|
||||
|
||||
if not self.canCheck():
|
||||
log.debug('Just checked, skipping %s' % self.getName())
|
||||
return []
|
||||
|
||||
self.last_checked = time.time()
|
||||
|
||||
return self.getIMDBids()
|
||||
|
||||
|
||||
def getIMDBids(self):
|
||||
return []
|
||||
|
||||
def canCheck(self):
|
||||
return time.time() > self.last_checked + self.interval
|
||||
@@ -0,0 +1,26 @@
|
||||
from .main import CP
|
||||
|
||||
def start():
|
||||
return CP()
|
||||
|
||||
config = [{
|
||||
'name': 'cp',
|
||||
'groups': [
|
||||
{
|
||||
'tab': 'automation',
|
||||
'name': 'couchpotato_automation',
|
||||
'label': 'CouchPotato',
|
||||
'description': 'Enable automatic movie adding from CouchPotato',
|
||||
'options': [
|
||||
{
|
||||
'name': 'automation_enabled',
|
||||
'default': False,
|
||||
'type': 'enabler',
|
||||
},
|
||||
{
|
||||
'name': 'automation_urls',
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
}]
|
||||
@@ -0,0 +1,14 @@
|
||||
from couchpotato.core.logger import CPLog
|
||||
from couchpotato.core.providers.automation.base import Automation
|
||||
|
||||
log = CPLog(__name__)
|
||||
|
||||
|
||||
class CP(Automation):
|
||||
|
||||
def getMovies(self):
|
||||
|
||||
if self.isDisabled():
|
||||
return
|
||||
|
||||
return []
|
||||
@@ -0,0 +1,26 @@
|
||||
from .main import IMDB
|
||||
|
||||
def start():
|
||||
return IMDB()
|
||||
|
||||
config = [{
|
||||
'name': 'imdb',
|
||||
'groups': [
|
||||
{
|
||||
'tab': 'automation',
|
||||
'name': 'imdb_automation',
|
||||
'label': 'IMDB',
|
||||
'description': 'Enable automatic movie adding of IMDB watchlists',
|
||||
'options': [
|
||||
{
|
||||
'name': 'automation_enabled',
|
||||
'default': False,
|
||||
'type': 'enabler',
|
||||
},
|
||||
{
|
||||
'name': 'automation_urls',
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
}]
|
||||
@@ -0,0 +1,36 @@
|
||||
from couchpotato.core.helpers.variable import md5, getImdb
|
||||
from couchpotato.core.logger import CPLog
|
||||
from couchpotato.core.providers.automation.base import Automation
|
||||
import StringIO
|
||||
import csv
|
||||
import traceback
|
||||
|
||||
log = CPLog(__name__)
|
||||
|
||||
|
||||
class IMDB(Automation):
|
||||
|
||||
interval = 1800
|
||||
|
||||
def getIMDBids(self):
|
||||
|
||||
if self.isDisabled():
|
||||
return
|
||||
|
||||
movies = []
|
||||
|
||||
for csv_url in self.conf('automation_urls').split(','):
|
||||
try:
|
||||
cache_key = 'imdb_csv.%s' % md5(csv_url)
|
||||
csv_data = self.getCache(cache_key, csv_url)
|
||||
csv_reader = csv.reader(StringIO.StringIO(csv_data))
|
||||
csv_reader.next()
|
||||
|
||||
for row in csv_reader:
|
||||
imdb = getImdb(str(row))
|
||||
if imdb:
|
||||
movies.append(imdb)
|
||||
except:
|
||||
log.error('Failed loading IMDB watchlist: %s %s' % (csv_url, traceback.format_exc()))
|
||||
|
||||
return movies
|
||||
@@ -0,0 +1,26 @@
|
||||
from .main import Kinepolis
|
||||
|
||||
def start():
|
||||
return Kinepolis()
|
||||
|
||||
config = [{
|
||||
'name': 'kinepolis',
|
||||
'groups': [
|
||||
{
|
||||
'tab': 'automation',
|
||||
'name': 'kinepolis_automation',
|
||||
'label': 'Kinepolis',
|
||||
'description': 'Enable automatic movie adding from Kinepolis',
|
||||
'options': [
|
||||
{
|
||||
'name': 'automation_enabled',
|
||||
'default': False,
|
||||
'type': 'enabler',
|
||||
},
|
||||
{
|
||||
'name': 'automation_urls',
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
}]
|
||||
@@ -0,0 +1,14 @@
|
||||
from couchpotato.core.logger import CPLog
|
||||
from couchpotato.core.providers.automation.base import Automation
|
||||
|
||||
log = CPLog(__name__)
|
||||
|
||||
|
||||
class Kinepolis(Automation):
|
||||
|
||||
def getMovies(self):
|
||||
|
||||
if self.isDisabled():
|
||||
return
|
||||
|
||||
return []
|
||||
@@ -0,0 +1,23 @@
|
||||
from .main import Trakt
|
||||
|
||||
def start():
|
||||
return Trakt()
|
||||
|
||||
config = [{
|
||||
'name': 'trakt',
|
||||
'groups': [
|
||||
{
|
||||
'tab': 'automation',
|
||||
'name': 'trakt_automation',
|
||||
'label': 'Trakt',
|
||||
'description': 'Enable automatic movie adding from Trakt',
|
||||
'options': [
|
||||
{
|
||||
'name': 'automation_enabled',
|
||||
'default': False,
|
||||
'type': 'enabler',
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
}]
|
||||
@@ -0,0 +1,14 @@
|
||||
from couchpotato.core.logger import CPLog
|
||||
from couchpotato.core.providers.automation.base import Automation
|
||||
|
||||
log = CPLog(__name__)
|
||||
|
||||
|
||||
class Trakt(Automation):
|
||||
|
||||
def getMovies(self):
|
||||
|
||||
if self.isDisabled():
|
||||
return
|
||||
|
||||
return []
|
||||
Reference in New Issue
Block a user