Cleanup searcher and release checking

This commit is contained in:
Ruud
2013-10-13 13:44:26 +02:00
parent 43ef982d95
commit f4c4f013da
3 changed files with 9 additions and 14 deletions
+6 -11
View File
@@ -7,8 +7,8 @@ from couchpotato.core.logger import CPLog
from couchpotato.core.media._base.searcher.base import SearcherBase
from couchpotato.core.settings.model import Media, Release, ReleaseInfo
from couchpotato.environment import Env
from sqlalchemy.exc import InterfaceError
from inspect import ismethod, isfunction
from sqlalchemy.exc import InterfaceError
import datetime
import re
import time
@@ -64,7 +64,7 @@ class Searcher(SearcherBase):
if downloader_enabled:
snatched_status = fireEvent('status.get', 'snatched', single = True)
snatched_status, done_status, active_status = fireEvent('status.get', ['snatched', 'done', 'active'], single = True)
# Download movie to temp
filedata = None
@@ -84,9 +84,6 @@ class Searcher(SearcherBase):
if rls:
renamer_enabled = Env.setting('enabled', 'renamer')
done_status = fireEvent('status.get', 'done', single = True)
rls.status_id = done_status.get('id') if not renamer_enabled else snatched_status.get('id')
# Save download-id info if returned
if isinstance(download_result, dict):
for key in download_result:
@@ -104,8 +101,6 @@ class Searcher(SearcherBase):
# If renamer isn't used, mark movie done
if not renamer_enabled:
active_status = fireEvent('status.get', 'active', single = True)
done_status = fireEvent('status.get', 'done', single = True)
try:
if movie['status_id'] == active_status.get('id'):
for profile_type in movie['profile']['types']:
@@ -113,9 +108,7 @@ class Searcher(SearcherBase):
log.info('Renamer disabled, marking movie as finished: %s', log_movie)
# Mark release done
rls.status_id = done_status.get('id')
rls.last_edit = int(time.time())
db.commit()
fireEvent('release.update_status', rls.id, status = done_status, single = True)
# Mark movie done
mvie = db.query(Media).filter_by(id = movie['id']).first()
@@ -124,6 +117,8 @@ class Searcher(SearcherBase):
db.commit()
except:
log.error('Failed marking movie finished, renamer disabled: %s', traceback.format_exc())
else:
fireEvent('release.update_status', rls.id, status = snatched_status, single = True)
except:
log.error('Failed marking movie finished: %s', traceback.format_exc())
@@ -158,7 +153,7 @@ class Searcher(SearcherBase):
def createReleases(self, search_results, media, quality_type):
available_status, ignored_status, failed_status = fireEvent('status.get', ['available', 'ignored', 'failed'], single = True)
available_status = fireEvent('status.get', ['available'], single = True)
db = get_session()
found_releases = []
@@ -117,7 +117,7 @@ class MovieSearcher(SearcherBase, MovieTypeBase):
def single(self, movie, search_protocols = None, manual = False):
# movies don't contain 'type' yet, so just set to default here
if 'type' not in movie:
if not movie.has_key('type'):
movie['type'] = 'movie'
# Find out search type
@@ -170,7 +170,7 @@ class MovieSearcher(SearcherBase, MovieTypeBase):
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('searcher.search', search_protocols, movie, quality, single = True)
results = fireEvent('searcher.search', search_protocols, movie, quality, single = True) or []
if len(results) == 0:
log.debug('Nothing found for %s in %s', (default_title, quality_type['quality']['label']))
+1 -1
View File
@@ -134,7 +134,7 @@ class Renamer(Plugin):
cleanup = self.conf('cleanup') and not self.downloadIsTorrent(download_info))
groups = fireEvent('scanner.scan', folder = folder if folder else self.conf('from'),
files = files, download_info = download_info, return_ignored = False, single = True)
files = files, download_info = download_info, return_ignored = False, single = True) or []
folder_name = self.conf('folder_name')
file_name = self.conf('file_name')