Merge branch 'refs/heads/develop'

This commit is contained in:
Ruud
2012-05-13 12:56:37 +02:00
4 changed files with 28 additions and 10 deletions
+3 -3
View File
@@ -2,7 +2,7 @@ from couchpotato.core.downloaders.base import Downloader
from couchpotato.core.helpers.encoding import tryUrlencode
from couchpotato.core.helpers.variable import cleanHost
from couchpotato.core.logger import CPLog
from inspect import isfunction
from inspect import ismethod, isfunction
from tempfile import mkstemp
import base64
import os
@@ -42,10 +42,10 @@ class Sabnzbd(Downloader):
'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'))
if len(nzb_file) < 50:
if not nzb_file or len(nzb_file) < 50:
log.error('No nzb available!')
return False
@@ -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.providers.automation.base import Automation
from couchpotato.environment import Env
from dateutil.parser import parse
import StringIO
import csv
import time
import traceback
log = CPLog(__name__)
@@ -18,19 +21,34 @@ class IMDB(Automation):
return
movies = []
headers = {}
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:
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()
if not headers:
nr = 0
for column in csv_reader.next():
headers[column] = nr
nr += 1
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:
movies.append(imdb)
except:
log.error('Failed loading IMDB watchlist: %s %s' % (csv_url, traceback.format_exc()))
Env.prop(prop_name, time.time())
return movies
@@ -88,10 +88,10 @@ class IMDBAPI(MovieProvider):
'poster': [movie.get('Poster', '')] if movie.get('Poster') and len(movie.get('Poster', '')) > 4 else [],
},
'rating': {
'imdb': (tryFloat(movie.get('Rating', 0)), tryInt(movie.get('Votes', ''))),
'rotten': (tryFloat(movie.get('tomatoRating', 0)), tryInt(movie.get('tomatoReviews', 0))),
'imdb': (tryFloat(movie.get('imdbRating', 0)), tryInt(movie.get('imdbVotes', ''))),
#'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', '')),
'released': movie.get('Released', ''),
'year': year if isinstance(year, (int)) else None,
@@ -138,7 +138,7 @@ class Newzbin(NZBProvider, RSS):
'username' : self.conf('username'),
'password' : self.conf('password'),
'reportid' : nzb_id
})
}, show_error = False)
except Exception, e:
log.error('Failed downloading from newzbin, check credit: %s' % e)
return False