Event fixes

This commit is contained in:
Ruud
2012-02-11 02:49:35 +01:00
parent e4588a5e7e
commit cfadd851bf
14 changed files with 115 additions and 98 deletions
+3 -5
View File
@@ -54,7 +54,7 @@ class Plugin(object):
s1 = re.sub('(.)([A-Z][a-z]+)', r'\1_\2', self.__class__.__name__)
class_name = re.sub('([a-z0-9])([A-Z])', r'\1_\2', s1).lower()
path = 'static/' + class_name + '/'
path = '%s/static/%s/' % (Env.setting('api_key'), class_name)
addView(path + '<path:filename>', self.showStatic, static = True)
if add_to_head:
@@ -94,8 +94,6 @@ class Plugin(object):
# http request
def urlopen(self, url, timeout = 10, params = {}, headers = {}, multipart = False, show_error = True):
socket.setdefaulttimeout(timeout)
# Fill in some headers
if not headers.get('Referer'):
headers['Referer'] = urlparse(url).hostname
@@ -114,13 +112,13 @@ class Plugin(object):
cookies = cookielib.CookieJar()
opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(cookies), MultipartPostHandler)
data = opener.open(request).read()
data = opener.open(request, timeout = timeout).read()
else:
log.info('Opening url: %s, params: %s' % (url, [x for x in params.iterkeys()]))
data = urllib.urlencode(params) if len(params) > 0 else None
request = urllib2.Request(url, data, headers)
data = urllib2.urlopen(request).read()
data = urllib2.urlopen(request, timeout = timeout).read()
except IOError:
if show_error:
log.error('Failed opening url in %s: %s %s' % (self.getName(), url, traceback.format_exc(1)))
+2 -2
View File
@@ -290,11 +290,11 @@ class Renamer(Plugin):
# Remove files
for src in remove_files:
log.info('Removing "%s"' % src)
log.info('(fake) Removing "%s"' % src)
# Remove matching releases
for release in remove_releases:
log.info('Removing release %s' % release)
log.info('(fake) Removing release %s' % release)
# Search for trailers etc
fireEventAsync('renamer.after', group)
+3 -1
View File
@@ -528,7 +528,9 @@ class Scanner(Plugin):
return True
def isSampleFile(self, filename):
return re.search('(^|[\W_])sample\d*[\W_]', filename.lower())
is_sample = re.search('(^|[\W_])sample\d*[\W_]', filename.lower())
if is_sample: log.debug('Is sample file: %s' % filename)
return is_sample
def filesizeBetween(self, file, min = 0, max = 100000):
try:
+4 -4
View File
@@ -16,18 +16,18 @@ log = CPLog(__name__)
class Searcher(Plugin):
def __init__(self):
addEvent('searcher.all', self.all)
addEvent('searcher.all', self.all_movies)
addEvent('searcher.single', self.single)
addEvent('searcher.correct_movie', self.correctMovie)
addEvent('searcher.download', self.download)
# Schedule cronjob
fireEvent('schedule.cron', 'searcher.all', self.all, day = self.conf('cron_day'), hour = self.conf('cron_hour'), minute = self.conf('cron_minute'))
fireEvent('schedule.cron', 'searcher.all', self.all_movies, day = self.conf('cron_day'), hour = self.conf('cron_hour'), minute = self.conf('cron_minute'))
if not Env.setting('development'):
addEvent('app.load', self.all)
addEvent('app.load', self.all_movies)
def all(self):
def all_movies(self):
db = get_session()