Browse Source

Merge branch 'refs/heads/develop'

pull/381/merge
Ruud 13 years ago
parent
commit
3e369c5838
  1. 6
      couchpotato/core/downloaders/sabnzbd/main.py
  2. 24
      couchpotato/core/providers/automation/imdb/main.py
  3. 6
      couchpotato/core/providers/movie/imdbapi/main.py
  4. 2
      couchpotato/core/providers/nzb/newzbin/main.py

6
couchpotato/core/downloaders/sabnzbd/main.py

@ -2,7 +2,7 @@ from couchpotato.core.downloaders.base import Downloader
from couchpotato.core.helpers.encoding import tryUrlencode from couchpotato.core.helpers.encoding import tryUrlencode
from couchpotato.core.helpers.variable import cleanHost from couchpotato.core.helpers.variable import cleanHost
from couchpotato.core.logger import CPLog from couchpotato.core.logger import CPLog
from inspect import isfunction from inspect import ismethod, isfunction
from tempfile import mkstemp from tempfile import mkstemp
import base64 import base64
import os import os
@ -42,10 +42,10 @@ class Sabnzbd(Downloader):
'nzbname': self.createNzbName(data, movie), 'nzbname': self.createNzbName(data, movie),
} }
if isfunction(data.get('download')): if data.get('download') and (ismethod(data.get('download')) or isfunction(data.get('download'))):
nzb_file = data.get('download')(url = data.get('url'), nzb_id = data.get('id')) nzb_file = data.get('download')(url = data.get('url'), nzb_id = data.get('id'))
if len(nzb_file) < 50: if not nzb_file or len(nzb_file) < 50:
log.error('No nzb available!') log.error('No nzb available!')
return False return False

24
couchpotato/core/providers/automation/imdb/main.py

@ -1,8 +1,11 @@
from couchpotato.core.helpers.variable import md5, getImdb from couchpotato.core.helpers.variable import md5
from couchpotato.core.logger import CPLog from couchpotato.core.logger import CPLog
from couchpotato.core.providers.automation.base import Automation from couchpotato.core.providers.automation.base import Automation
from couchpotato.environment import Env
from dateutil.parser import parse
import StringIO import StringIO
import csv import csv
import time
import traceback import traceback
log = CPLog(__name__) log = CPLog(__name__)
@ -18,19 +21,34 @@ class IMDB(Automation):
return return
movies = [] movies = []
headers = {}
for csv_url in self.conf('automation_urls').split(','): for csv_url in self.conf('automation_urls').split(','):
prop_name = 'automation.imdb.last_update.%s' % md5(csv_url)
last_update = float(Env.prop(prop_name, default = 0))
try: try:
cache_key = 'imdb_csv.%s' % md5(csv_url) cache_key = 'imdb_csv.%s' % md5(csv_url)
csv_data = self.getCache(cache_key, csv_url) csv_data = self.getCache(cache_key, csv_url)
csv_reader = csv.reader(StringIO.StringIO(csv_data)) csv_reader = csv.reader(StringIO.StringIO(csv_data))
csv_reader.next() if not headers:
nr = 0
for column in csv_reader.next():
headers[column] = nr
nr += 1
for row in csv_reader: for row in csv_reader:
imdb = getImdb(str(row)) created = int(time.mktime(parse(row[headers['created']]).timetuple()))
if created < last_update:
continue
imdb = row[headers['const']]
if imdb: if imdb:
movies.append(imdb) movies.append(imdb)
except: except:
log.error('Failed loading IMDB watchlist: %s %s' % (csv_url, traceback.format_exc())) log.error('Failed loading IMDB watchlist: %s %s' % (csv_url, traceback.format_exc()))
Env.prop(prop_name, time.time())
return movies return movies

6
couchpotato/core/providers/movie/imdbapi/main.py

@ -88,10 +88,10 @@ class IMDBAPI(MovieProvider):
'poster': [movie.get('Poster', '')] if movie.get('Poster') and len(movie.get('Poster', '')) > 4 else [], 'poster': [movie.get('Poster', '')] if movie.get('Poster') and len(movie.get('Poster', '')) > 4 else [],
}, },
'rating': { 'rating': {
'imdb': (tryFloat(movie.get('Rating', 0)), tryInt(movie.get('Votes', ''))), 'imdb': (tryFloat(movie.get('imdbRating', 0)), tryInt(movie.get('imdbVotes', ''))),
'rotten': (tryFloat(movie.get('tomatoRating', 0)), tryInt(movie.get('tomatoReviews', 0))), #'rotten': (tryFloat(movie.get('tomatoRating', 0)), tryInt(movie.get('tomatoReviews', 0))),
}, },
'imdb': str(movie.get('ID', '')), 'imdb': str(movie.get('imdbID', '')),
'runtime': self.runtimeToMinutes(movie.get('Runtime', '')), 'runtime': self.runtimeToMinutes(movie.get('Runtime', '')),
'released': movie.get('Released', ''), 'released': movie.get('Released', ''),
'year': year if isinstance(year, (int)) else None, 'year': year if isinstance(year, (int)) else None,

2
couchpotato/core/providers/nzb/newzbin/main.py

@ -138,7 +138,7 @@ class Newzbin(NZBProvider, RSS):
'username' : self.conf('username'), 'username' : self.conf('username'),
'password' : self.conf('password'), 'password' : self.conf('password'),
'reportid' : nzb_id 'reportid' : nzb_id
}) }, show_error = False)
except Exception, e: except Exception, e:
log.error('Failed downloading from newzbin, check credit: %s' % e) log.error('Failed downloading from newzbin, check credit: %s' % e)
return False return False

Loading…
Cancel
Save