Browse Source

Cleanup up bluray.com and kinopolis providers

pull/584/head
Ruud 13 years ago
parent
commit
4e10fddf95
  1. 2
      couchpotato/core/plugins/automation/__init__.py
  2. 4
      couchpotato/core/plugins/automation/main.py
  3. 26
      couchpotato/core/providers/automation/base.py
  4. 2
      couchpotato/core/providers/automation/bluray/__init__.py
  5. 4
      couchpotato/core/providers/automation/bluray/main.py
  6. 2
      couchpotato/core/providers/automation/kinepolis/__init__.py
  7. 12
      couchpotato/core/providers/automation/kinepolis/main.py

2
couchpotato/core/plugins/automation/__init__.py

@ -25,7 +25,7 @@ config = [{
},
{
'name': 'rating',
'default': 6.0,
'default': 7.0,
'type': 'float',
},
{

4
couchpotato/core/plugins/automation/main.py

@ -19,4 +19,8 @@ class Automation(Plugin):
movies = fireEvent('automation.get_movies', merge = True)
for imdb_id in movies:
prop_name = 'automation.added.%s' % imdb_id
added = Env.prop(prop_name, default = False)
if not added:
fireEvent('movie.add', params = {'identifier': imdb_id}, force_readd = False)
Env.prop(prop_name, True)

26
couchpotato/core/providers/automation/base.py

@ -2,7 +2,6 @@ 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
from couchpotato.core.helpers.encoding import simplifyString
import time
log = CPLog(__name__)
@ -36,13 +35,8 @@ class Automation(Plugin):
else:
return None
def isMinimal(self, identifier):
movie = fireEvent('movie.info', identifier = identifier, merge = True)
return self.isMinimalMovie(movie)
def isMinimalMovie(self, movie):
if movie['rating']:
rating = movie['rating']['imdb'][0]
if movie['rating'] and movie['rating'].get('imdb'):
movie['votes'] = movie['rating']['imdb'][1]
movie['rating'] = movie['rating']['imdb'][0]
identifier = movie['imdb']
@ -55,19 +49,13 @@ class Automation(Plugin):
return True
def getIMDBFromTitle(self, title):
cache_key = u'%s/%s' % (__name__, simplifyString(title))
movies = Env.get('cache').get(cache_key)
if not movies:
movies = fireEvent('movie.searchimdb', q = title, merge = True)
Env.get('cache').set(cache_key, movies)
try:
return movies[0]
def getIMDBFromTitle(self, name, year = None):
result = fireEvent('movie.search', q = '%s %s' % (name, year), limit = 1, merge = True)
except:
log.info("No results for " + title)
if len(result) > 0:
return result[0]
else:
return None
def getMinimal(self, min_type):
return Env.setting(min_type, 'automation')

2
couchpotato/core/providers/automation/bluray/__init__.py

@ -10,7 +10,7 @@ config = [{
'tab': 'automation',
'name': 'bluray_automation',
'label': 'Blu-ray.com',
'description': 'imports movies from blu-ray.com',
'description': 'Imports movies from blu-ray.com. (uses minimal requirements)',
'options': [
{
'name': 'automation_enabled',

4
couchpotato/core/providers/automation/bluray/main.py

@ -3,9 +3,7 @@ from couchpotato.core.helpers.variable import md5
from couchpotato.core.logger import CPLog
from couchpotato.core.providers.automation.base import Automation
from couchpotato.environment import Env
import traceback
import xml.etree.ElementTree as XMLTree
import json
log = CPLog(__name__)
@ -52,7 +50,7 @@ class Bluray(Automation, RSS):
log.info('No movies found.')
return
log.info("Applying IMDB filter to found movies...")
log.debug("Applying IMDB filter to found movies...")
for RSSMovie in RSSMovies:
imdb = self.getIMDBFromTitle(RSSMovie['name'] + ' ' + RSSMovie['year'])

2
couchpotato/core/providers/automation/kinepolis/__init__.py

@ -10,7 +10,7 @@ config = [{
'tab': 'automation',
'name': 'kinepolis_automation',
'label': 'Kinepolis',
'description': 'imports movies from the current top 10 of kinepolis',
'description': 'Imports movies from the current top 10 of kinepolis. (uses minimal requirements)',
'options': [
{
'name': 'automation_enabled',

12
couchpotato/core/providers/automation/kinepolis/main.py

@ -2,12 +2,8 @@ from couchpotato.core.helpers.rss import RSS
from couchpotato.core.helpers.variable import md5
from couchpotato.core.logger import CPLog
from couchpotato.core.providers.automation.base import Automation
from couchpotato.environment import Env
from dateutil.parser import parse
import time
import traceback
import xml.etree.ElementTree as XMLTree
import datetime
import xml.etree.ElementTree as XMLTree
log = CPLog(__name__)
@ -29,7 +25,7 @@ class Kinepolis(Automation, RSS):
rss_data = self.getCache(cache_key, self.rss_url)
data = XMLTree.fromstring(rss_data)
if data:
if data is not None:
rss_movies = self.getElements(data, 'channel/item')
for movie in rss_movies:
@ -37,8 +33,8 @@ class Kinepolis(Automation, RSS):
currentYear = datetime.datetime.now().strftime("%Y")
RSSMovie['year'] = currentYear
log.info('Release found: %s.' % RSSMovie)
imdb = self.getIMDBFromTitle(RSSMovie['name'] + ' ' + RSSMovie['year'])
log.debug('Release found: %s.', RSSMovie)
imdb = self.getIMDBFromTitle(RSSMovie['name'], RSSMovie['year'])
if imdb:
movies.append(imdb['imdb'])

Loading…
Cancel
Save