Try and encode logging messages. fix #403
This commit is contained in:
@@ -80,7 +80,7 @@ class Plugin(object):
|
||||
f.close()
|
||||
os.chmod(path, Env.getPermission('file'))
|
||||
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):
|
||||
try:
|
||||
@@ -88,7 +88,7 @@ class Plugin(object):
|
||||
os.makedirs(path, Env.getPermission('folder'))
|
||||
return True
|
||||
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
|
||||
|
||||
@@ -106,7 +106,7 @@ class Plugin(object):
|
||||
# Don't try for failed requests
|
||||
if self.http_failed_disabled.get(host, 0) > 0:
|
||||
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
|
||||
else:
|
||||
del self.http_failed_request[host]
|
||||
@@ -116,7 +116,7 @@ class Plugin(object):
|
||||
try:
|
||||
|
||||
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)
|
||||
|
||||
cookies = cookielib.CookieJar()
|
||||
@@ -124,7 +124,7 @@ class Plugin(object):
|
||||
|
||||
data = opener.open(request, timeout = timeout).read()
|
||||
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
|
||||
request = urllib2.Request(url, data, headers)
|
||||
|
||||
@@ -133,7 +133,7 @@ class Plugin(object):
|
||||
self.http_failed_request[host] = 0
|
||||
except IOError:
|
||||
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
|
||||
try:
|
||||
@@ -147,7 +147,7 @@ class Plugin(object):
|
||||
self.http_failed_disabled[host] = time.time()
|
||||
|
||||
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
|
||||
|
||||
@@ -163,7 +163,7 @@ class Plugin(object):
|
||||
wait = math.ceil(last_use - now + self.http_time_between_calls)
|
||||
|
||||
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)
|
||||
|
||||
def beforeCall(self, handler):
|
||||
@@ -202,7 +202,7 @@ class Plugin(object):
|
||||
cache_key = simplifyString(cache_key)
|
||||
cache = Env.get('cache').get(cache_key)
|
||||
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
|
||||
|
||||
if url:
|
||||
@@ -220,7 +220,7 @@ class Plugin(object):
|
||||
pass
|
||||
|
||||
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)
|
||||
return value
|
||||
|
||||
|
||||
@@ -78,7 +78,7 @@ class LibraryPlugin(Plugin):
|
||||
except: pass
|
||||
|
||||
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
|
||||
|
||||
# Main info
|
||||
@@ -95,7 +95,7 @@ class LibraryPlugin(Plugin):
|
||||
db.commit()
|
||||
|
||||
titles = info.get('titles', [])
|
||||
log.debug('Adding titles: %s' % titles)
|
||||
log.debug('Adding titles: %s', titles)
|
||||
for title in titles:
|
||||
if not title:
|
||||
continue
|
||||
@@ -123,7 +123,7 @@ class LibraryPlugin(Plugin):
|
||||
library.files.append(file_obj)
|
||||
db.commit()
|
||||
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)
|
||||
|
||||
|
||||
@@ -149,7 +149,7 @@ class Logging(Plugin):
|
||||
except:
|
||||
log.error(log_message)
|
||||
except:
|
||||
log.error('Couldn\'t log via API: %s' % params)
|
||||
log.error('Couldn\'t log via API: %s', params)
|
||||
|
||||
|
||||
return jsonified({
|
||||
|
||||
@@ -52,10 +52,10 @@ class Manage(Plugin):
|
||||
|
||||
if not os.path.isdir(directory):
|
||||
if len(directory) > 0:
|
||||
log.error('Directory doesn\'t exist: %s' % directory)
|
||||
log.error('Directory doesn\'t exist: %s', directory)
|
||||
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)
|
||||
if identifiers:
|
||||
added_identifiers.extend(identifiers)
|
||||
|
||||
@@ -315,7 +315,7 @@ class MoviePlugin(Plugin):
|
||||
|
||||
m.profile_id = params.get('profile_id', default_profile.get('id'))
|
||||
else:
|
||||
log.debug('Movie already exists, not updating: %s' % params)
|
||||
log.debug('Movie already exists, not updating: %s', params)
|
||||
added = False
|
||||
|
||||
if force_readd:
|
||||
@@ -458,7 +458,7 @@ class MoviePlugin(Plugin):
|
||||
log.debug('Can\'t restatus movie, doesn\'t seem to exist.')
|
||||
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:
|
||||
m.status_id = done_status.get('id')
|
||||
else:
|
||||
|
||||
@@ -135,8 +135,7 @@ class ProfilePlugin(Plugin):
|
||||
|
||||
success = True
|
||||
except Exception, e:
|
||||
message = 'Failed deleting Profile: %s' % e
|
||||
log.error(message)
|
||||
message = log.error('Failed deleting Profile: %s', e)
|
||||
|
||||
#db.close()
|
||||
|
||||
@@ -163,7 +162,7 @@ class ProfilePlugin(Plugin):
|
||||
# Create default quality profile
|
||||
order = -2
|
||||
for profile in profiles:
|
||||
log.info('Creating default profile: %s' % profile.get('label'))
|
||||
log.info('Creating default profile: %s', profile.get('label'))
|
||||
p = Profile(
|
||||
label = toUnicode(profile.get('label')),
|
||||
order = order
|
||||
|
||||
@@ -116,7 +116,7 @@ class QualityPlugin(Plugin):
|
||||
quality = db.query(Quality).filter_by(identifier = q.get('identifier')).first()
|
||||
|
||||
if not quality:
|
||||
log.info('Creating quality: %s' % q.get('label'))
|
||||
log.info('Creating quality: %s', q.get('label'))
|
||||
quality = Quality()
|
||||
db.add(quality)
|
||||
|
||||
@@ -133,7 +133,7 @@ class QualityPlugin(Plugin):
|
||||
).all()
|
||||
|
||||
if not profile:
|
||||
log.info('Creating profile: %s' % q.get('label'))
|
||||
log.info('Creating profile: %s', q.get('label'))
|
||||
profile = Profile(
|
||||
core = True,
|
||||
label = toUnicode(quality.label),
|
||||
@@ -170,20 +170,20 @@ class QualityPlugin(Plugin):
|
||||
|
||||
# Check tags
|
||||
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)
|
||||
|
||||
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)
|
||||
|
||||
for tag in quality.get('tags', []):
|
||||
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)
|
||||
|
||||
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)
|
||||
|
||||
# Try again with loose testing
|
||||
@@ -191,7 +191,7 @@ class QualityPlugin(Plugin):
|
||||
if 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
|
||||
|
||||
def guessLoose(self, hash, extra):
|
||||
@@ -200,7 +200,7 @@ class QualityPlugin(Plugin):
|
||||
|
||||
# Last check on resolution only
|
||||
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)
|
||||
|
||||
if 480 <= extra.get('resolution_width', 0) <= 720:
|
||||
|
||||
@@ -79,7 +79,7 @@ class Release(Plugin):
|
||||
rel.files.append(added_file)
|
||||
db.commit()
|
||||
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)
|
||||
|
||||
@@ -158,7 +158,7 @@ class Release(Plugin):
|
||||
'success': True
|
||||
})
|
||||
else:
|
||||
log.error('Couldn\'t find release with id: %s' % id)
|
||||
log.error('Couldn\'t find release with id: %s', id)
|
||||
|
||||
#db.close()
|
||||
return jsonified({
|
||||
|
||||
@@ -100,7 +100,7 @@ class Renamer(Plugin):
|
||||
else:
|
||||
group['library'] = fireEvent('library.update', identifier = group['library']['identifier'], single = True)
|
||||
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
|
||||
|
||||
library = group['library']
|
||||
@@ -138,7 +138,7 @@ class Renamer(Plugin):
|
||||
|
||||
# Move nfo depending on settings
|
||||
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'):
|
||||
for current_file in group['files'][file_type]:
|
||||
remove_files.append(current_file)
|
||||
@@ -197,7 +197,7 @@ class Renamer(Plugin):
|
||||
break
|
||||
|
||||
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
|
||||
else:
|
||||
@@ -272,7 +272,7 @@ class Renamer(Plugin):
|
||||
movie.status_id = done_status.get('id')
|
||||
db.commit()
|
||||
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
|
||||
for release in movie.releases:
|
||||
@@ -282,20 +282,20 @@ class Renamer(Plugin):
|
||||
|
||||
# This is where CP removes older, lesser quality releases
|
||||
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:
|
||||
remove_files.append(current_file)
|
||||
remove_releases.append(release)
|
||||
# Same quality, but still downloaded, so maybe repack/proper/unrated/directors cut etc
|
||||
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:
|
||||
remove_files.append(current_file)
|
||||
remove_releases.append(release)
|
||||
|
||||
# Downloaded a lower quality, rename the newly downloaded files/folder to exclude them from scan
|
||||
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
|
||||
if group['dirname']:
|
||||
@@ -333,18 +333,18 @@ class Renamer(Plugin):
|
||||
if isinstance(src, File):
|
||||
src = src.path
|
||||
|
||||
log.info('Removing "%s"' % src)
|
||||
log.info('Removing "%s"', src)
|
||||
try:
|
||||
os.remove(src)
|
||||
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
|
||||
group['renamed_files'] = []
|
||||
for src in rename_files:
|
||||
if 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
|
||||
self.makeDir(os.path.dirname(dst))
|
||||
@@ -353,22 +353,22 @@ class Renamer(Plugin):
|
||||
self.moveFile(src, dst)
|
||||
group['renamed_files'].append(dst)
|
||||
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
|
||||
for release in remove_releases:
|
||||
log.debug('Removing release %s' % release.identifier)
|
||||
log.debug('Removing release %s', release.identifier)
|
||||
try:
|
||||
db.delete(release)
|
||||
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']:
|
||||
try:
|
||||
log.info('Deleting folder: %s' % group['parentdir'])
|
||||
log.info('Deleting folder: %s', group['parentdir'])
|
||||
self.deleteEmptyFolder(group['parentdir'])
|
||||
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:
|
||||
# Search for trailers etc
|
||||
@@ -408,10 +408,10 @@ class Renamer(Plugin):
|
||||
try:
|
||||
os.chmod(dest, Env.getPermission('file'))
|
||||
except:
|
||||
log.error('Failed setting permissions for file: %s' % dest)
|
||||
log.error('Failed setting permissions for file: %s', dest)
|
||||
|
||||
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
|
||||
|
||||
return True
|
||||
@@ -447,9 +447,9 @@ class Renamer(Plugin):
|
||||
try:
|
||||
os.rmdir(full_path)
|
||||
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:
|
||||
os.rmdir(folder)
|
||||
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)
|
||||
|
||||
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 {}
|
||||
|
||||
# Get movie "master" files
|
||||
@@ -154,12 +154,12 @@ class Scanner(Plugin):
|
||||
try:
|
||||
files = []
|
||||
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 filename in walk_files:
|
||||
files.append(os.path.join(root, filename))
|
||||
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()
|
||||
|
||||
@@ -215,7 +215,7 @@ class Scanner(Plugin):
|
||||
for identifier, group in movie_files.iteritems():
|
||||
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']:
|
||||
wo_ext = file_path[:-(len(getExt(file_path)) + 1)]
|
||||
@@ -241,7 +241,7 @@ class Scanner(Plugin):
|
||||
# Group the files based on the identifier
|
||||
delete_identifiers = []
|
||||
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)
|
||||
if group:
|
||||
@@ -264,7 +264,7 @@ class Scanner(Plugin):
|
||||
# Group based on folder
|
||||
delete_identifiers = []
|
||||
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:
|
||||
new_identifier = self.createStringIdentifier(os.path.dirname(ff), folder)
|
||||
@@ -308,7 +308,7 @@ class Scanner(Plugin):
|
||||
break
|
||||
|
||||
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
|
||||
del group['unsorted_files']
|
||||
@@ -322,7 +322,7 @@ class Scanner(Plugin):
|
||||
if file_time[0] > time.time() or file_time[1] > time.time():
|
||||
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
|
||||
del group['unsorted_files']
|
||||
@@ -348,10 +348,10 @@ class Scanner(Plugin):
|
||||
group['files']['movie'] = self.getMediaFiles(group['unsorted_files'])
|
||||
|
||||
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
|
||||
|
||||
log.debug('Getting metadata for %s' % identifier)
|
||||
log.debug('Getting metadata for %s', identifier)
|
||||
group['meta_data'] = self.getMetaData(group)
|
||||
|
||||
# Subtitle meta
|
||||
@@ -384,7 +384,7 @@ class Scanner(Plugin):
|
||||
# Determine movie
|
||||
group['library'] = self.determineMovie(group)
|
||||
if not group['library']:
|
||||
log.error('Unable to determine movie: %s' % group['identifiers'])
|
||||
log.error('Unable to determine movie: %s', group['identifiers'])
|
||||
else:
|
||||
movie = db.query(Movie).filter_by(library_id = group['library']['id']).first()
|
||||
group['movie_id'] = None if not movie else movie.id
|
||||
@@ -397,9 +397,9 @@ class Scanner(Plugin):
|
||||
self.path_identifiers = {}
|
||||
|
||||
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:
|
||||
log.debug('Found no movies in the folder %s' % (folder))
|
||||
log.debug('Found no movies in the folder %s', (folder))
|
||||
return processed_movies
|
||||
|
||||
def getMetaData(self, group):
|
||||
@@ -419,7 +419,7 @@ class Scanner(Plugin):
|
||||
data['resolution_height'] = meta.get('resolution_height', 480)
|
||||
data['aspect'] = meta.get('resolution_width', 720) / meta.get('resolution_height', 480)
|
||||
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
|
||||
|
||||
if data.get('audio'): break
|
||||
@@ -447,11 +447,11 @@ class Scanner(Plugin):
|
||||
'resolution_height': tryInt(p.video[0].height),
|
||||
}
|
||||
except ParseError:
|
||||
log.debug('Failed to parse meta for %s' % filename)
|
||||
log.debug('Failed to parse meta for %s', filename)
|
||||
except NoParserError:
|
||||
log.debug('No parser found for %s' % filename)
|
||||
log.debug('No parser found for %s', filename)
|
||||
except:
|
||||
log.debug('Failed parsing %s' % filename)
|
||||
log.debug('Failed parsing %s', filename)
|
||||
|
||||
return {}
|
||||
|
||||
@@ -473,7 +473,7 @@ class Scanner(Plugin):
|
||||
if s.language and s.path not in paths:
|
||||
detected_languages[s.path] = [s.language]
|
||||
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
|
||||
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):
|
||||
detected_languages[sub_file] = idx_langs
|
||||
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
|
||||
|
||||
@@ -502,7 +502,7 @@ class Scanner(Plugin):
|
||||
for cur_file in files['movie']:
|
||||
imdb_id = self.getCPImdb(cur_file)
|
||||
if imdb_id:
|
||||
log.debug('Found movie via CP tag: %s' % cur_file)
|
||||
log.debug('Found movie via CP tag: %s', cur_file)
|
||||
break
|
||||
|
||||
# Check and see if nfo contains the imdb-id
|
||||
@@ -511,7 +511,7 @@ class Scanner(Plugin):
|
||||
for nfo_file in files['nfo']:
|
||||
imdb_id = getImdb(nfo_file)
|
||||
if imdb_id:
|
||||
log.debug('Found movie via nfo file: %s' % nfo_file)
|
||||
log.debug('Found movie via nfo file: %s', nfo_file)
|
||||
break
|
||||
except:
|
||||
pass
|
||||
@@ -523,7 +523,7 @@ class Scanner(Plugin):
|
||||
for filetype_file in files[filetype]:
|
||||
imdb_id = getImdb(filetype_file, check_inside = False)
|
||||
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
|
||||
except:
|
||||
pass
|
||||
@@ -535,7 +535,7 @@ class Scanner(Plugin):
|
||||
f = db.query(File).filter_by(path = toUnicode(cur_file)).first()
|
||||
try:
|
||||
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
|
||||
except:
|
||||
pass
|
||||
@@ -549,7 +549,7 @@ class Scanner(Plugin):
|
||||
if len(movie) > 0:
|
||||
imdb_id = movie[0]['imdb']
|
||||
if imdb_id:
|
||||
log.debug('Found movie via OpenSubtitleHash: %s' % cur_file)
|
||||
log.debug('Found movie via OpenSubtitleHash: %s', cur_file)
|
||||
break
|
||||
|
||||
# Search based on identifiers
|
||||
@@ -566,17 +566,17 @@ class Scanner(Plugin):
|
||||
|
||||
if len(movie) > 0:
|
||||
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
|
||||
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:
|
||||
return fireEvent('library.add', attrs = {
|
||||
'identifier': imdb_id
|
||||
}, 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 {}
|
||||
|
||||
def getCPImdb(self, string):
|
||||
@@ -665,17 +665,17 @@ class Scanner(Plugin):
|
||||
# ignoredpaths
|
||||
for i in self.ignored_in_path:
|
||||
if i in filename.lower():
|
||||
log.debug('Ignored "%s" contains "%s".' % (filename, i))
|
||||
log.debug('Ignored "%s" contains "%s".', (filename, i))
|
||||
return False
|
||||
|
||||
# Sample file
|
||||
if self.isSampleFile(filename):
|
||||
log.debug('Is sample file "%s".' % filename)
|
||||
log.debug('Is sample file "%s".', filename)
|
||||
return False
|
||||
|
||||
# Minimal size
|
||||
if self.filesizeBetween(filename, self.minimal_filesize['media']):
|
||||
log.debug('File to small: %s' % filename)
|
||||
log.debug('File to small: %s', filename)
|
||||
return False
|
||||
|
||||
# All is OK
|
||||
@@ -683,14 +683,14 @@ class Scanner(Plugin):
|
||||
|
||||
def isSampleFile(self, filename):
|
||||
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
|
||||
|
||||
def filesizeBetween(self, file, min = 0, max = 100000):
|
||||
try:
|
||||
return (min * 1048576) < os.path.getsize(file) < (max * 1048576)
|
||||
except:
|
||||
log.error('Couldn\'t get filesize of %s.' % file)
|
||||
log.error('Couldn\'t get filesize of %s.', file)
|
||||
|
||||
return False
|
||||
|
||||
@@ -793,7 +793,7 @@ class Scanner(Plugin):
|
||||
'year': guess.get('year'),
|
||||
}
|
||||
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
|
||||
cleaned = ' '.join(re.split('\W+', simplifyString(release_name)))
|
||||
|
||||
@@ -56,7 +56,7 @@ class Searcher(Plugin):
|
||||
except IndexError:
|
||||
fireEvent('library.update', movie_dict['library']['identifier'], force = True)
|
||||
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
|
||||
if self.shuttingDown():
|
||||
@@ -88,7 +88,7 @@ class Searcher(Plugin):
|
||||
ret = False
|
||||
for quality_type in movie['profile']['types']:
|
||||
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
|
||||
|
||||
has_better_quality = 0
|
||||
@@ -101,12 +101,12 @@ class Searcher(Plugin):
|
||||
# Don't search for quality lower then already available.
|
||||
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)
|
||||
results = fireEvent('yarr.search', movie, quality, merge = True)
|
||||
sorted_results = sorted(results, key = lambda k: k['score'], reverse = True)
|
||||
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
|
||||
if not db.query(Movie).filter_by(id = movie.get('id')).first():
|
||||
@@ -141,7 +141,7 @@ class Searcher(Plugin):
|
||||
rls.info.append(rls_info)
|
||||
db.commit()
|
||||
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:
|
||||
@@ -152,7 +152,7 @@ class Searcher(Plugin):
|
||||
elif downloaded != 'try_next':
|
||||
break
|
||||
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'])
|
||||
break
|
||||
|
||||
@@ -200,7 +200,7 @@ class Searcher(Plugin):
|
||||
if movie['status_id'] == active_status.get('id'):
|
||||
for profile_type in movie['profile']['types']:
|
||||
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
|
||||
rls.status_id = done_status.get('id')
|
||||
@@ -211,7 +211,7 @@ class Searcher(Plugin):
|
||||
mvie.status_id = done_status.get('id')
|
||||
db.commit()
|
||||
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()
|
||||
return True
|
||||
@@ -226,7 +226,7 @@ class Searcher(Plugin):
|
||||
retention = Env.setting('retention', section = 'nzb')
|
||||
|
||||
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
|
||||
|
||||
movie_name = getTitle(movie['library'])
|
||||
@@ -248,7 +248,7 @@ class Searcher(Plugin):
|
||||
pron_tags = ['xxx', 'sex', 'anal', 'tits', 'fuck', 'porn', 'orgy', 'milf', 'boobs']
|
||||
for p_tag in pron_tags:
|
||||
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
|
||||
|
||||
#qualities = fireEvent('quality.all', single = True)
|
||||
@@ -256,18 +256,18 @@ class Searcher(Plugin):
|
||||
|
||||
# Contains lower quality string
|
||||
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
|
||||
|
||||
|
||||
# File to small
|
||||
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
|
||||
|
||||
# File to large
|
||||
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
|
||||
|
||||
|
||||
|
||||
@@ -92,7 +92,7 @@ class StatusPlugin(Plugin):
|
||||
for identifier, label in self.statuses.iteritems():
|
||||
s = db.query(Status).filter_by(identifier = identifier).first()
|
||||
if not s:
|
||||
log.info('Creating status: %s' % label)
|
||||
log.info('Creating status: %s', label)
|
||||
s = Status(
|
||||
identifier = identifier,
|
||||
label = toUnicode(label)
|
||||
|
||||
@@ -18,7 +18,7 @@ class Trailer(Plugin):
|
||||
|
||||
trailers = fireEvent('trailer.search', group = group, merge = True)
|
||||
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
|
||||
|
||||
for trailer in trailers.get(self.conf('quality'), []):
|
||||
@@ -26,7 +26,7 @@ class Trailer(Plugin):
|
||||
if not os.path.isfile(destination):
|
||||
fireEvent('file.download', url = trailer, dest = destination, urlopen_kwargs = {'headers': {'User-Agent': 'Quicktime'}}, single = True)
|
||||
else:
|
||||
log.debug('Trailer already exists: %s' % destination)
|
||||
log.debug('Trailer already exists: %s', destination)
|
||||
|
||||
# Download first and break
|
||||
break
|
||||
|
||||
@@ -73,7 +73,7 @@ class Userscript(Plugin):
|
||||
'movie': fireEvent('userscript.get_movie_via_url', url = url, single = True)
|
||||
}
|
||||
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'
|
||||
|
||||
return jsonified(params)
|
||||
|
||||
Reference in New Issue
Block a user