Try and encode logging messages. fix #403
This commit is contained in:
@@ -96,7 +96,7 @@ class Core(Plugin):
|
|||||||
while loop:
|
while loop:
|
||||||
log.debug('Asking who is running')
|
log.debug('Asking who is running')
|
||||||
still_running = fireEvent('plugin.running', merge = True)
|
still_running = fireEvent('plugin.running', merge = True)
|
||||||
log.debug('Still running: %s' % still_running)
|
log.debug('Still running: %s', still_running)
|
||||||
|
|
||||||
if len(still_running) == 0:
|
if len(still_running) == 0:
|
||||||
break
|
break
|
||||||
@@ -105,7 +105,7 @@ class Core(Plugin):
|
|||||||
|
|
||||||
running = list(set(still_running) - set(self.ignore_restart))
|
running = list(set(still_running) - set(self.ignore_restart))
|
||||||
if len(running) > 0:
|
if len(running) > 0:
|
||||||
log.info('Waiting on plugins to finish: %s' % running)
|
log.info('Waiting on plugins to finish: %s', running)
|
||||||
else:
|
else:
|
||||||
loop = False
|
loop = False
|
||||||
|
|
||||||
@@ -118,7 +118,7 @@ class Core(Plugin):
|
|||||||
except RuntimeError:
|
except RuntimeError:
|
||||||
pass
|
pass
|
||||||
except:
|
except:
|
||||||
log.error('Failed shutting down the server: %s' % traceback.format_exc())
|
log.error('Failed shutting down the server: %s', traceback.format_exc())
|
||||||
|
|
||||||
fireEvent('app.after_shutdown', restart = restart)
|
fireEvent('app.after_shutdown', restart = restart)
|
||||||
|
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ class Scheduler(Plugin):
|
|||||||
for type in ['interval', 'cron']:
|
for type in ['interval', 'cron']:
|
||||||
try:
|
try:
|
||||||
self.sched.unschedule_job(getattr(self, type)[identifier]['job'])
|
self.sched.unschedule_job(getattr(self, type)[identifier]['job'])
|
||||||
log.debug('%s unscheduled %s' % (type.capitalize(), identifier))
|
log.debug('%s unscheduled %s', (type.capitalize(), identifier))
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
@@ -45,7 +45,7 @@ class Scheduler(Plugin):
|
|||||||
job = self.sched.add_cron_job(cron['handle'], day = cron['day'], hour = cron['hour'], minute = cron['minute'])
|
job = self.sched.add_cron_job(cron['handle'], day = cron['day'], hour = cron['hour'], minute = cron['minute'])
|
||||||
cron['job'] = job
|
cron['job'] = job
|
||||||
except ValueError, e:
|
except ValueError, e:
|
||||||
log.error("Failed adding cronjob: %s" % e)
|
log.error('Failed adding cronjob: %s', e)
|
||||||
|
|
||||||
# Intervals
|
# Intervals
|
||||||
for identifier in self.intervals:
|
for identifier in self.intervals:
|
||||||
@@ -55,7 +55,7 @@ class Scheduler(Plugin):
|
|||||||
job = self.sched.add_interval_job(interval['handle'], hours = interval['hours'], minutes = interval['minutes'], seconds = interval['seconds'])
|
job = self.sched.add_interval_job(interval['handle'], hours = interval['hours'], minutes = interval['minutes'], seconds = interval['seconds'])
|
||||||
interval['job'] = job
|
interval['job'] = job
|
||||||
except ValueError, e:
|
except ValueError, e:
|
||||||
log.error("Failed adding interval cronjob: %s" % e)
|
log.error('Failed adding interval cronjob: %s', e)
|
||||||
|
|
||||||
# Start it
|
# Start it
|
||||||
log.debug('Starting scheduler')
|
log.debug('Starting scheduler')
|
||||||
@@ -75,7 +75,7 @@ class Scheduler(Plugin):
|
|||||||
self.started = False
|
self.started = False
|
||||||
|
|
||||||
def cron(self, identifier = '', handle = None, day = '*', hour = '*', minute = '*'):
|
def cron(self, identifier = '', handle = None, day = '*', hour = '*', minute = '*'):
|
||||||
log.info('Scheduling "%s", cron: day = %s, hour = %s, minute = %s' % (identifier, day, hour, minute))
|
log.info('Scheduling "%s", cron: day = %s, hour = %s, minute = %s', (identifier, day, hour, minute))
|
||||||
|
|
||||||
self.remove(identifier)
|
self.remove(identifier)
|
||||||
self.crons[identifier] = {
|
self.crons[identifier] = {
|
||||||
@@ -86,7 +86,7 @@ class Scheduler(Plugin):
|
|||||||
}
|
}
|
||||||
|
|
||||||
def interval(self, identifier = '', handle = None, hours = 0, minutes = 0, seconds = 0):
|
def interval(self, identifier = '', handle = None, hours = 0, minutes = 0, seconds = 0):
|
||||||
log.info('Scheduling %s, interval: hours = %s, minutes = %s, seconds = %s' % (identifier, hours, minutes, seconds))
|
log.info('Scheduling %s, interval: hours = %s, minutes = %s, seconds = %s', (identifier, hours, minutes, seconds))
|
||||||
|
|
||||||
self.remove(identifier)
|
self.remove(identifier)
|
||||||
self.intervals[identifier] = {
|
self.intervals[identifier] = {
|
||||||
|
|||||||
@@ -128,11 +128,11 @@ class BaseUpdater(Plugin):
|
|||||||
|
|
||||||
for excess_pyc_file in excess_pyc_files:
|
for excess_pyc_file in excess_pyc_files:
|
||||||
full_path = os.path.join(root, excess_pyc_file)
|
full_path = os.path.join(root, excess_pyc_file)
|
||||||
log.debug('Removing old PYC file: %s' % full_path)
|
log.debug('Removing old PYC file: %s', full_path)
|
||||||
try:
|
try:
|
||||||
os.remove(full_path)
|
os.remove(full_path)
|
||||||
except:
|
except:
|
||||||
log.error('Couldn\'t remove %s: %s' % (full_path, traceback.format_exc()))
|
log.error('Couldn\'t remove %s: %s', (full_path, traceback.format_exc()))
|
||||||
|
|
||||||
for dir_name in dirs:
|
for dir_name in dirs:
|
||||||
full_path = os.path.join(root, dir_name)
|
full_path = os.path.join(root, dir_name)
|
||||||
@@ -140,7 +140,7 @@ class BaseUpdater(Plugin):
|
|||||||
try:
|
try:
|
||||||
os.rmdir(full_path)
|
os.rmdir(full_path)
|
||||||
except:
|
except:
|
||||||
log.error('Couldn\'t remove empty directory %s: %s' % (full_path, traceback.format_exc()))
|
log.error('Couldn\'t remove empty directory %s: %s', (full_path, traceback.format_exc()))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -170,7 +170,7 @@ class GitUpdater(BaseUpdater):
|
|||||||
|
|
||||||
return True
|
return True
|
||||||
except:
|
except:
|
||||||
log.error('Failed updating via GIT: %s' % traceback.format_exc())
|
log.error('Failed updating via GIT: %s', traceback.format_exc())
|
||||||
|
|
||||||
self.update_failed = True
|
self.update_failed = True
|
||||||
|
|
||||||
@@ -181,14 +181,14 @@ class GitUpdater(BaseUpdater):
|
|||||||
if not self.version:
|
if not self.version:
|
||||||
try:
|
try:
|
||||||
output = self.repo.getHead() # Yes, please
|
output = self.repo.getHead() # Yes, please
|
||||||
log.debug('Git version output: %s' % output.hash)
|
log.debug('Git version output: %s', output.hash)
|
||||||
self.version = {
|
self.version = {
|
||||||
'hash': output.hash[:8],
|
'hash': output.hash[:8],
|
||||||
'date': output.getDate(),
|
'date': output.getDate(),
|
||||||
'type': 'git',
|
'type': 'git',
|
||||||
}
|
}
|
||||||
except Exception, e:
|
except Exception, e:
|
||||||
log.error('Failed using GIT updater, running from source, you need to have GIT installed. %s' % e)
|
log.error('Failed using GIT updater, running from source, you need to have GIT installed. %s', e)
|
||||||
return 'No GIT'
|
return 'No GIT'
|
||||||
|
|
||||||
return self.version
|
return self.version
|
||||||
@@ -198,7 +198,7 @@ class GitUpdater(BaseUpdater):
|
|||||||
if self.update_version:
|
if self.update_version:
|
||||||
return
|
return
|
||||||
|
|
||||||
log.info('Checking for new version on github for %s' % self.repo_name)
|
log.info('Checking for new version on github for %s', self.repo_name)
|
||||||
if not Env.get('dev'):
|
if not Env.get('dev'):
|
||||||
self.repo.fetch()
|
self.repo.fetch()
|
||||||
|
|
||||||
@@ -210,7 +210,7 @@ class GitUpdater(BaseUpdater):
|
|||||||
local = self.repo.getHead()
|
local = self.repo.getHead()
|
||||||
remote = branch.getHead()
|
remote = branch.getHead()
|
||||||
|
|
||||||
log.info('Versions, local:%s, remote:%s' % (local.hash[:8], remote.hash[:8]))
|
log.info('Versions, local:%s, remote:%s', (local.hash[:8], remote.hash[:8]))
|
||||||
|
|
||||||
if local.getDate() < remote.getDate():
|
if local.getDate() < remote.getDate():
|
||||||
self.update_version = {
|
self.update_version = {
|
||||||
@@ -263,7 +263,7 @@ class SourceUpdater(BaseUpdater):
|
|||||||
|
|
||||||
return True
|
return True
|
||||||
except:
|
except:
|
||||||
log.error('Failed updating: %s' % traceback.format_exc())
|
log.error('Failed updating: %s', traceback.format_exc())
|
||||||
|
|
||||||
self.update_failed = True
|
self.update_failed = True
|
||||||
return False
|
return False
|
||||||
@@ -296,7 +296,7 @@ class SourceUpdater(BaseUpdater):
|
|||||||
except ValueError:
|
except ValueError:
|
||||||
pass
|
pass
|
||||||
except Exception, e:
|
except Exception, e:
|
||||||
log.error('Failed overwriting file: %s' % e)
|
log.error('Failed overwriting file: %s', e)
|
||||||
|
|
||||||
|
|
||||||
def removeDir(self, path):
|
def removeDir(self, path):
|
||||||
@@ -315,11 +315,11 @@ class SourceUpdater(BaseUpdater):
|
|||||||
output = json.loads(f.read())
|
output = json.loads(f.read())
|
||||||
f.close()
|
f.close()
|
||||||
|
|
||||||
log.debug('Source version output: %s' % output)
|
log.debug('Source version output: %s', output)
|
||||||
self.version = output
|
self.version = output
|
||||||
self.version['type'] = 'source'
|
self.version['type'] = 'source'
|
||||||
except Exception, e:
|
except Exception, e:
|
||||||
log.error('Failed using source updater. %s' % e)
|
log.error('Failed using source updater. %s', e)
|
||||||
return {}
|
return {}
|
||||||
|
|
||||||
return self.version
|
return self.version
|
||||||
@@ -336,7 +336,7 @@ class SourceUpdater(BaseUpdater):
|
|||||||
|
|
||||||
self.last_check = time.time()
|
self.last_check = time.time()
|
||||||
except:
|
except:
|
||||||
log.error('Failed updating via source: %s' % traceback.format_exc())
|
log.error('Failed updating via source: %s', traceback.format_exc())
|
||||||
|
|
||||||
return self.update_version is not None
|
return self.update_version is not None
|
||||||
|
|
||||||
@@ -351,7 +351,7 @@ class SourceUpdater(BaseUpdater):
|
|||||||
'date': int(time.mktime(parse(commit['commit']['committer']['date']).timetuple())),
|
'date': int(time.mktime(parse(commit['commit']['committer']['date']).timetuple())),
|
||||||
}
|
}
|
||||||
except:
|
except:
|
||||||
log.error('Failed getting latest request from github: %s' % traceback.format_exc())
|
log.error('Failed getting latest request from github: %s', traceback.format_exc())
|
||||||
|
|
||||||
return {}
|
return {}
|
||||||
|
|
||||||
@@ -372,7 +372,7 @@ class DesktopUpdater(BaseUpdater):
|
|||||||
if e['status'] == 'done':
|
if e['status'] == 'done':
|
||||||
fireEventAsync('app.restart')
|
fireEventAsync('app.restart')
|
||||||
else:
|
else:
|
||||||
log.error('Failed updating desktop: %s' % e['exception'])
|
log.error('Failed updating desktop: %s', e['exception'])
|
||||||
self.update_failed = True
|
self.update_failed = True
|
||||||
|
|
||||||
self.desktop._esky.auto_update(callback = do_restart)
|
self.desktop._esky.auto_update(callback = do_restart)
|
||||||
@@ -403,7 +403,7 @@ class DesktopUpdater(BaseUpdater):
|
|||||||
|
|
||||||
self.last_check = time.time()
|
self.last_check = time.time()
|
||||||
except:
|
except:
|
||||||
log.error('Failed updating desktop: %s' % traceback.format_exc())
|
log.error('Failed updating desktop: %s', traceback.format_exc())
|
||||||
|
|
||||||
return self.update_version is not None
|
return self.update_version is not None
|
||||||
|
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ class Blackhole(Downloader):
|
|||||||
|
|
||||||
directory = self.conf('directory')
|
directory = self.conf('directory')
|
||||||
if not directory or not os.path.isdir(directory):
|
if not directory or not os.path.isdir(directory):
|
||||||
log.error('No directory set for blackhole %s download.' % data.get('type'))
|
log.error('No directory set for blackhole %s download.', data.get('type'))
|
||||||
else:
|
else:
|
||||||
try:
|
try:
|
||||||
if not filedata or len(filedata) < 50:
|
if not filedata or len(filedata) < 50:
|
||||||
@@ -27,19 +27,19 @@ class Blackhole(Downloader):
|
|||||||
|
|
||||||
try:
|
try:
|
||||||
if not os.path.isfile(fullPath):
|
if not os.path.isfile(fullPath):
|
||||||
log.info('Downloading %s to %s.' % (data.get('type'), fullPath))
|
log.info('Downloading %s to %s.', (data.get('type'), fullPath))
|
||||||
with open(fullPath, 'wb') as f:
|
with open(fullPath, 'wb') as f:
|
||||||
f.write(filedata)
|
f.write(filedata)
|
||||||
return True
|
return True
|
||||||
else:
|
else:
|
||||||
log.info('File %s already exists.' % fullPath)
|
log.info('File %s already exists.', fullPath)
|
||||||
return True
|
return True
|
||||||
|
|
||||||
except:
|
except:
|
||||||
log.error('Failed to download to blackhole %s' % traceback.format_exc())
|
log.error('Failed to download to blackhole %s', traceback.format_exc())
|
||||||
pass
|
pass
|
||||||
|
|
||||||
except:
|
except:
|
||||||
log.info('Failed to download file %s: %s' % (data.get('name'), traceback.format_exc()))
|
log.info('Failed to download file %s: %s', (data.get('name'), traceback.format_exc()))
|
||||||
return False
|
return False
|
||||||
return False
|
return False
|
||||||
|
|||||||
@@ -20,10 +20,10 @@ class NZBGet(Downloader):
|
|||||||
return
|
return
|
||||||
|
|
||||||
if not filedata:
|
if not filedata:
|
||||||
log.error('Unable to get NZB file: %s' % traceback.format_exc())
|
log.error('Unable to get NZB file: %s', traceback.format_exc())
|
||||||
return False
|
return False
|
||||||
|
|
||||||
log.info('Sending "%s" to NZBGet.' % data.get('name'))
|
log.info('Sending "%s" to NZBGet.', data.get('name'))
|
||||||
|
|
||||||
url = self.url % {'host': self.conf('host'), 'password': self.conf('password')}
|
url = self.url % {'host': self.conf('host'), 'password': self.conf('password')}
|
||||||
nzb_name = '%s.nzb' % self.createNzbName(data, movie)
|
nzb_name = '%s.nzb' % self.createNzbName(data, movie)
|
||||||
@@ -41,12 +41,12 @@ class NZBGet(Downloader):
|
|||||||
if e.errcode == 401:
|
if e.errcode == 401:
|
||||||
log.error('Password is incorrect.')
|
log.error('Password is incorrect.')
|
||||||
else:
|
else:
|
||||||
log.error('Protocol Error: %s' % e)
|
log.error('Protocol Error: %s', e)
|
||||||
return False
|
return False
|
||||||
|
|
||||||
if rpc.append(nzb_name, self.conf('category'), False, standard_b64encode(filedata.strip())):
|
if rpc.append(nzb_name, self.conf('category'), False, standard_b64encode(filedata.strip())):
|
||||||
log.info('NZB sent successfully to NZBGet')
|
log.info('NZB sent successfully to NZBGet')
|
||||||
return True
|
return True
|
||||||
else:
|
else:
|
||||||
log.error('NZBGet could not add %s to the queue.' % nzb_name)
|
log.error('NZBGet could not add %s to the queue.', nzb_name)
|
||||||
return False
|
return False
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ class Sabnzbd(Downloader):
|
|||||||
if self.isDisabled(manual) or not self.isCorrectType(data.get('type')):
|
if self.isDisabled(manual) or not self.isCorrectType(data.get('type')):
|
||||||
return
|
return
|
||||||
|
|
||||||
log.info("Sending '%s' to SABnzbd." % data.get('name'))
|
log.info('Sending "%s" to SABnzbd.', data.get('name'))
|
||||||
|
|
||||||
params = {
|
params = {
|
||||||
'apikey': self.conf('api_key'),
|
'apikey': self.conf('api_key'),
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ class Transmission(Downloader):
|
|||||||
if self.isDisabled(manual) or not self.isCorrectType(data.get('type')):
|
if self.isDisabled(manual) or not self.isCorrectType(data.get('type')):
|
||||||
return
|
return
|
||||||
|
|
||||||
log.info('Sending "%s" to Transmission.' % data.get('name'))
|
log.info('Sending "%s" to Transmission.', data.get('name'))
|
||||||
|
|
||||||
# Load host from config and split out port.
|
# Load host from config and split out port.
|
||||||
host = self.conf('host').split(':')
|
host = self.conf('host').split(':')
|
||||||
@@ -42,10 +42,10 @@ class Transmission(Downloader):
|
|||||||
torrent.seed_ratio_limit = self.conf('ratio')
|
torrent.seed_ratio_limit = self.conf('ratio')
|
||||||
torrent.seed_ratio_mode = 'single' if self.conf('ratio') else 'global'
|
torrent.seed_ratio_mode = 'single' if self.conf('ratio') else 'global'
|
||||||
except transmissionrpc.TransmissionError, e:
|
except transmissionrpc.TransmissionError, e:
|
||||||
log.error('Failed to change settings for transfer in transmission: %s' % e)
|
log.error('Failed to change settings for transfer in transmission: %s', e)
|
||||||
|
|
||||||
return True
|
return True
|
||||||
|
|
||||||
except transmissionrpc.TransmissionError, e:
|
except transmissionrpc.TransmissionError, e:
|
||||||
log.error('Failed to send link to transmission: %s' % e)
|
log.error('Failed to send link to transmission: %s', e)
|
||||||
return False
|
return False
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ def runHandler(name, handler, *args, **kwargs):
|
|||||||
return handler(*args, **kwargs)
|
return handler(*args, **kwargs)
|
||||||
except:
|
except:
|
||||||
from couchpotato.environment import Env
|
from couchpotato.environment import Env
|
||||||
log.error('Error in event "%s", that wasn\'t caught: %s%s' % (name, traceback.format_exc(), Env.all()))
|
log.error('Error in event "%s", that wasn\'t caught: %s%s', (name, traceback.format_exc(), Env.all()))
|
||||||
|
|
||||||
def addEvent(name, handler, priority = 100):
|
def addEvent(name, handler, priority = 100):
|
||||||
|
|
||||||
@@ -43,7 +43,7 @@ def removeEvent(name, handler):
|
|||||||
|
|
||||||
def fireEvent(name, *args, **kwargs):
|
def fireEvent(name, *args, **kwargs):
|
||||||
if not events.get(name): return
|
if not events.get(name): return
|
||||||
#log.debug('Firing event %s' % name)
|
#log.debug('Firing event %s', name)
|
||||||
try:
|
try:
|
||||||
|
|
||||||
# Fire after event
|
# Fire after event
|
||||||
@@ -100,7 +100,7 @@ def fireEvent(name, *args, **kwargs):
|
|||||||
elif r[1]:
|
elif r[1]:
|
||||||
errorHandler(r[1])
|
errorHandler(r[1])
|
||||||
else:
|
else:
|
||||||
log.debug('Assume disabled eventhandler for: %s' % name)
|
log.debug('Assume disabled eventhandler for: %s', name)
|
||||||
|
|
||||||
else:
|
else:
|
||||||
results = []
|
results = []
|
||||||
@@ -130,7 +130,7 @@ def fireEvent(name, *args, **kwargs):
|
|||||||
|
|
||||||
modified_results = fireEvent('result.modify.%s' % name, results, single = True)
|
modified_results = fireEvent('result.modify.%s' % name, results, single = True)
|
||||||
if modified_results:
|
if modified_results:
|
||||||
log.debug('Return modified results for %s' % name)
|
log.debug('Return modified results for %s', name)
|
||||||
results = modified_results
|
results = modified_results
|
||||||
|
|
||||||
if not is_after_event:
|
if not is_after_event:
|
||||||
@@ -143,7 +143,7 @@ def fireEvent(name, *args, **kwargs):
|
|||||||
except KeyError, e:
|
except KeyError, e:
|
||||||
pass
|
pass
|
||||||
except Exception:
|
except Exception:
|
||||||
log.error('%s: %s' % (name, traceback.format_exc()))
|
log.error('%s: %s', (name, traceback.format_exc()))
|
||||||
|
|
||||||
def fireEventAsync(*args, **kwargs):
|
def fireEventAsync(*args, **kwargs):
|
||||||
try:
|
try:
|
||||||
@@ -152,7 +152,7 @@ def fireEventAsync(*args, **kwargs):
|
|||||||
my_thread.start()
|
my_thread.start()
|
||||||
return True
|
return True
|
||||||
except Exception, e:
|
except Exception, e:
|
||||||
log.error('%s: %s' % (args[0], e))
|
log.error('%s: %s', (args[0], e))
|
||||||
|
|
||||||
def errorHandler(error):
|
def errorHandler(error):
|
||||||
etype, value, tb = error
|
etype, value, tb = error
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ def toUnicode(original, *args):
|
|||||||
except:
|
except:
|
||||||
raise
|
raise
|
||||||
except UnicodeDecodeError:
|
except UnicodeDecodeError:
|
||||||
log.error('Unable to decode value: %s... ' % repr(original)[:20])
|
log.error('Unable to decode value: %s... ', repr(original)[:20])
|
||||||
ascii_text = str(original).encode('string_escape')
|
ascii_text = str(original).encode('string_escape')
|
||||||
return toUnicode(ascii_text)
|
return toUnicode(ascii_text)
|
||||||
|
|
||||||
|
|||||||
@@ -47,5 +47,5 @@ class RSS(object):
|
|||||||
try:
|
try:
|
||||||
return XMLTree.parse(data).findall(path)
|
return XMLTree.parse(data).findall(path)
|
||||||
except Exception, e:
|
except Exception, e:
|
||||||
log.error('Error parsing RSS. %s' % e)
|
log.error('Error parsing RSS. %s', e)
|
||||||
return []
|
return []
|
||||||
|
|||||||
@@ -118,10 +118,10 @@ def getTitle(library_dict):
|
|||||||
try:
|
try:
|
||||||
return library_dict['titles'][0]['title']
|
return library_dict['titles'][0]['title']
|
||||||
except:
|
except:
|
||||||
log.error('Could not get title for %s' % library_dict['identifier'])
|
log.error('Could not get title for %s', library_dict['identifier'])
|
||||||
return None
|
return None
|
||||||
except:
|
except:
|
||||||
log.error('Could not get title for library item: %s' % library_dict)
|
log.error('Could not get title for library item: %s', library_dict)
|
||||||
return None
|
return None
|
||||||
|
|
||||||
def randomString(size = 8, chars = string.ascii_uppercase + string.digits):
|
def randomString(size = 8, chars = string.ascii_uppercase + string.digits):
|
||||||
|
|||||||
@@ -45,7 +45,7 @@ class Loader(object):
|
|||||||
try:
|
try:
|
||||||
m = getattr(self.loadModule(module_name), plugin.get('name'))
|
m = getattr(self.loadModule(module_name), plugin.get('name'))
|
||||||
|
|
||||||
log.info("Loading %s: %s" % (plugin['type'], plugin['name']))
|
log.info('Loading %s: %s', (plugin['type'], plugin['name']))
|
||||||
|
|
||||||
# Save default settings for plugin/provider
|
# Save default settings for plugin/provider
|
||||||
did_save += self.loadSettings(m, module_name, save = False)
|
did_save += self.loadSettings(m, module_name, save = False)
|
||||||
@@ -57,10 +57,10 @@ class Loader(object):
|
|||||||
log.error(e.message)
|
log.error(e.message)
|
||||||
pass
|
pass
|
||||||
# todo:: this needs to be more descriptive.
|
# todo:: this needs to be more descriptive.
|
||||||
log.error('Import error, remove the empty folder: %s' % plugin.get('module'))
|
log.error('Import error, remove the empty folder: %s', plugin.get('module'))
|
||||||
log.debug('Can\'t import %s: %s' % (module_name, traceback.format_exc()))
|
log.debug('Can\'t import %s: %s', (module_name, traceback.format_exc()))
|
||||||
except:
|
except:
|
||||||
log.error('Can\'t import %s: %s' % (module_name, traceback.format_exc()))
|
log.error('Can\'t import %s: %s', (module_name, traceback.format_exc()))
|
||||||
|
|
||||||
if did_save:
|
if did_save:
|
||||||
fireEvent('settings.save')
|
fireEvent('settings.save')
|
||||||
@@ -84,7 +84,7 @@ class Loader(object):
|
|||||||
fireEvent('settings.register', section_name = section['name'], options = options, save = save)
|
fireEvent('settings.register', section_name = section['name'], options = options, save = save)
|
||||||
return True
|
return True
|
||||||
except:
|
except:
|
||||||
log.debug("Failed loading settings for '%s': %s" % (name, traceback.format_exc()))
|
log.debug('Failed loading settings for "%s": %s', (name, traceback.format_exc()))
|
||||||
return False
|
return False
|
||||||
|
|
||||||
def loadPlugins(self, module, name):
|
def loadPlugins(self, module, name):
|
||||||
@@ -97,7 +97,7 @@ class Loader(object):
|
|||||||
|
|
||||||
return True
|
return True
|
||||||
except Exception, e:
|
except Exception, e:
|
||||||
log.error("Failed loading plugin '%s': %s" % (module.__file__, traceback.format_exc()))
|
log.error('Failed loading plugin "%s": %s', (module.__file__, traceback.format_exc()))
|
||||||
return False
|
return False
|
||||||
|
|
||||||
def addModule(self, priority, plugin_type, module, name):
|
def addModule(self, priority, plugin_type, module, name):
|
||||||
|
|||||||
+34
-18
@@ -1,5 +1,6 @@
|
|||||||
import logging
|
import logging
|
||||||
import re
|
import re
|
||||||
|
import traceback
|
||||||
|
|
||||||
class CPLog(object):
|
class CPLog(object):
|
||||||
|
|
||||||
@@ -13,39 +14,54 @@ class CPLog(object):
|
|||||||
self.context = context
|
self.context = context
|
||||||
self.logger = logging.getLogger()
|
self.logger = logging.getLogger()
|
||||||
|
|
||||||
def info(self, msg):
|
def info(self, msg, replace_tuple = ()):
|
||||||
self.logger.info(self.addContext(msg))
|
self.logger.info(self.addContext(msg, replace_tuple))
|
||||||
|
|
||||||
def debug(self, msg):
|
def debug(self, msg, replace_tuple = ()):
|
||||||
self.logger.debug(self.addContext(msg))
|
self.logger.debug(self.addContext(msg, replace_tuple))
|
||||||
|
|
||||||
def error(self, msg):
|
def error(self, msg, replace_tuple = ()):
|
||||||
self.logger.error(self.addContext(msg))
|
self.logger.error(self.addContext(msg, replace_tuple))
|
||||||
|
|
||||||
def warning(self, msg):
|
def warning(self, msg, replace_tuple = ()):
|
||||||
self.logger.warning(self.addContext(msg))
|
self.logger.warning(self.addContext(msg, replace_tuple))
|
||||||
|
|
||||||
def critical(self, msg):
|
def critical(self, msg, replace_tuple = ()):
|
||||||
self.logger.critical(self.addContext(msg), exc_info = 1)
|
self.logger.critical(self.addContext(msg, replace_tuple), exc_info = 1)
|
||||||
|
|
||||||
def addContext(self, msg):
|
def addContext(self, msg, replace_tuple = ()):
|
||||||
return '[%+25.25s] %s' % (self.context[-25:], self.removePrivateData(msg))
|
return '[%+25.25s] %s' % (self.context[-25:], self.safeMessage(msg, replace_tuple))
|
||||||
|
|
||||||
|
def safeMessage(self, msg, replace_tuple = ()):
|
||||||
|
|
||||||
|
if not hasattr(self, 'Env'):
|
||||||
|
from couchpotato.environment import Env
|
||||||
|
from couchpotato.core.helpers.encoding import toUnicode
|
||||||
|
|
||||||
|
self.Env = Env
|
||||||
|
self.toUnicode = toUnicode
|
||||||
|
|
||||||
|
msg = self.toUnicode(msg)
|
||||||
|
|
||||||
def removePrivateData(self, msg):
|
|
||||||
try:
|
try:
|
||||||
msg = unicode(msg)
|
msg = msg % replace_tuple
|
||||||
except:
|
except:
|
||||||
pass
|
try:
|
||||||
|
if isinstance(replace_tuple, tuple):
|
||||||
|
msg = msg % tuple([self.toUnicode(x).encode(self.Env.get('encoding')) for x in list(replace_tuple)])
|
||||||
|
else:
|
||||||
|
msg = msg % self.toUnicode(replace_tuple).encode(self.Env.get('encoding'))
|
||||||
|
except:
|
||||||
|
self.error('Failed encoding stuff to log: %s' % traceback.format_exc())
|
||||||
|
|
||||||
from couchpotato.environment import Env
|
if not self.Env.get('dev'):
|
||||||
if not Env.get('dev'):
|
|
||||||
|
|
||||||
for replace in self.replace_private:
|
for replace in self.replace_private:
|
||||||
msg = re.sub('(%s=)[^\&]+' % replace, '%s=xxx' % replace, msg)
|
msg = re.sub('(%s=)[^\&]+' % replace, '%s=xxx' % replace, msg)
|
||||||
|
|
||||||
# Replace api key
|
# Replace api key
|
||||||
try:
|
try:
|
||||||
api_key = Env.setting('api_key')
|
api_key = self.Env.setting('api_key')
|
||||||
if api_key:
|
if api_key:
|
||||||
msg = msg.replace(api_key, 'API_KEY')
|
msg = msg.replace(api_key, 'API_KEY')
|
||||||
except:
|
except:
|
||||||
|
|||||||
@@ -41,7 +41,7 @@ class Notification(Plugin):
|
|||||||
|
|
||||||
test_type = self.testNotifyName()
|
test_type = self.testNotifyName()
|
||||||
|
|
||||||
log.info('Sending test to %s' % test_type)
|
log.info('Sending test to %s', test_type)
|
||||||
|
|
||||||
success = self.notify(
|
success = self.notify(
|
||||||
message = self.test_message,
|
message = self.test_message,
|
||||||
|
|||||||
@@ -38,7 +38,7 @@ class Growl(Notification):
|
|||||||
self.growl.register()
|
self.growl.register()
|
||||||
self.registered = True
|
self.registered = True
|
||||||
except:
|
except:
|
||||||
log.error('Failed register of growl: %s' % traceback.format_exc())
|
log.error('Failed register of growl: %s', traceback.format_exc())
|
||||||
|
|
||||||
def notify(self, message = '', data = {}, listener = None):
|
def notify(self, message = '', data = {}, listener = None):
|
||||||
if self.isDisabled(): return
|
if self.isDisabled(): return
|
||||||
|
|||||||
@@ -33,10 +33,10 @@ class NMJ(Notification):
|
|||||||
try:
|
try:
|
||||||
terminal = telnetlib.Telnet(host)
|
terminal = telnetlib.Telnet(host)
|
||||||
except Exception:
|
except Exception:
|
||||||
log.error('Warning: unable to get a telnet session to %s' % (host))
|
log.error('Warning: unable to get a telnet session to %s', (host))
|
||||||
return self.failed()
|
return self.failed()
|
||||||
|
|
||||||
log.debug('Connected to %s via telnet' % (host))
|
log.debug('Connected to %s via telnet', (host))
|
||||||
terminal.read_until('sh-3.00# ')
|
terminal.read_until('sh-3.00# ')
|
||||||
terminal.write('cat /tmp/source\n')
|
terminal.write('cat /tmp/source\n')
|
||||||
terminal.write('cat /tmp/netshare\n')
|
terminal.write('cat /tmp/netshare\n')
|
||||||
@@ -48,9 +48,9 @@ class NMJ(Notification):
|
|||||||
if match:
|
if match:
|
||||||
database = match.group(1)
|
database = match.group(1)
|
||||||
device = match.group(2)
|
device = match.group(2)
|
||||||
log.info('Found NMJ database %s on device %s' % (database, device))
|
log.info('Found NMJ database %s on device %s', (database, device))
|
||||||
else:
|
else:
|
||||||
log.error('Could not get current NMJ database on %s, NMJ is probably not running!' % (host))
|
log.error('Could not get current NMJ database on %s, NMJ is probably not running!', (host))
|
||||||
return self.failed()
|
return self.failed()
|
||||||
|
|
||||||
if device.startswith('NETWORK_SHARE/'):
|
if device.startswith('NETWORK_SHARE/'):
|
||||||
@@ -58,7 +58,7 @@ class NMJ(Notification):
|
|||||||
|
|
||||||
if match:
|
if match:
|
||||||
mount = match.group().replace('127.0.0.1', host)
|
mount = match.group().replace('127.0.0.1', host)
|
||||||
log.info('Found mounting url on the Popcorn Hour in configuration: %s' % (mount))
|
log.info('Found mounting url on the Popcorn Hour in configuration: %s', (mount))
|
||||||
else:
|
else:
|
||||||
log.error('Detected a network share on the Popcorn Hour, but could not get the mounting url')
|
log.error('Detected a network share on the Popcorn Hour, but could not get the mounting url')
|
||||||
return self.failed()
|
return self.failed()
|
||||||
@@ -77,7 +77,7 @@ class NMJ(Notification):
|
|||||||
database = self.conf('database')
|
database = self.conf('database')
|
||||||
|
|
||||||
if self.mount:
|
if self.mount:
|
||||||
log.debug('Try to mount network drive via url: %s' % (mount))
|
log.debug('Try to mount network drive via url: %s', (mount))
|
||||||
try:
|
try:
|
||||||
data = self.urlopen(mount)
|
data = self.urlopen(mount)
|
||||||
except:
|
except:
|
||||||
@@ -102,11 +102,11 @@ class NMJ(Notification):
|
|||||||
et = etree.fromstring(response)
|
et = etree.fromstring(response)
|
||||||
result = et.findtext('returnValue')
|
result = et.findtext('returnValue')
|
||||||
except SyntaxError, e:
|
except SyntaxError, e:
|
||||||
log.error('Unable to parse XML returned from the Popcorn Hour: %s' % (e))
|
log.error('Unable to parse XML returned from the Popcorn Hour: %s', (e))
|
||||||
return False
|
return False
|
||||||
|
|
||||||
if int(result) > 0:
|
if int(result) > 0:
|
||||||
log.error('Popcorn Hour returned an errorcode: %s' % (result))
|
log.error('Popcorn Hour returned an errorcode: %s', (result))
|
||||||
return False
|
return False
|
||||||
else:
|
else:
|
||||||
log.info('NMJ started background scan')
|
log.info('NMJ started background scan')
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ class Notifo(Notification):
|
|||||||
raise Exception
|
raise Exception
|
||||||
|
|
||||||
except:
|
except:
|
||||||
log.error('Notification failed: %s' % traceback.format_exc())
|
log.error('Notification failed: %s', traceback.format_exc())
|
||||||
return False
|
return False
|
||||||
|
|
||||||
log.info('Notifo notification successful.')
|
log.info('Notifo notification successful.')
|
||||||
|
|||||||
@@ -23,6 +23,6 @@ class NotifyMyAndroid(Notification):
|
|||||||
|
|
||||||
for key in keys:
|
for key in keys:
|
||||||
if not response[str(key)]['code'] == u'200':
|
if not response[str(key)]['code'] == u'200':
|
||||||
log.error('Could not send notification to NotifyMyAndroid (%s). %s' % (key, response[key]['message']))
|
log.error('Could not send notification to NotifyMyAndroid (%s). %s', (key, response[key]['message']))
|
||||||
|
|
||||||
return response
|
return response
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ class NotifyMyWP(Notification):
|
|||||||
|
|
||||||
for key in keys:
|
for key in keys:
|
||||||
if not response[key]['Code'] == u'200':
|
if not response[key]['Code'] == u'200':
|
||||||
log.error('Could not send notification to NotifyMyWindowsPhone (%s). %s' % (key, response[key]['message']))
|
log.error('Could not send notification to NotifyMyWindowsPhone (%s). %s', (key, response[key]['message']))
|
||||||
return False
|
return False
|
||||||
|
|
||||||
return response
|
return response
|
||||||
|
|||||||
@@ -38,7 +38,7 @@ class Plex(Notification):
|
|||||||
x = self.urlopen(url)
|
x = self.urlopen(url)
|
||||||
|
|
||||||
except:
|
except:
|
||||||
log.error('Plex library update failed for %s: %s' % (host, traceback.format_exc()))
|
log.error('Plex library update failed for %s: %s', (host, traceback.format_exc()))
|
||||||
return False
|
return False
|
||||||
|
|
||||||
return True
|
return True
|
||||||
@@ -63,5 +63,5 @@ class Plex(Notification):
|
|||||||
log.error("Couldn't sent command to Plex")
|
log.error("Couldn't sent command to Plex")
|
||||||
return False
|
return False
|
||||||
|
|
||||||
log.info('Plex notification to %s successful.' % host)
|
log.info('Plex notification to %s successful.', host)
|
||||||
return True
|
return True
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ class Prowl(Notification):
|
|||||||
log.info('Prowl notifications sent.')
|
log.info('Prowl notifications sent.')
|
||||||
return True
|
return True
|
||||||
elif request_status == 401:
|
elif request_status == 401:
|
||||||
log.error('Prowl auth failed: %s' % response.reason)
|
log.error('Prowl auth failed: %s', response.reason)
|
||||||
return False
|
return False
|
||||||
else:
|
else:
|
||||||
log.error('Prowl notification failed.')
|
log.error('Prowl notification failed.')
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ class Pushover(Notification):
|
|||||||
log.info('Pushover notifications sent.')
|
log.info('Pushover notifications sent.')
|
||||||
return True
|
return True
|
||||||
elif request_status == 401:
|
elif request_status == 401:
|
||||||
log.error('Pushover auth failed: %s' % response.reason)
|
log.error('Pushover auth failed: %s', response.reason)
|
||||||
return False
|
return False
|
||||||
else:
|
else:
|
||||||
log.error('Pushover notification failed.')
|
log.error('Pushover notification failed.')
|
||||||
|
|||||||
@@ -15,14 +15,14 @@ class Synoindex(Notification):
|
|||||||
if self.isDisabled(): return
|
if self.isDisabled(): return
|
||||||
|
|
||||||
command = ['/usr/syno/bin/synoindex', '-A', group.get('destination_dir')]
|
command = ['/usr/syno/bin/synoindex', '-A', group.get('destination_dir')]
|
||||||
log.info(u'Executing synoindex command: %s ' % command)
|
log.info(u'Executing synoindex command: %s ', command)
|
||||||
try:
|
try:
|
||||||
p = subprocess.Popen(command, stdout = subprocess.PIPE, stderr = subprocess.STDOUT)
|
p = subprocess.Popen(command, stdout = subprocess.PIPE, stderr = subprocess.STDOUT)
|
||||||
out = p.communicate()
|
out = p.communicate()
|
||||||
log.info('Result from synoindex: %s' % str(out))
|
log.info('Result from synoindex: %s', str(out))
|
||||||
return True
|
return True
|
||||||
except OSError, e:
|
except OSError, e:
|
||||||
log.error('Unable to run synoindex: %s' % e)
|
log.error('Unable to run synoindex: %s', e)
|
||||||
return False
|
return False
|
||||||
|
|
||||||
return True
|
return True
|
||||||
|
|||||||
@@ -55,7 +55,7 @@ class Twitter(Notification):
|
|||||||
else:
|
else:
|
||||||
api.PostUpdate('[%s] %s' % (self.default_title, message))
|
api.PostUpdate('[%s] %s' % (self.default_title, message))
|
||||||
except Exception, e:
|
except Exception, e:
|
||||||
log.error('Error sending tweet: %s' % e)
|
log.error('Error sending tweet: %s', e)
|
||||||
return False
|
return False
|
||||||
|
|
||||||
return True
|
return True
|
||||||
@@ -71,7 +71,7 @@ class Twitter(Notification):
|
|||||||
resp, content = oauth_client.request(self.urls['request'], 'POST', body = tryUrlencode({'oauth_callback': callback_url}))
|
resp, content = oauth_client.request(self.urls['request'], 'POST', body = tryUrlencode({'oauth_callback': callback_url}))
|
||||||
|
|
||||||
if resp['status'] != '200':
|
if resp['status'] != '200':
|
||||||
log.error('Invalid response from Twitter requesting temp token: %s' % resp['status'])
|
log.error('Invalid response from Twitter requesting temp token: %s', resp['status'])
|
||||||
return jsonified({
|
return jsonified({
|
||||||
'success': False,
|
'success': False,
|
||||||
})
|
})
|
||||||
@@ -80,7 +80,7 @@ class Twitter(Notification):
|
|||||||
|
|
||||||
auth_url = self.urls['authorize'] + ("?oauth_token=%s" % self.request_token['oauth_token'])
|
auth_url = self.urls['authorize'] + ("?oauth_token=%s" % self.request_token['oauth_token'])
|
||||||
|
|
||||||
log.info('Redirecting to "%s"' % auth_url)
|
log.info('Redirecting to "%s"', auth_url)
|
||||||
return jsonified({
|
return jsonified({
|
||||||
'success': True,
|
'success': True,
|
||||||
'url': auth_url,
|
'url': auth_url,
|
||||||
@@ -100,10 +100,10 @@ class Twitter(Notification):
|
|||||||
access_token = dict(parse_qsl(content))
|
access_token = dict(parse_qsl(content))
|
||||||
|
|
||||||
if resp['status'] != '200':
|
if resp['status'] != '200':
|
||||||
log.error('The request for an access token did not succeed: %s' % resp['status'])
|
log.error('The request for an access token did not succeed: %s', resp['status'])
|
||||||
return 'Twitter auth failed'
|
return 'Twitter auth failed'
|
||||||
else:
|
else:
|
||||||
log.debug('Tokens: %s, %s' % (access_token['oauth_token'], access_token['oauth_token_secret']))
|
log.debug('Tokens: %s, %s', (access_token['oauth_token'], access_token['oauth_token_secret']))
|
||||||
|
|
||||||
self.conf('access_token_key', value = access_token['oauth_token'])
|
self.conf('access_token_key', value = access_token['oauth_token'])
|
||||||
self.conf('access_token_secret', value = access_token['oauth_token_secret'])
|
self.conf('access_token_secret', value = access_token['oauth_token_secret'])
|
||||||
|
|||||||
@@ -35,5 +35,5 @@ class XBMC(Notification):
|
|||||||
log.error("Couldn't sent command to XBMC")
|
log.error("Couldn't sent command to XBMC")
|
||||||
return False
|
return False
|
||||||
|
|
||||||
log.info('XBMC notification to %s successful.' % host)
|
log.info('XBMC notification to %s successful.', host)
|
||||||
return True
|
return True
|
||||||
|
|||||||
@@ -80,7 +80,7 @@ class Plugin(object):
|
|||||||
f.close()
|
f.close()
|
||||||
os.chmod(path, Env.getPermission('file'))
|
os.chmod(path, Env.getPermission('file'))
|
||||||
except Exception, e:
|
except Exception, e:
|
||||||
log.error('Unable writing to file "%s": %s' % (path, e))
|
log.error('Unable writing to file "%s": %s', (path, e))
|
||||||
|
|
||||||
def makeDir(self, path):
|
def makeDir(self, path):
|
||||||
try:
|
try:
|
||||||
@@ -88,7 +88,7 @@ class Plugin(object):
|
|||||||
os.makedirs(path, Env.getPermission('folder'))
|
os.makedirs(path, Env.getPermission('folder'))
|
||||||
return True
|
return True
|
||||||
except Exception, e:
|
except Exception, e:
|
||||||
log.error('Unable to create folder "%s": %s' % (path, e))
|
log.error('Unable to create folder "%s": %s', (path, e))
|
||||||
|
|
||||||
return False
|
return False
|
||||||
|
|
||||||
@@ -106,7 +106,7 @@ class Plugin(object):
|
|||||||
# Don't try for failed requests
|
# Don't try for failed requests
|
||||||
if self.http_failed_disabled.get(host, 0) > 0:
|
if self.http_failed_disabled.get(host, 0) > 0:
|
||||||
if self.http_failed_disabled[host] > (time.time() - 900):
|
if self.http_failed_disabled[host] > (time.time() - 900):
|
||||||
log.info('Disabled calls to %s for 15 minutes because so many failed requests.' % host)
|
log.info('Disabled calls to %s for 15 minutes because so many failed requests.', host)
|
||||||
raise Exception
|
raise Exception
|
||||||
else:
|
else:
|
||||||
del self.http_failed_request[host]
|
del self.http_failed_request[host]
|
||||||
@@ -116,7 +116,7 @@ class Plugin(object):
|
|||||||
try:
|
try:
|
||||||
|
|
||||||
if multipart:
|
if multipart:
|
||||||
log.info('Opening multipart url: %s, params: %s' % (url, [x for x in params.iterkeys()]))
|
log.info('Opening multipart url: %s, params: %s', (url, [x for x in params.iterkeys()]))
|
||||||
request = urllib2.Request(url, params, headers)
|
request = urllib2.Request(url, params, headers)
|
||||||
|
|
||||||
cookies = cookielib.CookieJar()
|
cookies = cookielib.CookieJar()
|
||||||
@@ -124,7 +124,7 @@ class Plugin(object):
|
|||||||
|
|
||||||
data = opener.open(request, timeout = timeout).read()
|
data = opener.open(request, timeout = timeout).read()
|
||||||
else:
|
else:
|
||||||
log.info('Opening url: %s, params: %s' % (url, [x for x in params.iterkeys()]))
|
log.info('Opening url: %s, params: %s', (url, [x for x in params.iterkeys()]))
|
||||||
data = tryUrlencode(params) if len(params) > 0 else None
|
data = tryUrlencode(params) if len(params) > 0 else None
|
||||||
request = urllib2.Request(url, data, headers)
|
request = urllib2.Request(url, data, headers)
|
||||||
|
|
||||||
@@ -133,7 +133,7 @@ class Plugin(object):
|
|||||||
self.http_failed_request[host] = 0
|
self.http_failed_request[host] = 0
|
||||||
except IOError:
|
except IOError:
|
||||||
if show_error:
|
if show_error:
|
||||||
log.error('Failed opening url in %s: %s %s' % (self.getName(), url, traceback.format_exc(1)))
|
log.error('Failed opening url in %s: %s %s', (self.getName(), url, traceback.format_exc(1)))
|
||||||
|
|
||||||
# Save failed requests by hosts
|
# Save failed requests by hosts
|
||||||
try:
|
try:
|
||||||
@@ -147,7 +147,7 @@ class Plugin(object):
|
|||||||
self.http_failed_disabled[host] = time.time()
|
self.http_failed_disabled[host] = time.time()
|
||||||
|
|
||||||
except:
|
except:
|
||||||
log.debug('Failed logging failed requests for %s: %s' % (url, traceback.format_exc()))
|
log.debug('Failed logging failed requests for %s: %s', (url, traceback.format_exc()))
|
||||||
|
|
||||||
raise
|
raise
|
||||||
|
|
||||||
@@ -163,7 +163,7 @@ class Plugin(object):
|
|||||||
wait = math.ceil(last_use - now + self.http_time_between_calls)
|
wait = math.ceil(last_use - now + self.http_time_between_calls)
|
||||||
|
|
||||||
if wait > 0:
|
if wait > 0:
|
||||||
log.debug('Waiting for %s, %d seconds' % (self.getName(), wait))
|
log.debug('Waiting for %s, %d seconds', (self.getName(), wait))
|
||||||
time.sleep(last_use - now + self.http_time_between_calls)
|
time.sleep(last_use - now + self.http_time_between_calls)
|
||||||
|
|
||||||
def beforeCall(self, handler):
|
def beforeCall(self, handler):
|
||||||
@@ -202,7 +202,7 @@ class Plugin(object):
|
|||||||
cache_key = simplifyString(cache_key)
|
cache_key = simplifyString(cache_key)
|
||||||
cache = Env.get('cache').get(cache_key)
|
cache = Env.get('cache').get(cache_key)
|
||||||
if cache:
|
if cache:
|
||||||
if not Env.get('dev'): log.debug('Getting cache %s' % cache_key)
|
if not Env.get('dev'): log.debug('Getting cache %s', cache_key)
|
||||||
return cache
|
return cache
|
||||||
|
|
||||||
if url:
|
if url:
|
||||||
@@ -220,7 +220,7 @@ class Plugin(object):
|
|||||||
pass
|
pass
|
||||||
|
|
||||||
def setCache(self, cache_key, value, timeout = 300):
|
def setCache(self, cache_key, value, timeout = 300):
|
||||||
log.debug('Setting cache %s' % cache_key)
|
log.debug('Setting cache %s', cache_key)
|
||||||
Env.get('cache').set(cache_key, value, timeout)
|
Env.get('cache').set(cache_key, value, timeout)
|
||||||
return value
|
return value
|
||||||
|
|
||||||
|
|||||||
@@ -78,7 +78,7 @@ class LibraryPlugin(Plugin):
|
|||||||
except: pass
|
except: pass
|
||||||
|
|
||||||
if not info or len(info) == 0:
|
if not info or len(info) == 0:
|
||||||
log.error('Could not update, no movie info to work with: %s' % identifier)
|
log.error('Could not update, no movie info to work with: %s', identifier)
|
||||||
return False
|
return False
|
||||||
|
|
||||||
# Main info
|
# Main info
|
||||||
@@ -95,7 +95,7 @@ class LibraryPlugin(Plugin):
|
|||||||
db.commit()
|
db.commit()
|
||||||
|
|
||||||
titles = info.get('titles', [])
|
titles = info.get('titles', [])
|
||||||
log.debug('Adding titles: %s' % titles)
|
log.debug('Adding titles: %s', titles)
|
||||||
for title in titles:
|
for title in titles:
|
||||||
if not title:
|
if not title:
|
||||||
continue
|
continue
|
||||||
@@ -123,7 +123,7 @@ class LibraryPlugin(Plugin):
|
|||||||
library.files.append(file_obj)
|
library.files.append(file_obj)
|
||||||
db.commit()
|
db.commit()
|
||||||
except:
|
except:
|
||||||
log.debug('Failed to attach to library: %s' % traceback.format_exc())
|
log.debug('Failed to attach to library: %s', traceback.format_exc())
|
||||||
|
|
||||||
library_dict = library.to_dict(self.default_dict)
|
library_dict = library.to_dict(self.default_dict)
|
||||||
|
|
||||||
|
|||||||
@@ -149,7 +149,7 @@ class Logging(Plugin):
|
|||||||
except:
|
except:
|
||||||
log.error(log_message)
|
log.error(log_message)
|
||||||
except:
|
except:
|
||||||
log.error('Couldn\'t log via API: %s' % params)
|
log.error('Couldn\'t log via API: %s', params)
|
||||||
|
|
||||||
|
|
||||||
return jsonified({
|
return jsonified({
|
||||||
|
|||||||
@@ -52,10 +52,10 @@ class Manage(Plugin):
|
|||||||
|
|
||||||
if not os.path.isdir(directory):
|
if not os.path.isdir(directory):
|
||||||
if len(directory) > 0:
|
if len(directory) > 0:
|
||||||
log.error('Directory doesn\'t exist: %s' % directory)
|
log.error('Directory doesn\'t exist: %s', directory)
|
||||||
continue
|
continue
|
||||||
|
|
||||||
log.info('Updating manage library: %s' % directory)
|
log.info('Updating manage library: %s', directory)
|
||||||
identifiers = fireEvent('scanner.folder', folder = directory, newer_than = last_update if not full else 0, single = True)
|
identifiers = fireEvent('scanner.folder', folder = directory, newer_than = last_update if not full else 0, single = True)
|
||||||
if identifiers:
|
if identifiers:
|
||||||
added_identifiers.extend(identifiers)
|
added_identifiers.extend(identifiers)
|
||||||
|
|||||||
@@ -315,7 +315,7 @@ class MoviePlugin(Plugin):
|
|||||||
|
|
||||||
m.profile_id = params.get('profile_id', default_profile.get('id'))
|
m.profile_id = params.get('profile_id', default_profile.get('id'))
|
||||||
else:
|
else:
|
||||||
log.debug('Movie already exists, not updating: %s' % params)
|
log.debug('Movie already exists, not updating: %s', params)
|
||||||
added = False
|
added = False
|
||||||
|
|
||||||
if force_readd:
|
if force_readd:
|
||||||
@@ -458,7 +458,7 @@ class MoviePlugin(Plugin):
|
|||||||
log.debug('Can\'t restatus movie, doesn\'t seem to exist.')
|
log.debug('Can\'t restatus movie, doesn\'t seem to exist.')
|
||||||
return False
|
return False
|
||||||
|
|
||||||
log.debug('Changing status for %s' % (m.library.titles[0].title))
|
log.debug('Changing status for %s', (m.library.titles[0].title))
|
||||||
if not m.profile:
|
if not m.profile:
|
||||||
m.status_id = done_status.get('id')
|
m.status_id = done_status.get('id')
|
||||||
else:
|
else:
|
||||||
|
|||||||
@@ -135,8 +135,7 @@ class ProfilePlugin(Plugin):
|
|||||||
|
|
||||||
success = True
|
success = True
|
||||||
except Exception, e:
|
except Exception, e:
|
||||||
message = 'Failed deleting Profile: %s' % e
|
message = log.error('Failed deleting Profile: %s', e)
|
||||||
log.error(message)
|
|
||||||
|
|
||||||
#db.close()
|
#db.close()
|
||||||
|
|
||||||
@@ -163,7 +162,7 @@ class ProfilePlugin(Plugin):
|
|||||||
# Create default quality profile
|
# Create default quality profile
|
||||||
order = -2
|
order = -2
|
||||||
for profile in profiles:
|
for profile in profiles:
|
||||||
log.info('Creating default profile: %s' % profile.get('label'))
|
log.info('Creating default profile: %s', profile.get('label'))
|
||||||
p = Profile(
|
p = Profile(
|
||||||
label = toUnicode(profile.get('label')),
|
label = toUnicode(profile.get('label')),
|
||||||
order = order
|
order = order
|
||||||
|
|||||||
@@ -116,7 +116,7 @@ class QualityPlugin(Plugin):
|
|||||||
quality = db.query(Quality).filter_by(identifier = q.get('identifier')).first()
|
quality = db.query(Quality).filter_by(identifier = q.get('identifier')).first()
|
||||||
|
|
||||||
if not quality:
|
if not quality:
|
||||||
log.info('Creating quality: %s' % q.get('label'))
|
log.info('Creating quality: %s', q.get('label'))
|
||||||
quality = Quality()
|
quality = Quality()
|
||||||
db.add(quality)
|
db.add(quality)
|
||||||
|
|
||||||
@@ -133,7 +133,7 @@ class QualityPlugin(Plugin):
|
|||||||
).all()
|
).all()
|
||||||
|
|
||||||
if not profile:
|
if not profile:
|
||||||
log.info('Creating profile: %s' % q.get('label'))
|
log.info('Creating profile: %s', q.get('label'))
|
||||||
profile = Profile(
|
profile = Profile(
|
||||||
core = True,
|
core = True,
|
||||||
label = toUnicode(quality.label),
|
label = toUnicode(quality.label),
|
||||||
@@ -170,20 +170,20 @@ class QualityPlugin(Plugin):
|
|||||||
|
|
||||||
# Check tags
|
# Check tags
|
||||||
if quality['identifier'] in words:
|
if quality['identifier'] in words:
|
||||||
log.debug('Found via identifier "%s" in %s' % (quality['identifier'], cur_file))
|
log.debug('Found via identifier "%s" in %s', (quality['identifier'], cur_file))
|
||||||
return self.setCache(hash, quality)
|
return self.setCache(hash, quality)
|
||||||
|
|
||||||
if list(set(quality.get('alternative', [])) & set(words)):
|
if list(set(quality.get('alternative', [])) & set(words)):
|
||||||
log.debug('Found %s via alt %s in %s' % (quality['identifier'], quality.get('alternative'), cur_file))
|
log.debug('Found %s via alt %s in %s', (quality['identifier'], quality.get('alternative'), cur_file))
|
||||||
return self.setCache(hash, quality)
|
return self.setCache(hash, quality)
|
||||||
|
|
||||||
for tag in quality.get('tags', []):
|
for tag in quality.get('tags', []):
|
||||||
if isinstance(tag, tuple) and '.'.join(tag) in '.'.join(words):
|
if isinstance(tag, tuple) and '.'.join(tag) in '.'.join(words):
|
||||||
log.debug('Found %s via tag %s in %s' % (quality['identifier'], quality.get('tags'), cur_file))
|
log.debug('Found %s via tag %s in %s', (quality['identifier'], quality.get('tags'), cur_file))
|
||||||
return self.setCache(hash, quality)
|
return self.setCache(hash, quality)
|
||||||
|
|
||||||
if list(set(quality.get('tags', [])) & set(words)):
|
if list(set(quality.get('tags', [])) & set(words)):
|
||||||
log.debug('Found %s via tag %s in %s' % (quality['identifier'], quality.get('tags'), cur_file))
|
log.debug('Found %s via tag %s in %s', (quality['identifier'], quality.get('tags'), cur_file))
|
||||||
return self.setCache(hash, quality)
|
return self.setCache(hash, quality)
|
||||||
|
|
||||||
# Try again with loose testing
|
# Try again with loose testing
|
||||||
@@ -191,7 +191,7 @@ class QualityPlugin(Plugin):
|
|||||||
if quality:
|
if quality:
|
||||||
return self.setCache(hash, quality)
|
return self.setCache(hash, quality)
|
||||||
|
|
||||||
log.debug('Could not identify quality for: %s' % files)
|
log.debug('Could not identify quality for: %s', files)
|
||||||
return None
|
return None
|
||||||
|
|
||||||
def guessLoose(self, hash, extra):
|
def guessLoose(self, hash, extra):
|
||||||
@@ -200,7 +200,7 @@ class QualityPlugin(Plugin):
|
|||||||
|
|
||||||
# Last check on resolution only
|
# Last check on resolution only
|
||||||
if quality.get('width', 480) == extra.get('resolution_width', 0):
|
if quality.get('width', 480) == extra.get('resolution_width', 0):
|
||||||
log.debug('Found %s via resolution_width: %s == %s' % (quality['identifier'], quality.get('width', 480), extra.get('resolution_width', 0)))
|
log.debug('Found %s via resolution_width: %s == %s', (quality['identifier'], quality.get('width', 480), extra.get('resolution_width', 0)))
|
||||||
return self.setCache(hash, quality)
|
return self.setCache(hash, quality)
|
||||||
|
|
||||||
if 480 <= extra.get('resolution_width', 0) <= 720:
|
if 480 <= extra.get('resolution_width', 0) <= 720:
|
||||||
|
|||||||
@@ -79,7 +79,7 @@ class Release(Plugin):
|
|||||||
rel.files.append(added_file)
|
rel.files.append(added_file)
|
||||||
db.commit()
|
db.commit()
|
||||||
except Exception, e:
|
except Exception, e:
|
||||||
log.debug('Failed to attach "%s" to release: %s' % (cur_file, e))
|
log.debug('Failed to attach "%s" to release: %s', (cur_file, e))
|
||||||
|
|
||||||
fireEvent('movie.restatus', movie.id)
|
fireEvent('movie.restatus', movie.id)
|
||||||
|
|
||||||
@@ -158,7 +158,7 @@ class Release(Plugin):
|
|||||||
'success': True
|
'success': True
|
||||||
})
|
})
|
||||||
else:
|
else:
|
||||||
log.error('Couldn\'t find release with id: %s' % id)
|
log.error('Couldn\'t find release with id: %s', id)
|
||||||
|
|
||||||
#db.close()
|
#db.close()
|
||||||
return jsonified({
|
return jsonified({
|
||||||
|
|||||||
@@ -100,7 +100,7 @@ class Renamer(Plugin):
|
|||||||
else:
|
else:
|
||||||
group['library'] = fireEvent('library.update', identifier = group['library']['identifier'], single = True)
|
group['library'] = fireEvent('library.update', identifier = group['library']['identifier'], single = True)
|
||||||
if not group['library']:
|
if not group['library']:
|
||||||
log.error('Could not rename, no library item to work with: %s' % group_identifier)
|
log.error('Could not rename, no library item to work with: %s', group_identifier)
|
||||||
continue
|
continue
|
||||||
|
|
||||||
library = group['library']
|
library = group['library']
|
||||||
@@ -138,7 +138,7 @@ class Renamer(Plugin):
|
|||||||
|
|
||||||
# Move nfo depending on settings
|
# Move nfo depending on settings
|
||||||
if file_type is 'nfo' and not self.conf('rename_nfo'):
|
if file_type is 'nfo' and not self.conf('rename_nfo'):
|
||||||
log.debug('Skipping, renaming of %s disabled' % file_type)
|
log.debug('Skipping, renaming of %s disabled', file_type)
|
||||||
if self.conf('cleanup'):
|
if self.conf('cleanup'):
|
||||||
for current_file in group['files'][file_type]:
|
for current_file in group['files'][file_type]:
|
||||||
remove_files.append(current_file)
|
remove_files.append(current_file)
|
||||||
@@ -197,7 +197,7 @@ class Renamer(Plugin):
|
|||||||
break
|
break
|
||||||
|
|
||||||
if not found:
|
if not found:
|
||||||
log.error('Could not determine dvd structure for: %s' % current_file)
|
log.error('Could not determine dvd structure for: %s', current_file)
|
||||||
|
|
||||||
# Do rename others
|
# Do rename others
|
||||||
else:
|
else:
|
||||||
@@ -272,7 +272,7 @@ class Renamer(Plugin):
|
|||||||
movie.status_id = done_status.get('id')
|
movie.status_id = done_status.get('id')
|
||||||
db.commit()
|
db.commit()
|
||||||
except Exception, e:
|
except Exception, e:
|
||||||
log.error('Failed marking movie finished: %s %s' % (e, traceback.format_exc()))
|
log.error('Failed marking movie finished: %s %s', (e, traceback.format_exc()))
|
||||||
|
|
||||||
# Go over current movie releases
|
# Go over current movie releases
|
||||||
for release in movie.releases:
|
for release in movie.releases:
|
||||||
@@ -282,20 +282,20 @@ class Renamer(Plugin):
|
|||||||
|
|
||||||
# This is where CP removes older, lesser quality releases
|
# This is where CP removes older, lesser quality releases
|
||||||
if release.quality.order > group['meta_data']['quality']['order']:
|
if release.quality.order > group['meta_data']['quality']['order']:
|
||||||
log.info('Removing lesser quality %s for %s.' % (movie.library.titles[0].title, release.quality.label))
|
log.info('Removing lesser quality %s for %s.', (movie.library.titles[0].title, release.quality.label))
|
||||||
for current_file in release.files:
|
for current_file in release.files:
|
||||||
remove_files.append(current_file)
|
remove_files.append(current_file)
|
||||||
remove_releases.append(release)
|
remove_releases.append(release)
|
||||||
# Same quality, but still downloaded, so maybe repack/proper/unrated/directors cut etc
|
# Same quality, but still downloaded, so maybe repack/proper/unrated/directors cut etc
|
||||||
elif release.quality.order is group['meta_data']['quality']['order']:
|
elif release.quality.order is group['meta_data']['quality']['order']:
|
||||||
log.info('Same quality release already exists for %s, with quality %s. Assuming repack.' % (movie.library.titles[0].title, release.quality.label))
|
log.info('Same quality release already exists for %s, with quality %s. Assuming repack.', (movie.library.titles[0].title, release.quality.label))
|
||||||
for current_file in release.files:
|
for current_file in release.files:
|
||||||
remove_files.append(current_file)
|
remove_files.append(current_file)
|
||||||
remove_releases.append(release)
|
remove_releases.append(release)
|
||||||
|
|
||||||
# Downloaded a lower quality, rename the newly downloaded files/folder to exclude them from scan
|
# Downloaded a lower quality, rename the newly downloaded files/folder to exclude them from scan
|
||||||
else:
|
else:
|
||||||
log.info('Better quality release already exists for %s, with quality %s' % (movie.library.titles[0].title, release.quality.label))
|
log.info('Better quality release already exists for %s, with quality %s', (movie.library.titles[0].title, release.quality.label))
|
||||||
|
|
||||||
# Add _EXISTS_ to the parent dir
|
# Add _EXISTS_ to the parent dir
|
||||||
if group['dirname']:
|
if group['dirname']:
|
||||||
@@ -333,18 +333,18 @@ class Renamer(Plugin):
|
|||||||
if isinstance(src, File):
|
if isinstance(src, File):
|
||||||
src = src.path
|
src = src.path
|
||||||
|
|
||||||
log.info('Removing "%s"' % src)
|
log.info('Removing "%s"', src)
|
||||||
try:
|
try:
|
||||||
os.remove(src)
|
os.remove(src)
|
||||||
except:
|
except:
|
||||||
log.error('Failed removing %s: %s' % (src, traceback.format_exc()))
|
log.error('Failed removing %s: %s', (src, traceback.format_exc()))
|
||||||
|
|
||||||
# Rename all files marked
|
# Rename all files marked
|
||||||
group['renamed_files'] = []
|
group['renamed_files'] = []
|
||||||
for src in rename_files:
|
for src in rename_files:
|
||||||
if rename_files[src]:
|
if rename_files[src]:
|
||||||
dst = rename_files[src]
|
dst = rename_files[src]
|
||||||
log.info('Renaming "%s" to "%s"' % (src, dst))
|
log.info('Renaming "%s" to "%s"', (src, dst))
|
||||||
|
|
||||||
# Create dir
|
# Create dir
|
||||||
self.makeDir(os.path.dirname(dst))
|
self.makeDir(os.path.dirname(dst))
|
||||||
@@ -353,22 +353,22 @@ class Renamer(Plugin):
|
|||||||
self.moveFile(src, dst)
|
self.moveFile(src, dst)
|
||||||
group['renamed_files'].append(dst)
|
group['renamed_files'].append(dst)
|
||||||
except:
|
except:
|
||||||
log.error('Failed moving the file "%s" : %s' % (os.path.basename(src), traceback.format_exc()))
|
log.error('Failed moving the file "%s" : %s', (os.path.basename(src), traceback.format_exc()))
|
||||||
|
|
||||||
# Remove matching releases
|
# Remove matching releases
|
||||||
for release in remove_releases:
|
for release in remove_releases:
|
||||||
log.debug('Removing release %s' % release.identifier)
|
log.debug('Removing release %s', release.identifier)
|
||||||
try:
|
try:
|
||||||
db.delete(release)
|
db.delete(release)
|
||||||
except:
|
except:
|
||||||
log.error('Failed removing %s: %s' % (release.identifier, traceback.format_exc()))
|
log.error('Failed removing %s: %s', (release.identifier, traceback.format_exc()))
|
||||||
|
|
||||||
if group['dirname'] and group['parentdir']:
|
if group['dirname'] and group['parentdir']:
|
||||||
try:
|
try:
|
||||||
log.info('Deleting folder: %s' % group['parentdir'])
|
log.info('Deleting folder: %s', group['parentdir'])
|
||||||
self.deleteEmptyFolder(group['parentdir'])
|
self.deleteEmptyFolder(group['parentdir'])
|
||||||
except:
|
except:
|
||||||
log.error('Failed removing %s: %s' % (group['parentdir'], traceback.format_exc()))
|
log.error('Failed removing %s: %s', (group['parentdir'], traceback.format_exc()))
|
||||||
|
|
||||||
if not unknown:
|
if not unknown:
|
||||||
# Search for trailers etc
|
# Search for trailers etc
|
||||||
@@ -408,10 +408,10 @@ class Renamer(Plugin):
|
|||||||
try:
|
try:
|
||||||
os.chmod(dest, Env.getPermission('file'))
|
os.chmod(dest, Env.getPermission('file'))
|
||||||
except:
|
except:
|
||||||
log.error('Failed setting permissions for file: %s' % dest)
|
log.error('Failed setting permissions for file: %s', dest)
|
||||||
|
|
||||||
except:
|
except:
|
||||||
log.error("Couldn't move file '%s' to '%s': %s" % (old, dest, traceback.format_exc()))
|
log.error('Couldn\'t move file "%s" to "%s": %s', (old, dest, traceback.format_exc()))
|
||||||
raise Exception
|
raise Exception
|
||||||
|
|
||||||
return True
|
return True
|
||||||
@@ -447,9 +447,9 @@ class Renamer(Plugin):
|
|||||||
try:
|
try:
|
||||||
os.rmdir(full_path)
|
os.rmdir(full_path)
|
||||||
except:
|
except:
|
||||||
log.error('Couldn\'t remove empty directory %s: %s' % (full_path, traceback.format_exc()))
|
log.error('Couldn\'t remove empty directory %s: %s', (full_path, traceback.format_exc()))
|
||||||
|
|
||||||
try:
|
try:
|
||||||
os.rmdir(folder)
|
os.rmdir(folder)
|
||||||
except:
|
except:
|
||||||
log.error('Couldn\'t remove empty directory %s: %s' % (folder, traceback.format_exc()))
|
log.error('Couldn\'t remove empty directory %s: %s', (folder, traceback.format_exc()))
|
||||||
|
|||||||
@@ -136,7 +136,7 @@ class Scanner(Plugin):
|
|||||||
folder = os.path.normpath(folder)
|
folder = os.path.normpath(folder)
|
||||||
|
|
||||||
if not folder or not os.path.isdir(folder):
|
if not folder or not os.path.isdir(folder):
|
||||||
log.error('Folder doesn\'t exists: %s' % folder)
|
log.error('Folder doesn\'t exists: %s', folder)
|
||||||
return {}
|
return {}
|
||||||
|
|
||||||
# Get movie "master" files
|
# Get movie "master" files
|
||||||
@@ -154,12 +154,12 @@ class Scanner(Plugin):
|
|||||||
try:
|
try:
|
||||||
files = []
|
files = []
|
||||||
folder = toUnicode(folder).encode(Env.get('encoding'))
|
folder = toUnicode(folder).encode(Env.get('encoding'))
|
||||||
log.info('Trying to convert unicode to str path: %s, %s' % (folder, type(folder)))
|
log.info('Trying to convert unicode to str path: %s, %s', (folder, type(folder)))
|
||||||
for root, dirs, walk_files in os.walk(folder):
|
for root, dirs, walk_files in os.walk(folder):
|
||||||
for filename in walk_files:
|
for filename in walk_files:
|
||||||
files.append(os.path.join(root, filename))
|
files.append(os.path.join(root, filename))
|
||||||
except:
|
except:
|
||||||
log.error('Failed getting files from %s: %s' % (folder, traceback.format_exc()))
|
log.error('Failed getting files from %s: %s', (folder, traceback.format_exc()))
|
||||||
|
|
||||||
db = get_session()
|
db = get_session()
|
||||||
|
|
||||||
@@ -215,7 +215,7 @@ class Scanner(Plugin):
|
|||||||
for identifier, group in movie_files.iteritems():
|
for identifier, group in movie_files.iteritems():
|
||||||
if identifier not in group['identifiers'] and len(identifier) > 0: group['identifiers'].append(identifier)
|
if identifier not in group['identifiers'] and len(identifier) > 0: group['identifiers'].append(identifier)
|
||||||
|
|
||||||
log.debug('Grouping files: %s' % identifier)
|
log.debug('Grouping files: %s', identifier)
|
||||||
|
|
||||||
for file_path in group['unsorted_files']:
|
for file_path in group['unsorted_files']:
|
||||||
wo_ext = file_path[:-(len(getExt(file_path)) + 1)]
|
wo_ext = file_path[:-(len(getExt(file_path)) + 1)]
|
||||||
@@ -241,7 +241,7 @@ class Scanner(Plugin):
|
|||||||
# Group the files based on the identifier
|
# Group the files based on the identifier
|
||||||
delete_identifiers = []
|
delete_identifiers = []
|
||||||
for identifier, found_files in self.path_identifiers.iteritems():
|
for identifier, found_files in self.path_identifiers.iteritems():
|
||||||
log.debug('Grouping files on identifier: %s' % identifier)
|
log.debug('Grouping files on identifier: %s', identifier)
|
||||||
|
|
||||||
group = movie_files.get(identifier)
|
group = movie_files.get(identifier)
|
||||||
if group:
|
if group:
|
||||||
@@ -264,7 +264,7 @@ class Scanner(Plugin):
|
|||||||
# Group based on folder
|
# Group based on folder
|
||||||
delete_identifiers = []
|
delete_identifiers = []
|
||||||
for identifier, found_files in self.path_identifiers.iteritems():
|
for identifier, found_files in self.path_identifiers.iteritems():
|
||||||
log.debug('Grouping files on foldername: %s' % identifier)
|
log.debug('Grouping files on foldername: %s', identifier)
|
||||||
|
|
||||||
for ff in found_files:
|
for ff in found_files:
|
||||||
new_identifier = self.createStringIdentifier(os.path.dirname(ff), folder)
|
new_identifier = self.createStringIdentifier(os.path.dirname(ff), folder)
|
||||||
@@ -308,7 +308,7 @@ class Scanner(Plugin):
|
|||||||
break
|
break
|
||||||
|
|
||||||
if file_too_new:
|
if file_too_new:
|
||||||
log.info('Files seem to be still unpacking or just unpacked (created on %s), ignoring for now: %s' % (time.ctime(file_time[0]), identifier))
|
log.info('Files seem to be still unpacking or just unpacked (created on %s), ignoring for now: %s', (time.ctime(file_time[0]), identifier))
|
||||||
|
|
||||||
# Delete the unsorted list
|
# Delete the unsorted list
|
||||||
del group['unsorted_files']
|
del group['unsorted_files']
|
||||||
@@ -322,7 +322,7 @@ class Scanner(Plugin):
|
|||||||
if file_time[0] > time.time() or file_time[1] > time.time():
|
if file_time[0] > time.time() or file_time[1] > time.time():
|
||||||
break
|
break
|
||||||
|
|
||||||
log.debug('None of the files have changed since %s for %s, skipping.' % (time.ctime(newer_than), identifier))
|
log.debug('None of the files have changed since %s for %s, skipping.', (time.ctime(newer_than), identifier))
|
||||||
|
|
||||||
# Delete the unsorted list
|
# Delete the unsorted list
|
||||||
del group['unsorted_files']
|
del group['unsorted_files']
|
||||||
@@ -348,10 +348,10 @@ class Scanner(Plugin):
|
|||||||
group['files']['movie'] = self.getMediaFiles(group['unsorted_files'])
|
group['files']['movie'] = self.getMediaFiles(group['unsorted_files'])
|
||||||
|
|
||||||
if len(group['files']['movie']) == 0:
|
if len(group['files']['movie']) == 0:
|
||||||
log.error('Couldn\t find any movie files for %s' % identifier)
|
log.error('Couldn\t find any movie files for %s', identifier)
|
||||||
continue
|
continue
|
||||||
|
|
||||||
log.debug('Getting metadata for %s' % identifier)
|
log.debug('Getting metadata for %s', identifier)
|
||||||
group['meta_data'] = self.getMetaData(group)
|
group['meta_data'] = self.getMetaData(group)
|
||||||
|
|
||||||
# Subtitle meta
|
# Subtitle meta
|
||||||
@@ -384,7 +384,7 @@ class Scanner(Plugin):
|
|||||||
# Determine movie
|
# Determine movie
|
||||||
group['library'] = self.determineMovie(group)
|
group['library'] = self.determineMovie(group)
|
||||||
if not group['library']:
|
if not group['library']:
|
||||||
log.error('Unable to determine movie: %s' % group['identifiers'])
|
log.error('Unable to determine movie: %s', group['identifiers'])
|
||||||
else:
|
else:
|
||||||
movie = db.query(Movie).filter_by(library_id = group['library']['id']).first()
|
movie = db.query(Movie).filter_by(library_id = group['library']['id']).first()
|
||||||
group['movie_id'] = None if not movie else movie.id
|
group['movie_id'] = None if not movie else movie.id
|
||||||
@@ -397,9 +397,9 @@ class Scanner(Plugin):
|
|||||||
self.path_identifiers = {}
|
self.path_identifiers = {}
|
||||||
|
|
||||||
if len(processed_movies) > 0:
|
if len(processed_movies) > 0:
|
||||||
log.info('Found %s movies in the folder %s' % (len(processed_movies), folder))
|
log.info('Found %s movies in the folder %s', (len(processed_movies), folder))
|
||||||
else:
|
else:
|
||||||
log.debug('Found no movies in the folder %s' % (folder))
|
log.debug('Found no movies in the folder %s', (folder))
|
||||||
return processed_movies
|
return processed_movies
|
||||||
|
|
||||||
def getMetaData(self, group):
|
def getMetaData(self, group):
|
||||||
@@ -419,7 +419,7 @@ class Scanner(Plugin):
|
|||||||
data['resolution_height'] = meta.get('resolution_height', 480)
|
data['resolution_height'] = meta.get('resolution_height', 480)
|
||||||
data['aspect'] = meta.get('resolution_width', 720) / meta.get('resolution_height', 480)
|
data['aspect'] = meta.get('resolution_width', 720) / meta.get('resolution_height', 480)
|
||||||
except:
|
except:
|
||||||
log.debug('Error parsing metadata: %s %s' % (cur_file, traceback.format_exc()))
|
log.debug('Error parsing metadata: %s %s', (cur_file, traceback.format_exc()))
|
||||||
pass
|
pass
|
||||||
|
|
||||||
if data.get('audio'): break
|
if data.get('audio'): break
|
||||||
@@ -447,11 +447,11 @@ class Scanner(Plugin):
|
|||||||
'resolution_height': tryInt(p.video[0].height),
|
'resolution_height': tryInt(p.video[0].height),
|
||||||
}
|
}
|
||||||
except ParseError:
|
except ParseError:
|
||||||
log.debug('Failed to parse meta for %s' % filename)
|
log.debug('Failed to parse meta for %s', filename)
|
||||||
except NoParserError:
|
except NoParserError:
|
||||||
log.debug('No parser found for %s' % filename)
|
log.debug('No parser found for %s', filename)
|
||||||
except:
|
except:
|
||||||
log.debug('Failed parsing %s' % filename)
|
log.debug('Failed parsing %s', filename)
|
||||||
|
|
||||||
return {}
|
return {}
|
||||||
|
|
||||||
@@ -473,7 +473,7 @@ class Scanner(Plugin):
|
|||||||
if s.language and s.path not in paths:
|
if s.language and s.path not in paths:
|
||||||
detected_languages[s.path] = [s.language]
|
detected_languages[s.path] = [s.language]
|
||||||
except:
|
except:
|
||||||
log.debug('Failed parsing subtitle languages for %s: %s' % (paths, traceback.format_exc()))
|
log.debug('Failed parsing subtitle languages for %s: %s', (paths, traceback.format_exc()))
|
||||||
|
|
||||||
# IDX
|
# IDX
|
||||||
for extra in group['files']['subtitle_extra']:
|
for extra in group['files']['subtitle_extra']:
|
||||||
@@ -489,7 +489,7 @@ class Scanner(Plugin):
|
|||||||
if len(idx_langs) > 0 and os.path.isfile(sub_file):
|
if len(idx_langs) > 0 and os.path.isfile(sub_file):
|
||||||
detected_languages[sub_file] = idx_langs
|
detected_languages[sub_file] = idx_langs
|
||||||
except:
|
except:
|
||||||
log.error('Failed parsing subtitle idx for %s: %s' % (extra, traceback.format_exc()))
|
log.error('Failed parsing subtitle idx for %s: %s', (extra, traceback.format_exc()))
|
||||||
|
|
||||||
return detected_languages
|
return detected_languages
|
||||||
|
|
||||||
@@ -502,7 +502,7 @@ class Scanner(Plugin):
|
|||||||
for cur_file in files['movie']:
|
for cur_file in files['movie']:
|
||||||
imdb_id = self.getCPImdb(cur_file)
|
imdb_id = self.getCPImdb(cur_file)
|
||||||
if imdb_id:
|
if imdb_id:
|
||||||
log.debug('Found movie via CP tag: %s' % cur_file)
|
log.debug('Found movie via CP tag: %s', cur_file)
|
||||||
break
|
break
|
||||||
|
|
||||||
# Check and see if nfo contains the imdb-id
|
# Check and see if nfo contains the imdb-id
|
||||||
@@ -511,7 +511,7 @@ class Scanner(Plugin):
|
|||||||
for nfo_file in files['nfo']:
|
for nfo_file in files['nfo']:
|
||||||
imdb_id = getImdb(nfo_file)
|
imdb_id = getImdb(nfo_file)
|
||||||
if imdb_id:
|
if imdb_id:
|
||||||
log.debug('Found movie via nfo file: %s' % nfo_file)
|
log.debug('Found movie via nfo file: %s', nfo_file)
|
||||||
break
|
break
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
@@ -523,7 +523,7 @@ class Scanner(Plugin):
|
|||||||
for filetype_file in files[filetype]:
|
for filetype_file in files[filetype]:
|
||||||
imdb_id = getImdb(filetype_file, check_inside = False)
|
imdb_id = getImdb(filetype_file, check_inside = False)
|
||||||
if imdb_id:
|
if imdb_id:
|
||||||
log.debug('Found movie via imdb in filename: %s' % nfo_file)
|
log.debug('Found movie via imdb in filename: %s', nfo_file)
|
||||||
break
|
break
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
@@ -535,7 +535,7 @@ class Scanner(Plugin):
|
|||||||
f = db.query(File).filter_by(path = toUnicode(cur_file)).first()
|
f = db.query(File).filter_by(path = toUnicode(cur_file)).first()
|
||||||
try:
|
try:
|
||||||
imdb_id = f.library[0].identifier
|
imdb_id = f.library[0].identifier
|
||||||
log.debug('Found movie via database: %s' % cur_file)
|
log.debug('Found movie via database: %s', cur_file)
|
||||||
break
|
break
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
@@ -549,7 +549,7 @@ class Scanner(Plugin):
|
|||||||
if len(movie) > 0:
|
if len(movie) > 0:
|
||||||
imdb_id = movie[0]['imdb']
|
imdb_id = movie[0]['imdb']
|
||||||
if imdb_id:
|
if imdb_id:
|
||||||
log.debug('Found movie via OpenSubtitleHash: %s' % cur_file)
|
log.debug('Found movie via OpenSubtitleHash: %s', cur_file)
|
||||||
break
|
break
|
||||||
|
|
||||||
# Search based on identifiers
|
# Search based on identifiers
|
||||||
@@ -566,17 +566,17 @@ class Scanner(Plugin):
|
|||||||
|
|
||||||
if len(movie) > 0:
|
if len(movie) > 0:
|
||||||
imdb_id = movie[0]['imdb']
|
imdb_id = movie[0]['imdb']
|
||||||
log.debug('Found movie via search: %s' % cur_file)
|
log.debug('Found movie via search: %s', cur_file)
|
||||||
if imdb_id: break
|
if imdb_id: break
|
||||||
else:
|
else:
|
||||||
log.debug('Identifier to short to use for search: %s' % identifier)
|
log.debug('Identifier to short to use for search: %s', identifier)
|
||||||
|
|
||||||
if imdb_id:
|
if imdb_id:
|
||||||
return fireEvent('library.add', attrs = {
|
return fireEvent('library.add', attrs = {
|
||||||
'identifier': imdb_id
|
'identifier': imdb_id
|
||||||
}, update_after = False, single = True)
|
}, update_after = False, single = True)
|
||||||
|
|
||||||
log.error('No imdb_id found for %s. Add a NFO file with IMDB id or add the year to the filename.' % group['identifiers'])
|
log.error('No imdb_id found for %s. Add a NFO file with IMDB id or add the year to the filename.', group['identifiers'])
|
||||||
return {}
|
return {}
|
||||||
|
|
||||||
def getCPImdb(self, string):
|
def getCPImdb(self, string):
|
||||||
@@ -665,17 +665,17 @@ class Scanner(Plugin):
|
|||||||
# ignoredpaths
|
# ignoredpaths
|
||||||
for i in self.ignored_in_path:
|
for i in self.ignored_in_path:
|
||||||
if i in filename.lower():
|
if i in filename.lower():
|
||||||
log.debug('Ignored "%s" contains "%s".' % (filename, i))
|
log.debug('Ignored "%s" contains "%s".', (filename, i))
|
||||||
return False
|
return False
|
||||||
|
|
||||||
# Sample file
|
# Sample file
|
||||||
if self.isSampleFile(filename):
|
if self.isSampleFile(filename):
|
||||||
log.debug('Is sample file "%s".' % filename)
|
log.debug('Is sample file "%s".', filename)
|
||||||
return False
|
return False
|
||||||
|
|
||||||
# Minimal size
|
# Minimal size
|
||||||
if self.filesizeBetween(filename, self.minimal_filesize['media']):
|
if self.filesizeBetween(filename, self.minimal_filesize['media']):
|
||||||
log.debug('File to small: %s' % filename)
|
log.debug('File to small: %s', filename)
|
||||||
return False
|
return False
|
||||||
|
|
||||||
# All is OK
|
# All is OK
|
||||||
@@ -683,14 +683,14 @@ class Scanner(Plugin):
|
|||||||
|
|
||||||
def isSampleFile(self, filename):
|
def isSampleFile(self, filename):
|
||||||
is_sample = 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)
|
if is_sample: log.debug('Is sample file: %s', filename)
|
||||||
return is_sample
|
return is_sample
|
||||||
|
|
||||||
def filesizeBetween(self, file, min = 0, max = 100000):
|
def filesizeBetween(self, file, min = 0, max = 100000):
|
||||||
try:
|
try:
|
||||||
return (min * 1048576) < os.path.getsize(file) < (max * 1048576)
|
return (min * 1048576) < os.path.getsize(file) < (max * 1048576)
|
||||||
except:
|
except:
|
||||||
log.error('Couldn\'t get filesize of %s.' % file)
|
log.error('Couldn\'t get filesize of %s.', file)
|
||||||
|
|
||||||
return False
|
return False
|
||||||
|
|
||||||
@@ -793,7 +793,7 @@ class Scanner(Plugin):
|
|||||||
'year': guess.get('year'),
|
'year': guess.get('year'),
|
||||||
}
|
}
|
||||||
except:
|
except:
|
||||||
log.debug('Could not detect via guessit "%s": %s' % (file_name, traceback.format_exc()))
|
log.debug('Could not detect via guessit "%s": %s', (file_name, traceback.format_exc()))
|
||||||
|
|
||||||
# Backup to simple
|
# Backup to simple
|
||||||
cleaned = ' '.join(re.split('\W+', simplifyString(release_name)))
|
cleaned = ' '.join(re.split('\W+', simplifyString(release_name)))
|
||||||
|
|||||||
@@ -56,7 +56,7 @@ class Searcher(Plugin):
|
|||||||
except IndexError:
|
except IndexError:
|
||||||
fireEvent('library.update', movie_dict['library']['identifier'], force = True)
|
fireEvent('library.update', movie_dict['library']['identifier'], force = True)
|
||||||
except:
|
except:
|
||||||
log.error('Search failed for %s: %s' % (movie_dict['library']['identifier'], traceback.format_exc()))
|
log.error('Search failed for %s: %s', (movie_dict['library']['identifier'], traceback.format_exc()))
|
||||||
|
|
||||||
# Break if CP wants to shut down
|
# Break if CP wants to shut down
|
||||||
if self.shuttingDown():
|
if self.shuttingDown():
|
||||||
@@ -88,7 +88,7 @@ class Searcher(Plugin):
|
|||||||
ret = False
|
ret = False
|
||||||
for quality_type in movie['profile']['types']:
|
for quality_type in movie['profile']['types']:
|
||||||
if not self.couldBeReleased(quality_type['quality']['identifier'], release_dates, pre_releases):
|
if not self.couldBeReleased(quality_type['quality']['identifier'], release_dates, pre_releases):
|
||||||
log.info('To early to search for %s, %s' % (quality_type['quality']['identifier'], default_title))
|
log.info('To early to search for %s, %s', (quality_type['quality']['identifier'], default_title))
|
||||||
continue
|
continue
|
||||||
|
|
||||||
has_better_quality = 0
|
has_better_quality = 0
|
||||||
@@ -101,12 +101,12 @@ class Searcher(Plugin):
|
|||||||
# Don't search for quality lower then already available.
|
# Don't search for quality lower then already available.
|
||||||
if has_better_quality is 0:
|
if has_better_quality is 0:
|
||||||
|
|
||||||
log.info('Search for %s in %s' % (default_title, quality_type['quality']['label']))
|
log.info('Search for %s in %s', (default_title, quality_type['quality']['label']))
|
||||||
quality = fireEvent('quality.single', identifier = quality_type['quality']['identifier'], single = True)
|
quality = fireEvent('quality.single', identifier = quality_type['quality']['identifier'], single = True)
|
||||||
results = fireEvent('yarr.search', movie, quality, merge = True)
|
results = fireEvent('yarr.search', movie, quality, merge = True)
|
||||||
sorted_results = sorted(results, key = lambda k: k['score'], reverse = True)
|
sorted_results = sorted(results, key = lambda k: k['score'], reverse = True)
|
||||||
if len(sorted_results) == 0:
|
if len(sorted_results) == 0:
|
||||||
log.debug('Nothing found for %s in %s' % (default_title, quality_type['quality']['label']))
|
log.debug('Nothing found for %s in %s', (default_title, quality_type['quality']['label']))
|
||||||
|
|
||||||
# Check if movie isn't deleted while searching
|
# Check if movie isn't deleted while searching
|
||||||
if not db.query(Movie).filter_by(id = movie.get('id')).first():
|
if not db.query(Movie).filter_by(id = movie.get('id')).first():
|
||||||
@@ -141,7 +141,7 @@ class Searcher(Plugin):
|
|||||||
rls.info.append(rls_info)
|
rls.info.append(rls_info)
|
||||||
db.commit()
|
db.commit()
|
||||||
except InterfaceError:
|
except InterfaceError:
|
||||||
log.debug('Couldn\'t add %s to ReleaseInfo: %s' % (info, traceback.format_exc()))
|
log.debug('Couldn\'t add %s to ReleaseInfo: %s', (info, traceback.format_exc()))
|
||||||
|
|
||||||
|
|
||||||
for nzb in sorted_results:
|
for nzb in sorted_results:
|
||||||
@@ -152,7 +152,7 @@ class Searcher(Plugin):
|
|||||||
elif downloaded != 'try_next':
|
elif downloaded != 'try_next':
|
||||||
break
|
break
|
||||||
else:
|
else:
|
||||||
log.info('Better quality (%s) already available or snatched for %s' % (quality_type['quality']['label'], default_title))
|
log.info('Better quality (%s) already available or snatched for %s', (quality_type['quality']['label'], default_title))
|
||||||
fireEvent('movie.restatus', movie['id'])
|
fireEvent('movie.restatus', movie['id'])
|
||||||
break
|
break
|
||||||
|
|
||||||
@@ -200,7 +200,7 @@ class Searcher(Plugin):
|
|||||||
if movie['status_id'] == active_status.get('id'):
|
if movie['status_id'] == active_status.get('id'):
|
||||||
for profile_type in movie['profile']['types']:
|
for profile_type in movie['profile']['types']:
|
||||||
if profile_type['quality_id'] == rls.quality.id and profile_type['finish']:
|
if profile_type['quality_id'] == rls.quality.id and profile_type['finish']:
|
||||||
log.info('Renamer disabled, marking movie as finished: %s' % log_movie)
|
log.info('Renamer disabled, marking movie as finished: %s', log_movie)
|
||||||
|
|
||||||
# Mark release done
|
# Mark release done
|
||||||
rls.status_id = done_status.get('id')
|
rls.status_id = done_status.get('id')
|
||||||
@@ -211,7 +211,7 @@ class Searcher(Plugin):
|
|||||||
mvie.status_id = done_status.get('id')
|
mvie.status_id = done_status.get('id')
|
||||||
db.commit()
|
db.commit()
|
||||||
except Exception, e:
|
except Exception, e:
|
||||||
log.error('Failed marking movie finished: %s %s' % (e, traceback.format_exc()))
|
log.error('Failed marking movie finished: %s %s', (e, traceback.format_exc()))
|
||||||
|
|
||||||
#db.close()
|
#db.close()
|
||||||
return True
|
return True
|
||||||
@@ -226,7 +226,7 @@ class Searcher(Plugin):
|
|||||||
retention = Env.setting('retention', section = 'nzb')
|
retention = Env.setting('retention', section = 'nzb')
|
||||||
|
|
||||||
if nzb.get('seeds') is None and retention < nzb.get('age', 0):
|
if nzb.get('seeds') is None and retention < nzb.get('age', 0):
|
||||||
log.info('Wrong: Outside retention, age is %s, needs %s or lower: %s' % (nzb['age'], retention, nzb['name']))
|
log.info('Wrong: Outside retention, age is %s, needs %s or lower: %s', (nzb['age'], retention, nzb['name']))
|
||||||
return False
|
return False
|
||||||
|
|
||||||
movie_name = getTitle(movie['library'])
|
movie_name = getTitle(movie['library'])
|
||||||
@@ -248,7 +248,7 @@ class Searcher(Plugin):
|
|||||||
pron_tags = ['xxx', 'sex', 'anal', 'tits', 'fuck', 'porn', 'orgy', 'milf', 'boobs']
|
pron_tags = ['xxx', 'sex', 'anal', 'tits', 'fuck', 'porn', 'orgy', 'milf', 'boobs']
|
||||||
for p_tag in pron_tags:
|
for p_tag in pron_tags:
|
||||||
if p_tag in nzb_words and p_tag not in movie_words:
|
if p_tag in nzb_words and p_tag not in movie_words:
|
||||||
log.info('Wrong: %s, probably pr0n' % (nzb['name']))
|
log.info('Wrong: %s, probably pr0n', (nzb['name']))
|
||||||
return False
|
return False
|
||||||
|
|
||||||
#qualities = fireEvent('quality.all', single = True)
|
#qualities = fireEvent('quality.all', single = True)
|
||||||
@@ -256,18 +256,18 @@ class Searcher(Plugin):
|
|||||||
|
|
||||||
# Contains lower quality string
|
# Contains lower quality string
|
||||||
if self.containsOtherQuality(nzb, movie_year = movie['library']['year'], preferred_quality = preferred_quality, single_category = single_category):
|
if self.containsOtherQuality(nzb, movie_year = movie['library']['year'], preferred_quality = preferred_quality, single_category = single_category):
|
||||||
log.info('Wrong: %s, looking for %s' % (nzb['name'], quality['label']))
|
log.info('Wrong: %s, looking for %s', (nzb['name'], quality['label']))
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
|
||||||
# File to small
|
# File to small
|
||||||
if nzb['size'] and preferred_quality['size_min'] > nzb['size']:
|
if nzb['size'] and preferred_quality['size_min'] > nzb['size']:
|
||||||
log.info('"%s" is too small to be %s. %sMB instead of the minimal of %sMB.' % (nzb['name'], preferred_quality['label'], nzb['size'], preferred_quality['size_min']))
|
log.info('"%s" is too small to be %s. %sMB instead of the minimal of %sMB.', (nzb['name'], preferred_quality['label'], nzb['size'], preferred_quality['size_min']))
|
||||||
return False
|
return False
|
||||||
|
|
||||||
# File to large
|
# File to large
|
||||||
if nzb['size'] and preferred_quality.get('size_max') < nzb['size']:
|
if nzb['size'] and preferred_quality.get('size_max') < nzb['size']:
|
||||||
log.info('"%s" is too large to be %s. %sMB instead of the maximum of %sMB.' % (nzb['name'], preferred_quality['label'], nzb['size'], preferred_quality['size_max']))
|
log.info('"%s" is too large to be %s. %sMB instead of the maximum of %sMB.', (nzb['name'], preferred_quality['label'], nzb['size'], preferred_quality['size_max']))
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -92,7 +92,7 @@ class StatusPlugin(Plugin):
|
|||||||
for identifier, label in self.statuses.iteritems():
|
for identifier, label in self.statuses.iteritems():
|
||||||
s = db.query(Status).filter_by(identifier = identifier).first()
|
s = db.query(Status).filter_by(identifier = identifier).first()
|
||||||
if not s:
|
if not s:
|
||||||
log.info('Creating status: %s' % label)
|
log.info('Creating status: %s', label)
|
||||||
s = Status(
|
s = Status(
|
||||||
identifier = identifier,
|
identifier = identifier,
|
||||||
label = toUnicode(label)
|
label = toUnicode(label)
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ class Trailer(Plugin):
|
|||||||
|
|
||||||
trailers = fireEvent('trailer.search', group = group, merge = True)
|
trailers = fireEvent('trailer.search', group = group, merge = True)
|
||||||
if not trailers or trailers == []:
|
if not trailers or trailers == []:
|
||||||
log.info('No trailers found for: %s' % getTitle(group['library']))
|
log.info('No trailers found for: %s', getTitle(group['library']))
|
||||||
return
|
return
|
||||||
|
|
||||||
for trailer in trailers.get(self.conf('quality'), []):
|
for trailer in trailers.get(self.conf('quality'), []):
|
||||||
@@ -26,7 +26,7 @@ class Trailer(Plugin):
|
|||||||
if not os.path.isfile(destination):
|
if not os.path.isfile(destination):
|
||||||
fireEvent('file.download', url = trailer, dest = destination, urlopen_kwargs = {'headers': {'User-Agent': 'Quicktime'}}, single = True)
|
fireEvent('file.download', url = trailer, dest = destination, urlopen_kwargs = {'headers': {'User-Agent': 'Quicktime'}}, single = True)
|
||||||
else:
|
else:
|
||||||
log.debug('Trailer already exists: %s' % destination)
|
log.debug('Trailer already exists: %s', destination)
|
||||||
|
|
||||||
# Download first and break
|
# Download first and break
|
||||||
break
|
break
|
||||||
|
|||||||
@@ -73,7 +73,7 @@ class Userscript(Plugin):
|
|||||||
'movie': fireEvent('userscript.get_movie_via_url', url = url, single = True)
|
'movie': fireEvent('userscript.get_movie_via_url', url = url, single = True)
|
||||||
}
|
}
|
||||||
if not isDict(params['movie']):
|
if not isDict(params['movie']):
|
||||||
log.error('Failed adding movie via url: %s' % url)
|
log.error('Failed adding movie via url: %s', url)
|
||||||
params['error'] = params['movie'] if params['movie'] else 'Failed getting movie info'
|
params['error'] = params['movie'] if params['movie'] else 'Failed getting movie info'
|
||||||
|
|
||||||
return jsonified(params)
|
return jsonified(params)
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ class Automation(Plugin):
|
|||||||
def _getMovies(self):
|
def _getMovies(self):
|
||||||
|
|
||||||
if not self.canCheck():
|
if not self.canCheck():
|
||||||
log.debug('Just checked, skipping %s' % self.getName())
|
log.debug('Just checked, skipping %s', self.getName())
|
||||||
return []
|
return []
|
||||||
|
|
||||||
self.last_checked = time.time()
|
self.last_checked = time.time()
|
||||||
@@ -43,7 +43,7 @@ class Automation(Plugin):
|
|||||||
type_value = movie.get(minimal_type, 0)
|
type_value = movie.get(minimal_type, 0)
|
||||||
type_min = self.getMinimal(minimal_type)
|
type_min = self.getMinimal(minimal_type)
|
||||||
if type_value < type_min:
|
if type_value < type_min:
|
||||||
log.info('%s to low for %s, need %s has %s' % (minimal_type, identifier, type_min, type_value))
|
log.info('%s to low for %s, need %s has %s', (minimal_type, identifier, type_min, type_value))
|
||||||
return False
|
return False
|
||||||
|
|
||||||
return True
|
return True
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ class IMDB(Automation, RSS):
|
|||||||
if not enablers[index]:
|
if not enablers[index]:
|
||||||
continue
|
continue
|
||||||
elif 'rss.imdb' not in rss_url:
|
elif 'rss.imdb' not in rss_url:
|
||||||
log.error('This isn\'t the correct url.: %s' % rss_url)
|
log.error('This isn\'t the correct url.: %s', rss_url)
|
||||||
continue
|
continue
|
||||||
|
|
||||||
prop_name = 'automation.imdb.last_update.%s' % md5(rss_url)
|
prop_name = 'automation.imdb.last_update.%s' % md5(rss_url)
|
||||||
@@ -58,7 +58,7 @@ class IMDB(Automation, RSS):
|
|||||||
movies.append(imdb)
|
movies.append(imdb)
|
||||||
|
|
||||||
except:
|
except:
|
||||||
log.error('Failed loading IMDB watchlist: %s %s' % (rss_url, traceback.format_exc()))
|
log.error('Failed loading IMDB watchlist: %s %s', (rss_url, traceback.format_exc()))
|
||||||
|
|
||||||
Env.prop(prop_name, last_movie_added)
|
Env.prop(prop_name, last_movie_added)
|
||||||
|
|
||||||
|
|||||||
@@ -43,7 +43,7 @@ class Trakt(Automation):
|
|||||||
|
|
||||||
if self.conf('automation_password'):
|
if self.conf('automation_password'):
|
||||||
headers = {
|
headers = {
|
||||||
'Authorization': "Basic %s" % base64.encodestring('%s:%s' % (self.conf('automation_username'), self.conf('automation_password')))[:-1]
|
'Authorization': 'Basic %s' % base64.encodestring('%s:%s' % (self.conf('automation_username'), self.conf('automation_password')))[:-1]
|
||||||
}
|
}
|
||||||
else:
|
else:
|
||||||
headers = {}
|
headers = {}
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ class Provider(Plugin):
|
|||||||
self.urlopen(test_url, 30)
|
self.urlopen(test_url, 30)
|
||||||
self.is_available[host] = True
|
self.is_available[host] = True
|
||||||
except:
|
except:
|
||||||
log.error('"%s" unavailable, trying again in an 15 minutes.' % host)
|
log.error('"%s" unavailable, trying again in an 15 minutes.', host)
|
||||||
self.is_available[host] = False
|
self.is_available[host] = False
|
||||||
|
|
||||||
return self.is_available.get(host, False)
|
return self.is_available.get(host, False)
|
||||||
@@ -73,7 +73,7 @@ class YarrProvider(Provider):
|
|||||||
if hostname in download_url:
|
if hostname in download_url:
|
||||||
return self
|
return self
|
||||||
except:
|
except:
|
||||||
log.debug('Url % s doesn\'t belong to %s' % (url, self.getName()))
|
log.debug('Url % s doesn\'t belong to %s', (url, self.getName()))
|
||||||
|
|
||||||
return
|
return
|
||||||
|
|
||||||
@@ -106,4 +106,4 @@ class YarrProvider(Provider):
|
|||||||
return [self.cat_backup_id]
|
return [self.cat_backup_id]
|
||||||
|
|
||||||
def found(self, new):
|
def found(self, new):
|
||||||
log.info('Found: score(%(score)s) on %(provider)s: %(name)s' % new)
|
log.info('Found: score(%(score)s) on %(provider)s: %(name)s', new)
|
||||||
|
|||||||
@@ -19,14 +19,14 @@ class MetaDataBase(Plugin):
|
|||||||
def create(self, release):
|
def create(self, release):
|
||||||
if self.isDisabled(): return
|
if self.isDisabled(): return
|
||||||
|
|
||||||
log.info('Creating %s metadata.' % self.getName())
|
log.info('Creating %s metadata.', self.getName())
|
||||||
|
|
||||||
# Update library to get latest info
|
# Update library to get latest info
|
||||||
try:
|
try:
|
||||||
updated_library = fireEvent('library.update', release['library']['identifier'], force = True, single = True)
|
updated_library = fireEvent('library.update', release['library']['identifier'], force = True, single = True)
|
||||||
release['library'] = mergeDicts(release['library'], updated_library)
|
release['library'] = mergeDicts(release['library'], updated_library)
|
||||||
except:
|
except:
|
||||||
log.error('Failed to update movie, before creating metadata: %s' % traceback.format_exc())
|
log.error('Failed to update movie, before creating metadata: %s', traceback.format_exc())
|
||||||
|
|
||||||
root_name = self.getRootName(release)
|
root_name = self.getRootName(release)
|
||||||
meta_name = os.path.basename(root_name)
|
meta_name = os.path.basename(root_name)
|
||||||
@@ -44,14 +44,14 @@ class MetaDataBase(Plugin):
|
|||||||
# Get file content
|
# Get file content
|
||||||
content = getattr(self, 'get' + file_type.capitalize())(movie_info = movie_info, data = release)
|
content = getattr(self, 'get' + file_type.capitalize())(movie_info = movie_info, data = release)
|
||||||
if content:
|
if content:
|
||||||
log.debug('Creating %s file: %s' % (file_type, name))
|
log.debug('Creating %s file: %s', (file_type, name))
|
||||||
if os.path.isfile(content):
|
if os.path.isfile(content):
|
||||||
shutil.copy2(content, name)
|
shutil.copy2(content, name)
|
||||||
else:
|
else:
|
||||||
self.createFile(name, content)
|
self.createFile(name, content)
|
||||||
|
|
||||||
except:
|
except:
|
||||||
log.error('Unable to create %s file: %s' % (file_type, traceback.format_exc()))
|
log.error('Unable to create %s file: %s', (file_type, traceback.format_exc()))
|
||||||
|
|
||||||
def getRootName(self, data):
|
def getRootName(self, data):
|
||||||
return
|
return
|
||||||
|
|||||||
@@ -77,7 +77,7 @@ class XBMC(MetaDataBase):
|
|||||||
votes.text = str(v)
|
votes.text = str(v)
|
||||||
break
|
break
|
||||||
except:
|
except:
|
||||||
log.debug('Failed adding rating info from %s: %s' % (rating_type, traceback.format_exc()))
|
log.debug('Failed adding rating info from %s: %s', (rating_type, traceback.format_exc()))
|
||||||
|
|
||||||
# Genre
|
# Genre
|
||||||
for genre in movie_info.get('genres', []):
|
for genre in movie_info.get('genres', []):
|
||||||
|
|||||||
@@ -68,7 +68,7 @@ class MovieResultModifier(Plugin):
|
|||||||
if release.status_id == done_status['id']:
|
if release.status_id == done_status['id']:
|
||||||
temp['in_library'] = fireEvent('movie.get', movie.id, single = True)
|
temp['in_library'] = fireEvent('movie.get', movie.id, single = True)
|
||||||
except:
|
except:
|
||||||
log.error('Tried getting more info on searched movies: %s' % traceback.format_exc())
|
log.error('Tried getting more info on searched movies: %s', traceback.format_exc())
|
||||||
|
|
||||||
#db.close()
|
#db.close()
|
||||||
return temp
|
return temp
|
||||||
|
|||||||
@@ -32,10 +32,10 @@ class CouchPotatoApi(MovieProvider):
|
|||||||
headers = {'X-CP-Version': fireEvent('app.version', single = True)}
|
headers = {'X-CP-Version': fireEvent('app.version', single = True)}
|
||||||
data = self.urlopen((self.api_url % ('eta')) + (identifier + '/'), headers = headers)
|
data = self.urlopen((self.api_url % ('eta')) + (identifier + '/'), headers = headers)
|
||||||
dates = json.loads(data)
|
dates = json.loads(data)
|
||||||
log.debug('Found ETA for %s: %s' % (identifier, dates))
|
log.debug('Found ETA for %s: %s', (identifier, dates))
|
||||||
return dates
|
return dates
|
||||||
except Exception, e:
|
except Exception, e:
|
||||||
log.error('Error getting ETA for %s: %s' % (identifier, e))
|
log.error('Error getting ETA for %s: %s', (identifier, e))
|
||||||
|
|
||||||
return {}
|
return {}
|
||||||
|
|
||||||
@@ -43,9 +43,9 @@ class CouchPotatoApi(MovieProvider):
|
|||||||
try:
|
try:
|
||||||
data = self.urlopen((self.api_url % ('suggest')) + ','.join(movies) + '/' + ','.join(ignore) + '/')
|
data = self.urlopen((self.api_url % ('suggest')) + ','.join(movies) + '/' + ','.join(ignore) + '/')
|
||||||
suggestions = json.loads(data)
|
suggestions = json.loads(data)
|
||||||
log.info('Found Suggestions for %s' % (suggestions))
|
log.info('Found Suggestions for %s', (suggestions))
|
||||||
except Exception, e:
|
except Exception, e:
|
||||||
log.error('Error getting suggestions for %s: %s' % (movies, e))
|
log.error('Error getting suggestions for %s: %s', (movies, e))
|
||||||
|
|
||||||
return suggestions
|
return suggestions
|
||||||
|
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ class IMDBAPI(MovieProvider):
|
|||||||
if cached:
|
if cached:
|
||||||
result = self.parseMovie(cached)
|
result = self.parseMovie(cached)
|
||||||
if result.get('titles') and len(result.get('titles')) > 0:
|
if result.get('titles') and len(result.get('titles')) > 0:
|
||||||
log.info('Found: %s' % result['titles'][0] + ' (' + str(result['year']) + ')')
|
log.info('Found: %s', result['titles'][0] + ' (' + str(result['year']) + ')')
|
||||||
return [result]
|
return [result]
|
||||||
|
|
||||||
return []
|
return []
|
||||||
@@ -54,7 +54,7 @@ class IMDBAPI(MovieProvider):
|
|||||||
if cached:
|
if cached:
|
||||||
result = self.parseMovie(cached)
|
result = self.parseMovie(cached)
|
||||||
if result.get('titles') and len(result.get('titles')) > 0:
|
if result.get('titles') and len(result.get('titles')) > 0:
|
||||||
log.info('Found: %s' % result['titles'][0] + ' (' + str(result['year']) + ')')
|
log.info('Found: %s', result['titles'][0] + ' (' + str(result['year']) + ')')
|
||||||
return result
|
return result
|
||||||
|
|
||||||
return {}
|
return {}
|
||||||
@@ -103,7 +103,7 @@ class IMDBAPI(MovieProvider):
|
|||||||
'actors': movie.get('Actors', '').split(','),
|
'actors': movie.get('Actors', '').split(','),
|
||||||
}
|
}
|
||||||
except:
|
except:
|
||||||
log.error('Failed parsing IMDB API json: %s' % traceback.format_exc())
|
log.error('Failed parsing IMDB API json: %s', traceback.format_exc())
|
||||||
|
|
||||||
return movie_data
|
return movie_data
|
||||||
|
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ class TheMovieDb(MovieProvider):
|
|||||||
results = self.getCache(cache_key)
|
results = self.getCache(cache_key)
|
||||||
|
|
||||||
if not results:
|
if not results:
|
||||||
log.debug('Searching for movie by hash: %s' % file)
|
log.debug('Searching for movie by hash: %s', file)
|
||||||
try:
|
try:
|
||||||
raw = tmdb.searchByHashingFile(file)
|
raw = tmdb.searchByHashingFile(file)
|
||||||
|
|
||||||
@@ -36,15 +36,15 @@ class TheMovieDb(MovieProvider):
|
|||||||
if raw:
|
if raw:
|
||||||
try:
|
try:
|
||||||
results = self.parseMovie(raw)
|
results = self.parseMovie(raw)
|
||||||
log.info('Found: %s' % results['titles'][0] + ' (' + str(results['year']) + ')')
|
log.info('Found: %s', results['titles'][0] + ' (' + str(results['year']) + ')')
|
||||||
|
|
||||||
self.setCache(cache_key, results)
|
self.setCache(cache_key, results)
|
||||||
return results
|
return results
|
||||||
except SyntaxError, e:
|
except SyntaxError, e:
|
||||||
log.error('Failed to parse XML response: %s' % e)
|
log.error('Failed to parse XML response: %s', e)
|
||||||
return False
|
return False
|
||||||
except:
|
except:
|
||||||
log.debug('No movies known by hash for: %s' % file)
|
log.debug('No movies known by hash for: %s', file)
|
||||||
pass
|
pass
|
||||||
|
|
||||||
return results
|
return results
|
||||||
@@ -56,11 +56,11 @@ class TheMovieDb(MovieProvider):
|
|||||||
return False
|
return False
|
||||||
|
|
||||||
search_string = simplifyString(q)
|
search_string = simplifyString(q)
|
||||||
cache_key = 'tmdb.cache.%s.%s' % (search_string, limit)
|
cache_key = 'tmdb.cache.%s.%s', (search_string, limit)
|
||||||
results = self.getCache(cache_key)
|
results = self.getCache(cache_key)
|
||||||
|
|
||||||
if not results:
|
if not results:
|
||||||
log.debug('Searching for movie: %s' % q)
|
log.debug('Searching for movie: %s', q)
|
||||||
raw = tmdb.search(search_string)
|
raw = tmdb.search(search_string)
|
||||||
|
|
||||||
results = []
|
results = []
|
||||||
@@ -75,12 +75,12 @@ class TheMovieDb(MovieProvider):
|
|||||||
if nr == limit:
|
if nr == limit:
|
||||||
break
|
break
|
||||||
|
|
||||||
log.info('Found: %s' % [result['titles'][0] + ' (' + str(result['year']) + ')' for result in results])
|
log.info('Found: %s', [result['titles'][0] + ' (' + str(result['year']) + ')' for result in results])
|
||||||
|
|
||||||
self.setCache(cache_key, results)
|
self.setCache(cache_key, results)
|
||||||
return results
|
return results
|
||||||
except SyntaxError, e:
|
except SyntaxError, e:
|
||||||
log.error('Failed to parse XML response: %s' % e)
|
log.error('Failed to parse XML response: %s', e)
|
||||||
return False
|
return False
|
||||||
|
|
||||||
return results
|
return results
|
||||||
@@ -90,7 +90,7 @@ class TheMovieDb(MovieProvider):
|
|||||||
if not identifier:
|
if not identifier:
|
||||||
return {}
|
return {}
|
||||||
|
|
||||||
cache_key = 'tmdb.cache.%s' % identifier
|
cache_key = 'tmdb.cache.%s', identifier
|
||||||
result = self.getCache(cache_key)
|
result = self.getCache(cache_key)
|
||||||
|
|
||||||
if not result:
|
if not result:
|
||||||
@@ -98,7 +98,7 @@ class TheMovieDb(MovieProvider):
|
|||||||
movie = None
|
movie = None
|
||||||
|
|
||||||
try:
|
try:
|
||||||
log.debug('Getting info: %s' % cache_key)
|
log.debug('Getting info: %s', cache_key)
|
||||||
movie = tmdb.imdbLookup(id = identifier)
|
movie = tmdb.imdbLookup(id = identifier)
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
@@ -111,7 +111,7 @@ class TheMovieDb(MovieProvider):
|
|||||||
|
|
||||||
def getInfoByTMDBId(self, id = None):
|
def getInfoByTMDBId(self, id = None):
|
||||||
|
|
||||||
cache_key = 'tmdb.cache.%s' % id
|
cache_key = 'tmdb.cache.%s', id
|
||||||
result = self.getCache(cache_key)
|
result = self.getCache(cache_key)
|
||||||
|
|
||||||
if not result:
|
if not result:
|
||||||
@@ -119,7 +119,7 @@ class TheMovieDb(MovieProvider):
|
|||||||
movie = None
|
movie = None
|
||||||
|
|
||||||
try:
|
try:
|
||||||
log.debug('Getting info: %s' % cache_key)
|
log.debug('Getting info: %s', cache_key)
|
||||||
movie = tmdb.getMovieInfo(id = id)
|
movie = tmdb.getMovieInfo(id = id)
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
|
|||||||
@@ -82,7 +82,7 @@ class Newzbin(NZBProvider, RSS):
|
|||||||
data = XMLTree.fromstring(data)
|
data = XMLTree.fromstring(data)
|
||||||
nzbs = self.getElements(data, 'channel/item')
|
nzbs = self.getElements(data, 'channel/item')
|
||||||
except Exception, e:
|
except Exception, e:
|
||||||
log.debug('%s, %s' % (self.getName(), e))
|
log.debug('%s, %s', (self.getName(), e))
|
||||||
return results
|
return results
|
||||||
|
|
||||||
for nzb in nzbs:
|
for nzb in nzbs:
|
||||||
@@ -133,7 +133,7 @@ class Newzbin(NZBProvider, RSS):
|
|||||||
|
|
||||||
def download(self, url = '', nzb_id = ''):
|
def download(self, url = '', nzb_id = ''):
|
||||||
try:
|
try:
|
||||||
log.info('Download nzb from newzbin, report id: %s ' % nzb_id)
|
log.info('Download nzb from newzbin, report id: %s ', nzb_id)
|
||||||
|
|
||||||
return self.urlopen(self.urls['download'], params = {
|
return self.urlopen(self.urls['download'], params = {
|
||||||
'username' : self.conf('username'),
|
'username' : self.conf('username'),
|
||||||
@@ -141,7 +141,7 @@ class Newzbin(NZBProvider, RSS):
|
|||||||
'reportid' : nzb_id
|
'reportid' : nzb_id
|
||||||
}, show_error = False)
|
}, 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
|
||||||
|
|
||||||
def getFormatId(self, format):
|
def getFormatId(self, format):
|
||||||
|
|||||||
@@ -112,7 +112,7 @@ class Newznab(NZBProvider, RSS):
|
|||||||
data = XMLTree.fromstring(data)
|
data = XMLTree.fromstring(data)
|
||||||
nzbs = self.getElements(data, 'channel/item')
|
nzbs = self.getElements(data, 'channel/item')
|
||||||
except Exception, e:
|
except Exception, e:
|
||||||
log.debug('%s, %s' % (self.getName(), e))
|
log.debug('%s, %s', (self.getName(), e))
|
||||||
return results
|
return results
|
||||||
|
|
||||||
results = []
|
results = []
|
||||||
@@ -126,8 +126,8 @@ class Newznab(NZBProvider, RSS):
|
|||||||
elif item.attrib.get('name') == 'usenetdate':
|
elif item.attrib.get('name') == 'usenetdate':
|
||||||
date = item.attrib.get('value')
|
date = item.attrib.get('value')
|
||||||
|
|
||||||
if date is '': log.debug('Date not parsed properly or not available for %s: %s' % (host['host'], self.getTextElement(nzb, "title")))
|
if date is '': log.debug('Date not parsed properly or not available for %s: %s', (host['host'], self.getTextElement(nzb, "title")))
|
||||||
if size is 0: log.debug('Size not parsed properly or not available for %s: %s' % (host['host'], self.getTextElement(nzb, "title")))
|
if size is 0: log.debug('Size not parsed properly or not available for %s: %s', (host['host'], self.getTextElement(nzb, "title")))
|
||||||
|
|
||||||
id = self.getTextElement(nzb, "guid").split('/')[-1:].pop()
|
id = self.getTextElement(nzb, "guid").split('/')[-1:].pop()
|
||||||
new = {
|
new = {
|
||||||
@@ -157,7 +157,7 @@ class Newznab(NZBProvider, RSS):
|
|||||||
|
|
||||||
return results
|
return results
|
||||||
except SyntaxError:
|
except SyntaxError:
|
||||||
log.error('Failed to parse XML response from Newznab: %s' % host)
|
log.error('Failed to parse XML response from Newznab: %s', host)
|
||||||
return results
|
return results
|
||||||
|
|
||||||
def getHosts(self):
|
def getHosts(self):
|
||||||
@@ -216,9 +216,9 @@ class Newznab(NZBProvider, RSS):
|
|||||||
response = e.read().lower()
|
response = e.read().lower()
|
||||||
if 'maximum api' in response or 'download limit' in response:
|
if 'maximum api' in response or 'download limit' in response:
|
||||||
if not self.limits_reached.get(host):
|
if not self.limits_reached.get(host):
|
||||||
log.error('Limit reached for newznab provider: %s' % host)
|
log.error('Limit reached for newznab provider: %s', host)
|
||||||
self.limits_reached[host] = time.time()
|
self.limits_reached[host] = time.time()
|
||||||
return 'try_next'
|
return 'try_next'
|
||||||
|
|
||||||
log.error('Failed download from %s' % (host, traceback.format_exc()))
|
log.error('Failed download from %s', (host, traceback.format_exc()))
|
||||||
raise
|
raise
|
||||||
|
|||||||
@@ -49,7 +49,7 @@ class NZBClub(NZBProvider, RSS):
|
|||||||
data = XMLTree.fromstring(data)
|
data = XMLTree.fromstring(data)
|
||||||
nzbs = self.getElements(data, 'channel/item')
|
nzbs = self.getElements(data, 'channel/item')
|
||||||
except Exception, e:
|
except Exception, e:
|
||||||
log.debug('%s, %s' % (self.getName(), e))
|
log.debug('%s, %s', (self.getName(), e))
|
||||||
return results
|
return results
|
||||||
|
|
||||||
for nzb in nzbs:
|
for nzb in nzbs:
|
||||||
@@ -63,7 +63,7 @@ class NZBClub(NZBProvider, RSS):
|
|||||||
full_description = self.getCache('nzbclub.%s' % nzbclub_id, item['detail_url'], cache_timeout = 25920000)
|
full_description = self.getCache('nzbclub.%s' % nzbclub_id, item['detail_url'], cache_timeout = 25920000)
|
||||||
|
|
||||||
if 'ARCHIVE inside ARCHIVE' in full_description:
|
if 'ARCHIVE inside ARCHIVE' in full_description:
|
||||||
log.info('Wrong: Seems to be passworded files: %s' % new['name'])
|
log.info('Wrong: Seems to be passworded files: %s', new['name'])
|
||||||
return False
|
return False
|
||||||
|
|
||||||
return True
|
return True
|
||||||
@@ -111,7 +111,7 @@ class NZBClub(NZBProvider, RSS):
|
|||||||
full_description = self.getCache('nzbclub.%s' % item['id'], item['detail_url'], cache_timeout = 25920000)
|
full_description = self.getCache('nzbclub.%s' % item['id'], item['detail_url'], cache_timeout = 25920000)
|
||||||
|
|
||||||
if 'ARCHIVE inside ARCHIVE' in full_description:
|
if 'ARCHIVE inside ARCHIVE' in full_description:
|
||||||
log.info('Wrong: Seems to be passworded files: %s' % item['name'])
|
log.info('Wrong: Seems to be passworded files: %s', item['name'])
|
||||||
return False
|
return False
|
||||||
|
|
||||||
return True
|
return True
|
||||||
|
|||||||
@@ -53,7 +53,7 @@ class NzbIndex(NZBProvider, RSS):
|
|||||||
data = XMLTree.fromstring(data)
|
data = XMLTree.fromstring(data)
|
||||||
nzbs = self.getElements(data, 'channel/item')
|
nzbs = self.getElements(data, 'channel/item')
|
||||||
except Exception, e:
|
except Exception, e:
|
||||||
log.debug('%s, %s' % (self.getName(), e))
|
log.debug('%s, %s', (self.getName(), e))
|
||||||
return results
|
return results
|
||||||
|
|
||||||
for nzb in nzbs:
|
for nzb in nzbs:
|
||||||
|
|||||||
@@ -58,7 +58,7 @@ class NZBMatrix(NZBProvider, RSS):
|
|||||||
data = XMLTree.fromstring(data)
|
data = XMLTree.fromstring(data)
|
||||||
nzbs = self.getElements(data, 'channel/item')
|
nzbs = self.getElements(data, 'channel/item')
|
||||||
except Exception, e:
|
except Exception, e:
|
||||||
log.debug('%s, %s' % (self.getName(), e))
|
log.debug('%s, %s', (self.getName(), e))
|
||||||
return results
|
return results
|
||||||
|
|
||||||
for nzb in nzbs:
|
for nzb in nzbs:
|
||||||
|
|||||||
@@ -99,7 +99,7 @@ class KickAssTorrents(TorrentProvider):
|
|||||||
results.append(new)
|
results.append(new)
|
||||||
self.found(new)
|
self.found(new)
|
||||||
except:
|
except:
|
||||||
log.error('Failed parsing KickAssTorrents: %s' % traceback.format_exc())
|
log.error('Failed parsing KickAssTorrents: %s', traceback.format_exc())
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|||||||
@@ -36,11 +36,11 @@ class ThePirateBay(TorrentProvider):
|
|||||||
|
|
||||||
url = self.apiUrl % (quote_plus(self.toSearchString(movie.name + ' ' + quality) + self.makeIgnoreString(type)), self.getCatId(type))
|
url = self.apiUrl % (quote_plus(self.toSearchString(movie.name + ' ' + quality) + self.makeIgnoreString(type)), self.getCatId(type))
|
||||||
|
|
||||||
log.info('Searching: %s' % url)
|
log.info('Searching: %s', url)
|
||||||
|
|
||||||
data = self.urlopen(url)
|
data = self.urlopen(url)
|
||||||
if not data:
|
if not data:
|
||||||
log.error('Failed to get data from %s.' % url)
|
log.error('Failed to get data from %s.', url)
|
||||||
return results
|
return results
|
||||||
|
|
||||||
try:
|
try:
|
||||||
@@ -104,7 +104,7 @@ class ThePirateBay(TorrentProvider):
|
|||||||
new.content = self.getInfo(new.detailUrl)
|
new.content = self.getInfo(new.detailUrl)
|
||||||
if self.isCorrectMovie(new, movie, type):
|
if self.isCorrectMovie(new, movie, type):
|
||||||
results.append(new)
|
results.append(new)
|
||||||
log.info('Found: %s' % new.name)
|
log.info('Found: %s', new.name)
|
||||||
|
|
||||||
return results
|
return results
|
||||||
|
|
||||||
@@ -127,11 +127,11 @@ class ThePirateBay(TorrentProvider):
|
|||||||
|
|
||||||
|
|
||||||
def getInfo(self, url):
|
def getInfo(self, url):
|
||||||
log.debug('Getting info: %s' % url)
|
log.debug('Getting info: %s', url)
|
||||||
|
|
||||||
data = self.urlopen(url)
|
data = self.urlopen(url)
|
||||||
if not data:
|
if not data:
|
||||||
log.error('Failed to get data from %s.' % url)
|
log.error('Failed to get data from %s.', url)
|
||||||
return ''
|
return ''
|
||||||
|
|
||||||
div = SoupStrainer('div')
|
div = SoupStrainer('div')
|
||||||
|
|||||||
@@ -94,7 +94,7 @@ class HDTrailers(TrailerProvider):
|
|||||||
return results
|
return results
|
||||||
|
|
||||||
except AttributeError:
|
except AttributeError:
|
||||||
log.debug('No trailers found in provider %s.' % provider)
|
log.debug('No trailers found in provider %s.', provider)
|
||||||
results['404'] = True
|
results['404'] = True
|
||||||
|
|
||||||
return results
|
return results
|
||||||
|
|||||||
@@ -5,8 +5,8 @@ class YouTheater(UserscriptBase):
|
|||||||
id_re = re.compile("view\.php\?id=(\d+)")
|
id_re = re.compile("view\.php\?id=(\d+)")
|
||||||
includes = ['http://www.youtheater.com/view.php?id=*', 'http://youtheater.com/view.php?id=*',
|
includes = ['http://www.youtheater.com/view.php?id=*', 'http://youtheater.com/view.php?id=*',
|
||||||
'http://www.sratim.co.il/view.php?id=*', 'http://sratim.co.il/view.php?id=*']
|
'http://www.sratim.co.il/view.php?id=*', 'http://sratim.co.il/view.php?id=*']
|
||||||
|
|
||||||
def getMovie(self, url):
|
def getMovie(self, url):
|
||||||
id = self.id_re.findall(url)[0]
|
id = self.id_re.findall(url)[0]
|
||||||
url = "http://www.youtheater.com/view.php?id=%s" % id
|
url = 'http://www.youtheater.com/view.php?id=%s' % id
|
||||||
return super(YouTheater, self).getMovie(url)
|
return super(YouTheater, self).getMovie(url)
|
||||||
|
|||||||
@@ -155,10 +155,10 @@ def runCouchPotato(options, base_path, args, data_dir = None, log_dir = None, En
|
|||||||
import color_logs
|
import color_logs
|
||||||
from couchpotato.core.logger import CPLog
|
from couchpotato.core.logger import CPLog
|
||||||
log = CPLog(__name__)
|
log = CPLog(__name__)
|
||||||
log.debug('Started with options %s' % options)
|
log.debug('Started with options %s', options)
|
||||||
|
|
||||||
def customwarn(message, category, filename, lineno, file = None, line = None):
|
def customwarn(message, category, filename, lineno, file = None, line = None):
|
||||||
log.warning('%s %s %s line:%s' % (category, message, filename, lineno))
|
log.warning('%s %s %s line:%s', (category, message, filename, lineno))
|
||||||
warnings.showwarning = customwarn
|
warnings.showwarning = customwarn
|
||||||
|
|
||||||
|
|
||||||
@@ -185,7 +185,7 @@ def runCouchPotato(options, base_path, args, data_dir = None, log_dir = None, En
|
|||||||
current_db_version = db_version(db, repo)
|
current_db_version = db_version(db, repo)
|
||||||
|
|
||||||
if current_db_version < latest_db_version and not debug:
|
if current_db_version < latest_db_version and not debug:
|
||||||
log.info('Doing database upgrade. From %d to %d' % (current_db_version, latest_db_version))
|
log.info('Doing database upgrade. From %d to %d', (current_db_version, latest_db_version))
|
||||||
upgrade(db, repo)
|
upgrade(db, repo)
|
||||||
|
|
||||||
# Configure Database
|
# Configure Database
|
||||||
@@ -220,7 +220,7 @@ def runCouchPotato(options, base_path, args, data_dir = None, log_dir = None, En
|
|||||||
app.register_blueprint(api, url_prefix = '%s/api/%s/' % (url_base, api_key))
|
app.register_blueprint(api, url_prefix = '%s/api/%s/' % (url_base, api_key))
|
||||||
|
|
||||||
# Some logging and fire load event
|
# Some logging and fire load event
|
||||||
try: log.info('Starting server on port %(port)s' % config)
|
try: log.info('Starting server on port %(port)s', config)
|
||||||
except: pass
|
except: pass
|
||||||
fireEventAsync('app.load')
|
fireEventAsync('app.load')
|
||||||
|
|
||||||
@@ -248,7 +248,7 @@ def runCouchPotato(options, base_path, args, data_dir = None, log_dir = None, En
|
|||||||
try:
|
try:
|
||||||
nr, msg = e
|
nr, msg = e
|
||||||
if nr == 48:
|
if nr == 48:
|
||||||
log.info('Already in use, try %s more time after few seconds' % restart_tries)
|
log.info('Already in use, try %s more time after few seconds', restart_tries)
|
||||||
time.sleep(1)
|
time.sleep(1)
|
||||||
restart_tries -= 1
|
restart_tries -= 1
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user