Close all
This commit is contained in:
@@ -101,6 +101,8 @@ class MediaPlugin(MediaBase):
|
||||
def handler():
|
||||
fireEvent(event, identifier = identifier, default_title = default_title, on_complete = self.createOnComplete(id))
|
||||
|
||||
db.close()
|
||||
|
||||
if handler:
|
||||
return handler
|
||||
|
||||
@@ -124,6 +126,7 @@ class MediaPlugin(MediaBase):
|
||||
if m:
|
||||
results = m.to_dict(self.default_dict)
|
||||
|
||||
db.close()
|
||||
return results
|
||||
|
||||
def getView(self, id = None, **kwargs):
|
||||
@@ -259,6 +262,7 @@ class MediaPlugin(MediaBase):
|
||||
'releases_count': releases_count.get(media_id),
|
||||
}))
|
||||
|
||||
db.close()
|
||||
return total_count, movies
|
||||
|
||||
def listView(self, **kwargs):
|
||||
@@ -352,6 +356,7 @@ class MediaPlugin(MediaBase):
|
||||
if len(chars) == 25:
|
||||
break
|
||||
|
||||
db.close()
|
||||
return ''.join(sorted(chars))
|
||||
|
||||
def charView(self, **kwargs):
|
||||
|
||||
@@ -117,6 +117,7 @@ class MovieSearcher(SearcherBase, MovieTypeBase):
|
||||
pass
|
||||
|
||||
self.in_progress = False
|
||||
db.close()
|
||||
|
||||
def single(self, movie, search_protocols = None, manual = False):
|
||||
|
||||
@@ -207,6 +208,7 @@ class MovieSearcher(SearcherBase, MovieTypeBase):
|
||||
|
||||
fireEvent('notify.frontend', type = 'movie.searcher.ended', data = {'id': movie['id']})
|
||||
|
||||
db.close()
|
||||
return ret
|
||||
|
||||
def correctRelease(self, nzb = None, media = None, quality = None, **kwargs):
|
||||
|
||||
@@ -33,6 +33,7 @@ class Suggestion(Plugin):
|
||||
.options(joinedload_all('library')) \
|
||||
.filter(or_(*[Media.status.has(identifier = s) for s in ['active', 'done']])).all()
|
||||
movies = [x.library.identifier for x in active_movies]
|
||||
db.close()
|
||||
|
||||
if not ignored or len(ignored) == 0:
|
||||
ignored = splitString(Env.prop('suggest_ignore', default = ''))
|
||||
@@ -97,6 +98,7 @@ class Suggestion(Plugin):
|
||||
.filter(Media.status_id.in_([active_status.get('id'), done_status.get('id')])).all()
|
||||
movies = [x[0] for x in active_movies]
|
||||
movies.extend(seen)
|
||||
db.close()
|
||||
|
||||
ignored.extend([x.get('imdb') for x in cached_suggestion])
|
||||
suggestions = fireEvent('movie.suggest', movies = movies, ignore = removeDuplicate(ignored), single = True)
|
||||
|
||||
@@ -126,6 +126,7 @@ class CoreNotifier(Notification):
|
||||
ndict['type'] = 'notification'
|
||||
notifications.append(ndict)
|
||||
|
||||
db.close()
|
||||
return {
|
||||
'success': True,
|
||||
'empty': len(notifications) == 0,
|
||||
@@ -172,6 +173,7 @@ class CoreNotifier(Notification):
|
||||
|
||||
self.frontend(type = listener, data = data)
|
||||
|
||||
db.close()
|
||||
return True
|
||||
except:
|
||||
log.error('Failed notify: %s', traceback.format_exc())
|
||||
@@ -287,6 +289,8 @@ class CoreNotifier(Notification):
|
||||
ndict['type'] = 'notification'
|
||||
messages.append(ndict)
|
||||
|
||||
db.close()
|
||||
|
||||
return {
|
||||
'success': True,
|
||||
'result': messages,
|
||||
|
||||
@@ -42,6 +42,7 @@ class CategoryPlugin(Plugin):
|
||||
for category in categories:
|
||||
temp.append(category.to_dict())
|
||||
|
||||
db.close()
|
||||
return temp
|
||||
|
||||
def save(self, **kwargs):
|
||||
@@ -65,6 +66,7 @@ class CategoryPlugin(Plugin):
|
||||
|
||||
category_dict = c.to_dict()
|
||||
|
||||
db.close()
|
||||
return {
|
||||
'success': True,
|
||||
'category': category_dict
|
||||
@@ -94,6 +96,7 @@ class CategoryPlugin(Plugin):
|
||||
|
||||
db.commit()
|
||||
|
||||
db.close()
|
||||
return {
|
||||
'success': True
|
||||
}
|
||||
@@ -126,6 +129,7 @@ class CategoryPlugin(Plugin):
|
||||
except Exception as e:
|
||||
message = log.error('Failed deleting category: %s', e)
|
||||
|
||||
db.close()
|
||||
return {
|
||||
'success': success,
|
||||
'message': message
|
||||
|
||||
@@ -119,6 +119,7 @@ class Dashboard(Plugin):
|
||||
'files': {},
|
||||
}))
|
||||
|
||||
db.close()
|
||||
return {
|
||||
'success': True,
|
||||
'empty': len(movies) == 0,
|
||||
|
||||
@@ -166,6 +166,7 @@ class FileManager(Plugin):
|
||||
for type_object in results:
|
||||
types.append(type_object.to_dict())
|
||||
|
||||
db.close()
|
||||
return types
|
||||
|
||||
def getTypesView(self, **kwargs):
|
||||
|
||||
@@ -71,6 +71,7 @@ class ProfilePlugin(Plugin):
|
||||
for profile in profiles:
|
||||
temp.append(profile.to_dict(self.to_dict))
|
||||
|
||||
db.close()
|
||||
return temp
|
||||
|
||||
def save(self, **kwargs):
|
||||
@@ -127,6 +128,7 @@ class ProfilePlugin(Plugin):
|
||||
.options(joinedload_all('types')) \
|
||||
.first()
|
||||
default_dict = default.to_dict(self.to_dict)
|
||||
db.close()
|
||||
|
||||
return default_dict
|
||||
|
||||
|
||||
@@ -78,6 +78,8 @@ class QualityPlugin(Plugin):
|
||||
temp.append(q)
|
||||
|
||||
self.cached_qualities = temp
|
||||
|
||||
db.close()
|
||||
return temp
|
||||
|
||||
def single(self, identifier = ''):
|
||||
@@ -89,6 +91,7 @@ class QualityPlugin(Plugin):
|
||||
if quality:
|
||||
quality_dict = dict(self.getQuality(quality.identifier), **quality.to_dict())
|
||||
|
||||
db.close()
|
||||
return quality_dict
|
||||
|
||||
def getQuality(self, identifier):
|
||||
|
||||
@@ -88,6 +88,8 @@ class Release(Plugin):
|
||||
elif rel.status_id in [snatched_status.get('id'), downloaded_status.get('id')]:
|
||||
self.updateStatus(id = rel.id, status = ignored_status)
|
||||
|
||||
db.close()
|
||||
|
||||
|
||||
def add(self, group):
|
||||
|
||||
@@ -176,7 +178,7 @@ class Release(Plugin):
|
||||
|
||||
rel = db.query(Relea).filter_by(id = id).first()
|
||||
if rel:
|
||||
rel.delete()
|
||||
db.delete(rel)
|
||||
db.commit()
|
||||
return True
|
||||
except:
|
||||
@@ -220,6 +222,7 @@ class Release(Plugin):
|
||||
ignored_status, failed_status, available_status = fireEvent('status.get', ['ignored', 'failed', 'available'], single = True)
|
||||
self.updateStatus(id, available_status if rel.status_id in [ignored_status.get('id'), failed_status.get('id')] else ignored_status)
|
||||
|
||||
db.close()
|
||||
return {
|
||||
'success': True
|
||||
}
|
||||
@@ -259,11 +262,10 @@ class Release(Plugin):
|
||||
'files': {}
|
||||
}), manual = True)
|
||||
|
||||
db.expunge_all()
|
||||
|
||||
if success:
|
||||
fireEvent('notify.frontend', type = 'release.manual_download', data = True, message = 'Successfully snatched "%s"' % item['name'])
|
||||
|
||||
db.close()
|
||||
return {
|
||||
'success': success == True
|
||||
}
|
||||
@@ -456,6 +458,7 @@ class Release(Plugin):
|
||||
releases = [r.to_dict({'info': {}, 'files': {}}) for r in releases_raw]
|
||||
releases = sorted(releases, key = lambda k: k['info'].get('score', 0), reverse = True)
|
||||
|
||||
db.close()
|
||||
return releases
|
||||
|
||||
def forMovieView(self, id = None, **kwargs):
|
||||
|
||||
@@ -598,6 +598,7 @@ class Renamer(Plugin):
|
||||
break
|
||||
|
||||
self.renaming_started = False
|
||||
db.close()
|
||||
|
||||
def getRenameExtras(self, extra_type = '', replacements = None, folder_name = '', file_name = '', destination = '', group = None, current_file = '', remove_multiple = False):
|
||||
if not group: group = {}
|
||||
@@ -851,197 +852,200 @@ Remove it if you want it to be renamed (again, or at least let it try again)
|
||||
snatched_status, ignored_status, failed_status, seeding_status, downloaded_status, missing_status = \
|
||||
fireEvent('status.get', ['snatched', 'ignored', 'failed', 'seeding', 'downloaded', 'missing'], single = True)
|
||||
|
||||
db = get_session()
|
||||
rels = db.query(Release).filter(
|
||||
Release.status_id.in_([snatched_status.get('id'), seeding_status.get('id'), missing_status.get('id')])
|
||||
).all()
|
||||
|
||||
if not rels:
|
||||
#No releases found that need status checking
|
||||
self.checking_snatched = False
|
||||
return True
|
||||
|
||||
# Collect all download information with the download IDs from the releases
|
||||
download_ids = []
|
||||
no_status_support = []
|
||||
try:
|
||||
for rel in rels:
|
||||
rel_dict = rel.to_dict({'info': {}})
|
||||
if rel_dict['info'].get('download_id') and rel_dict['info'].get('download_downloader'):
|
||||
download_ids.append({'id': rel_dict['info']['download_id'], 'downloader': rel_dict['info']['download_downloader']})
|
||||
db = get_session()
|
||||
rels = db.query(Release).filter(
|
||||
Release.status_id.in_([snatched_status.get('id'), seeding_status.get('id'), missing_status.get('id')])
|
||||
).all()
|
||||
|
||||
ds = rel_dict['info'].get('download_status_support')
|
||||
if ds == False or ds == 'False':
|
||||
no_status_support.append(ss(rel_dict['info'].get('download_downloader')))
|
||||
except:
|
||||
log.error('Error getting download IDs from database')
|
||||
self.checking_snatched = False
|
||||
return False
|
||||
if not rels:
|
||||
#No releases found that need status checking
|
||||
self.checking_snatched = False
|
||||
return True
|
||||
|
||||
release_downloads = fireEvent('download.status', download_ids, merge = True) if download_ids else []
|
||||
# Collect all download information with the download IDs from the releases
|
||||
download_ids = []
|
||||
no_status_support = []
|
||||
try:
|
||||
for rel in rels:
|
||||
rel_dict = rel.to_dict({'info': {}})
|
||||
if rel_dict['info'].get('download_id') and rel_dict['info'].get('download_downloader'):
|
||||
download_ids.append({'id': rel_dict['info']['download_id'], 'downloader': rel_dict['info']['download_downloader']})
|
||||
|
||||
if len(no_status_support) > 0:
|
||||
log.debug('Download status functionality is not implemented for one of the active downloaders: %s', no_status_support)
|
||||
ds = rel_dict['info'].get('download_status_support')
|
||||
if ds == False or ds == 'False':
|
||||
no_status_support.append(ss(rel_dict['info'].get('download_downloader')))
|
||||
except:
|
||||
log.error('Error getting download IDs from database')
|
||||
self.checking_snatched = False
|
||||
return False
|
||||
|
||||
if not release_downloads:
|
||||
if fire_scan:
|
||||
self.scan()
|
||||
release_downloads = fireEvent('download.status', download_ids, merge = True) if download_ids else []
|
||||
|
||||
self.checking_snatched = False
|
||||
return True
|
||||
if len(no_status_support) > 0:
|
||||
log.debug('Download status functionality is not implemented for one of the active downloaders: %s', no_status_support)
|
||||
|
||||
scan_releases = []
|
||||
scan_required = False
|
||||
if not release_downloads:
|
||||
if fire_scan:
|
||||
self.scan()
|
||||
|
||||
log.debug('Checking status snatched releases...')
|
||||
self.checking_snatched = False
|
||||
return True
|
||||
|
||||
try:
|
||||
for rel in rels:
|
||||
rel_dict = rel.to_dict({'info': {}})
|
||||
movie_dict = fireEvent('media.get', media_id = rel.movie_id, single = True)
|
||||
scan_releases = []
|
||||
scan_required = False
|
||||
|
||||
if not isinstance(rel_dict['info'], dict):
|
||||
log.error('Faulty release found without any info, ignoring.')
|
||||
fireEvent('release.update_status', rel.id, status = ignored_status, single = True)
|
||||
continue
|
||||
log.debug('Checking status snatched releases...')
|
||||
|
||||
# Check if download ID is available
|
||||
if not rel_dict['info'].get('download_id') or not rel_dict['info'].get('download_downloader'):
|
||||
log.debug('Download status functionality is not implemented for downloader (%s) of release %s.', (rel_dict['info'].get('download_downloader', 'unknown'), rel_dict['info']['name']))
|
||||
scan_required = True
|
||||
try:
|
||||
for rel in rels:
|
||||
rel_dict = rel.to_dict({'info': {}})
|
||||
movie_dict = fireEvent('media.get', media_id = rel.movie_id, single = True)
|
||||
|
||||
# Continue with next release
|
||||
continue
|
||||
if not isinstance(rel_dict['info'], dict):
|
||||
log.error('Faulty release found without any info, ignoring.')
|
||||
fireEvent('release.update_status', rel.id, status = ignored_status, single = True)
|
||||
continue
|
||||
|
||||
# Find release in downloaders
|
||||
nzbname = self.createNzbName(rel_dict['info'], movie_dict)
|
||||
# Check if download ID is available
|
||||
if not rel_dict['info'].get('download_id') or not rel_dict['info'].get('download_downloader'):
|
||||
log.debug('Download status functionality is not implemented for downloader (%s) of release %s.', (rel_dict['info'].get('download_downloader', 'unknown'), rel_dict['info']['name']))
|
||||
scan_required = True
|
||||
|
||||
# Continue with next release
|
||||
continue
|
||||
|
||||
# Find release in downloaders
|
||||
nzbname = self.createNzbName(rel_dict['info'], movie_dict)
|
||||
|
||||
found_release = False
|
||||
for release_download in release_downloads:
|
||||
found_release = False
|
||||
if rel_dict['info'].get('download_id'):
|
||||
if release_download['id'] == rel_dict['info']['download_id'] and release_download['downloader'] == rel_dict['info']['download_downloader']:
|
||||
log.debug('Found release by id: %s', release_download['id'])
|
||||
found_release = True
|
||||
break
|
||||
else:
|
||||
if release_download['name'] == nzbname or rel_dict['info']['name'] in release_download['name'] or getImdb(release_download['name']) == movie_dict['library']['identifier']:
|
||||
log.debug('Found release by release name or imdb ID: %s', release_download['name'])
|
||||
found_release = True
|
||||
break
|
||||
|
||||
if not found_release:
|
||||
log.info('%s not found in downloaders', nzbname)
|
||||
|
||||
#Check status if already missing and for how long, if > 1 week, set to ignored else to missing
|
||||
if rel.status_id == missing_status.get('id'):
|
||||
if rel.last_edit < int(time.time()) - 7 * 24 * 60 * 60:
|
||||
fireEvent('release.update_status', rel.id, status = ignored_status, single = True)
|
||||
else:
|
||||
# Set the release to missing
|
||||
fireEvent('release.update_status', rel.id, status = missing_status, single = True)
|
||||
|
||||
# Continue with next release
|
||||
continue
|
||||
|
||||
# Log that we found the release
|
||||
timeleft = 'N/A' if release_download['timeleft'] == -1 else release_download['timeleft']
|
||||
log.debug('Found %s: %s, time to go: %s', (release_download['name'], release_download['status'].upper(), timeleft))
|
||||
|
||||
# Check status of release
|
||||
if release_download['status'] == 'busy':
|
||||
# Set the release to snatched if it was missing before
|
||||
fireEvent('release.update_status', rel.id, status = snatched_status, single = True)
|
||||
|
||||
# Tag folder if it is in the 'from' folder and it will not be processed because it is still downloading
|
||||
if self.movieInFromFolder(release_download['folder']):
|
||||
self.tagRelease(release_download = release_download, tag = 'downloading')
|
||||
|
||||
elif release_download['status'] == 'seeding':
|
||||
#If linking setting is enabled, process release
|
||||
if self.conf('file_action') != 'move' and not rel.status_id == seeding_status.get('id') and self.statusInfoComplete(release_download):
|
||||
log.info('Download of %s completed! It is now being processed while leaving the original files alone for seeding. Current ratio: %s.', (release_download['name'], release_download['seed_ratio']))
|
||||
|
||||
# Remove the downloading tag
|
||||
self.untagRelease(release_download = release_download, tag = 'downloading')
|
||||
|
||||
# Scan and set the torrent to paused if required
|
||||
release_download.update({'pause': True, 'scan': True, 'process_complete': False})
|
||||
scan_releases.append(release_download)
|
||||
else:
|
||||
#let it seed
|
||||
log.debug('%s is seeding with ratio: %s', (release_download['name'], release_download['seed_ratio']))
|
||||
|
||||
# Set the release to seeding
|
||||
fireEvent('release.update_status', rel.id, status = seeding_status, single = True)
|
||||
|
||||
elif release_download['status'] == 'failed':
|
||||
# Set the release to failed
|
||||
fireEvent('release.update_status', rel.id, status = failed_status, single = True)
|
||||
|
||||
fireEvent('download.remove_failed', release_download, single = True)
|
||||
|
||||
if self.conf('next_on_failed'):
|
||||
fireEvent('movie.searcher.try_next_release', media_id = rel.movie_id)
|
||||
|
||||
elif release_download['status'] == 'completed':
|
||||
log.info('Download of %s completed!', release_download['name'])
|
||||
|
||||
#Make sure the downloader sent over a path to look in
|
||||
if self.statusInfoComplete(release_download):
|
||||
|
||||
# If the release has been seeding, process now the seeding is done
|
||||
if rel.status_id == seeding_status.get('id'):
|
||||
if self.conf('file_action') != 'move':
|
||||
# Set the release to done as the movie has already been renamed
|
||||
fireEvent('release.update_status', rel.id, status = downloaded_status, single = True)
|
||||
|
||||
# Allow the downloader to clean-up
|
||||
release_download.update({'pause': False, 'scan': False, 'process_complete': True})
|
||||
scan_releases.append(release_download)
|
||||
else:
|
||||
# Scan and Allow the downloader to clean-up
|
||||
release_download.update({'pause': False, 'scan': True, 'process_complete': True})
|
||||
scan_releases.append(release_download)
|
||||
|
||||
for release_download in release_downloads:
|
||||
found_release = False
|
||||
if rel_dict['info'].get('download_id'):
|
||||
if release_download['id'] == rel_dict['info']['download_id'] and release_download['downloader'] == rel_dict['info']['download_downloader']:
|
||||
log.debug('Found release by id: %s', release_download['id'])
|
||||
found_release = True
|
||||
break
|
||||
else:
|
||||
# Set the release to snatched if it was missing before
|
||||
fireEvent('release.update_status', rel.id, status = snatched_status, single = True)
|
||||
if release_download['name'] == nzbname or rel_dict['info']['name'] in release_download['name'] or getImdb(release_download['name']) == movie_dict['library']['identifier']:
|
||||
log.debug('Found release by release name or imdb ID: %s', release_download['name'])
|
||||
found_release = True
|
||||
break
|
||||
|
||||
if not found_release:
|
||||
log.info('%s not found in downloaders', nzbname)
|
||||
|
||||
#Check status if already missing and for how long, if > 1 week, set to ignored else to missing
|
||||
if rel.status_id == missing_status.get('id'):
|
||||
if rel.last_edit < int(time.time()) - 7 * 24 * 60 * 60:
|
||||
fireEvent('release.update_status', rel.id, status = ignored_status, single = True)
|
||||
else:
|
||||
# Set the release to missing
|
||||
fireEvent('release.update_status', rel.id, status = missing_status, single = True)
|
||||
|
||||
# Continue with next release
|
||||
continue
|
||||
|
||||
# Log that we found the release
|
||||
timeleft = 'N/A' if release_download['timeleft'] == -1 else release_download['timeleft']
|
||||
log.debug('Found %s: %s, time to go: %s', (release_download['name'], release_download['status'].upper(), timeleft))
|
||||
|
||||
# Check status of release
|
||||
if release_download['status'] == 'busy':
|
||||
# Set the release to snatched if it was missing before
|
||||
fireEvent('release.update_status', rel.id, status = snatched_status, single = True)
|
||||
|
||||
# Tag folder if it is in the 'from' folder and it will not be processed because it is still downloading
|
||||
if self.movieInFromFolder(release_download['folder']):
|
||||
self.tagRelease(release_download = release_download, tag = 'downloading')
|
||||
|
||||
elif release_download['status'] == 'seeding':
|
||||
#If linking setting is enabled, process release
|
||||
if self.conf('file_action') != 'move' and not rel.status_id == seeding_status.get('id') and self.statusInfoComplete(release_download):
|
||||
log.info('Download of %s completed! It is now being processed while leaving the original files alone for seeding. Current ratio: %s.', (release_download['name'], release_download['seed_ratio']))
|
||||
|
||||
# Remove the downloading tag
|
||||
self.untagRelease(release_download = release_download, tag = 'downloading')
|
||||
|
||||
# Scan and Allow the downloader to clean-up
|
||||
release_download.update({'pause': False, 'scan': True, 'process_complete': True})
|
||||
# Scan and set the torrent to paused if required
|
||||
release_download.update({'pause': True, 'scan': True, 'process_complete': False})
|
||||
scan_releases.append(release_download)
|
||||
else:
|
||||
scan_required = True
|
||||
else:
|
||||
#let it seed
|
||||
log.debug('%s is seeding with ratio: %s', (release_download['name'], release_download['seed_ratio']))
|
||||
|
||||
except:
|
||||
log.error('Failed checking for release in downloader: %s', traceback.format_exc())
|
||||
# Set the release to seeding
|
||||
fireEvent('release.update_status', rel.id, status = seeding_status, single = True)
|
||||
|
||||
# The following can either be done here, or inside the scanner if we pass it scan_items in one go
|
||||
for release_download in scan_releases:
|
||||
# Ask the renamer to scan the item
|
||||
if release_download['scan']:
|
||||
if release_download['pause'] and self.conf('file_action') == 'link':
|
||||
fireEvent('download.pause', release_download = release_download, pause = True, single = True)
|
||||
self.scan(release_download = release_download)
|
||||
if release_download['pause'] and self.conf('file_action') == 'link':
|
||||
fireEvent('download.pause', release_download = release_download, pause = False, single = True)
|
||||
if release_download['process_complete']:
|
||||
#First make sure the files were succesfully processed
|
||||
if not self.hastagRelease(release_download = release_download, tag = 'failed_rename'):
|
||||
# Remove the seeding tag if it exists
|
||||
self.untagRelease(release_download = release_download, tag = 'renamed_already')
|
||||
# Ask the downloader to process the item
|
||||
fireEvent('download.process_complete', release_download = release_download, single = True)
|
||||
elif release_download['status'] == 'failed':
|
||||
# Set the release to failed
|
||||
fireEvent('release.update_status', rel.id, status = failed_status, single = True)
|
||||
|
||||
if fire_scan and (scan_required or len(no_status_support) > 0):
|
||||
self.scan()
|
||||
fireEvent('download.remove_failed', release_download, single = True)
|
||||
|
||||
self.checking_snatched = False
|
||||
return True
|
||||
if self.conf('next_on_failed'):
|
||||
fireEvent('movie.searcher.try_next_release', media_id = rel.movie_id)
|
||||
|
||||
elif release_download['status'] == 'completed':
|
||||
log.info('Download of %s completed!', release_download['name'])
|
||||
|
||||
#Make sure the downloader sent over a path to look in
|
||||
if self.statusInfoComplete(release_download):
|
||||
|
||||
# If the release has been seeding, process now the seeding is done
|
||||
if rel.status_id == seeding_status.get('id'):
|
||||
if self.conf('file_action') != 'move':
|
||||
# Set the release to done as the movie has already been renamed
|
||||
fireEvent('release.update_status', rel.id, status = downloaded_status, single = True)
|
||||
|
||||
# Allow the downloader to clean-up
|
||||
release_download.update({'pause': False, 'scan': False, 'process_complete': True})
|
||||
scan_releases.append(release_download)
|
||||
else:
|
||||
# Scan and Allow the downloader to clean-up
|
||||
release_download.update({'pause': False, 'scan': True, 'process_complete': True})
|
||||
scan_releases.append(release_download)
|
||||
|
||||
else:
|
||||
# Set the release to snatched if it was missing before
|
||||
fireEvent('release.update_status', rel.id, status = snatched_status, single = True)
|
||||
|
||||
# Remove the downloading tag
|
||||
self.untagRelease(release_download = release_download, tag = 'downloading')
|
||||
|
||||
# Scan and Allow the downloader to clean-up
|
||||
release_download.update({'pause': False, 'scan': True, 'process_complete': True})
|
||||
scan_releases.append(release_download)
|
||||
else:
|
||||
scan_required = True
|
||||
|
||||
except:
|
||||
log.error('Failed checking for release in downloader: %s', traceback.format_exc())
|
||||
|
||||
# The following can either be done here, or inside the scanner if we pass it scan_items in one go
|
||||
for release_download in scan_releases:
|
||||
# Ask the renamer to scan the item
|
||||
if release_download['scan']:
|
||||
if release_download['pause'] and self.conf('file_action') == 'link':
|
||||
fireEvent('download.pause', release_download = release_download, pause = True, single = True)
|
||||
self.scan(release_download = release_download)
|
||||
if release_download['pause'] and self.conf('file_action') == 'link':
|
||||
fireEvent('download.pause', release_download = release_download, pause = False, single = True)
|
||||
if release_download['process_complete']:
|
||||
#First make sure the files were succesfully processed
|
||||
if not self.hastagRelease(release_download = release_download, tag = 'failed_rename'):
|
||||
# Remove the seeding tag if it exists
|
||||
self.untagRelease(release_download = release_download, tag = 'renamed_already')
|
||||
# Ask the downloader to process the item
|
||||
fireEvent('download.process_complete', release_download = release_download, single = True)
|
||||
|
||||
if fire_scan and (scan_required or len(no_status_support) > 0):
|
||||
self.scan()
|
||||
|
||||
self.checking_snatched = False
|
||||
return True
|
||||
finally:
|
||||
db.close()
|
||||
|
||||
def extendReleaseDownload(self, release_download):
|
||||
|
||||
@@ -1064,6 +1068,8 @@ Remove it if you want it to be renamed (again, or at least let it try again)
|
||||
if not rls:
|
||||
log.error('Download ID %s from downloader %s not found in releases', (release_download.get('id'), release_download.get('downloader')))
|
||||
|
||||
db.close()
|
||||
|
||||
if rls:
|
||||
|
||||
rls_dict = rls.to_dict({'info':{}})
|
||||
|
||||
@@ -441,6 +441,7 @@ class Scanner(Plugin):
|
||||
else:
|
||||
log.debug('Found no movies in the folder %s', folder)
|
||||
|
||||
db.close()
|
||||
return processed_movies
|
||||
|
||||
def getMetaData(self, group, folder = '', release_download = None):
|
||||
@@ -608,6 +609,7 @@ class Scanner(Plugin):
|
||||
break
|
||||
except:
|
||||
pass
|
||||
db.close()
|
||||
|
||||
# Search based on identifiers
|
||||
if not imdb_id:
|
||||
|
||||
@@ -55,7 +55,7 @@ class StatusPlugin(Plugin):
|
||||
db = get_session()
|
||||
status = db.query(Status).filter_by(id = id).first()
|
||||
status_dict = status.to_dict()
|
||||
#db.close()
|
||||
db.close()
|
||||
|
||||
return status_dict
|
||||
|
||||
@@ -73,6 +73,7 @@ class StatusPlugin(Plugin):
|
||||
# Update cache
|
||||
self.status_cached[status.identifier] = s
|
||||
|
||||
db.close()
|
||||
return temp
|
||||
|
||||
def get(self, identifiers):
|
||||
|
||||
@@ -41,6 +41,8 @@ class Subtitle(Plugin):
|
||||
# get subtitles for those files
|
||||
subliminal.list_subtitles(files, cache_dir = Env.get('cache_dir'), multi = True, languages = self.getLanguages(), services = self.services)
|
||||
|
||||
db.close()
|
||||
|
||||
def searchSingle(self, group):
|
||||
if self.isDisabled(): return
|
||||
|
||||
|
||||
@@ -104,6 +104,7 @@ class MovieResultModifier(Plugin):
|
||||
except:
|
||||
log.error('Tried getting more info on searched movies: %s', traceback.format_exc())
|
||||
|
||||
db.close()
|
||||
return temp
|
||||
|
||||
def checkLibrary(self, result):
|
||||
|
||||
@@ -216,6 +216,7 @@ class Settings(object):
|
||||
except:
|
||||
pass
|
||||
|
||||
db.close()
|
||||
return prop
|
||||
|
||||
def setProperty(self, identifier, value = ''):
|
||||
|
||||
Reference in New Issue
Block a user