Browse Source

Renamed 'movie' -> 'media' in 'searcher.download'

pull/2356/head
Dean Gardiner 12 years ago
parent
commit
32c289fd3d
  1. 39
      couchpotato/core/media/_base/searcher/main.py
  2. 2
      couchpotato/core/plugins/release/main.py

39
couchpotato/core/media/_base/searcher/main.py

@ -70,7 +70,7 @@ class Searcher(SearcherBase):
log.info('Ignored, score to low: %s', rel['name']) log.info('Ignored, score to low: %s', rel['name'])
continue continue
downloaded = fireEvent('searcher.download', data = rel, movie = media, manual = manual, single = True) downloaded = fireEvent('searcher.download', data = rel, media = media, manual = manual, single = True)
if downloaded is True: if downloaded is True:
return True return True
elif downloaded != 'try_next': elif downloaded != 'try_next':
@ -78,11 +78,12 @@ class Searcher(SearcherBase):
return False return False
def download(self, data, movie, manual = False): def download(self, data, media, manual = False):
if not data.get('protocol'): # TODO what is this for?
data['protocol'] = data['type'] #if not data.get('protocol'):
data['type'] = 'movie' # data['protocol'] = data['type']
# data['type'] = 'movie'
# Test to see if any downloaders are enabled for this type # Test to see if any downloaders are enabled for this type
downloader_enabled = fireEvent('download.enabled', manual, data, single = True) downloader_enabled = fireEvent('download.enabled', manual, data, single = True)
@ -91,14 +92,14 @@ class Searcher(SearcherBase):
snatched_status = fireEvent('status.get', 'snatched', single = True) snatched_status = fireEvent('status.get', 'snatched', single = True)
# Download movie to temp # Download release to temp
filedata = None filedata = None
if data.get('download') and (ismethod(data.get('download')) or isfunction(data.get('download'))): if data.get('download') and (ismethod(data.get('download')) or isfunction(data.get('download'))):
filedata = data.get('download')(url = data.get('url'), nzb_id = data.get('id')) filedata = data.get('download')(url = data.get('url'), nzb_id = data.get('id'))
if filedata == 'try_next': if filedata == 'try_next':
return filedata return filedata
download_result = fireEvent('download', data = data, movie = movie, manual = manual, filedata = filedata, single = True) download_result = fireEvent('download', data = data, movie = media, manual = manual, filedata = filedata, single = True)
log.debug('Downloader result: %s', download_result) log.debug('Downloader result: %s', download_result)
if download_result: if download_result:
@ -122,36 +123,36 @@ class Searcher(SearcherBase):
rls.info.append(rls_info) rls.info.append(rls_info)
db.commit() db.commit()
log_movie = '%s (%s) in %s' % (getTitle(movie['library']), movie['library']['year'], rls.quality.label) log_movie = '%s (%s) in %s' % (getTitle(media['library']), media['library']['year'], rls.quality.label)
snatch_message = 'Snatched "%s": %s' % (data.get('name'), log_movie) snatch_message = 'Snatched "%s": %s' % (data.get('name'), log_movie)
log.info(snatch_message) log.info(snatch_message)
fireEvent('movie.snatched', message = snatch_message, data = rls.to_dict()) fireEvent('%s.snatched' % data['type'], message = snatch_message, data = rls.to_dict())
# If renamer isn't used, mark movie done # If renamer isn't used, mark media done
if not renamer_enabled: if not renamer_enabled:
active_status = fireEvent('status.get', 'active', single = True) active_status = fireEvent('status.get', 'active', single = True)
done_status = fireEvent('status.get', 'done', single = True) done_status = fireEvent('status.get', 'done', single = True)
try: try:
if movie['status_id'] == active_status.get('id'): if media['status_id'] == active_status.get('id'):
for profile_type in movie['profile']['types']: for profile_type in media['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 media 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')
rls.last_edit = int(time.time()) rls.last_edit = int(time.time())
db.commit() db.commit()
# Mark movie done # Mark media done
mvie = db.query(Media).filter_by(id = movie['id']).first() mdia = db.query(Media).filter_by(id = media['id']).first()
mvie.status_id = done_status.get('id') mdia.status_id = done_status.get('id')
mvie.last_edit = int(time.time()) mdia.last_edit = int(time.time())
db.commit() db.commit()
except: except:
log.error('Failed marking movie finished, renamer disabled: %s', traceback.format_exc()) log.error('Failed marking media finished, renamer disabled: %s', traceback.format_exc())
except: except:
log.error('Failed marking movie finished: %s', traceback.format_exc()) log.error('Failed marking media finished: %s', traceback.format_exc())
return True return True

2
couchpotato/core/plugins/release/main.py

@ -191,7 +191,7 @@ class Release(Plugin):
if item.get('protocol') != 'torrent_magnet': if item.get('protocol') != 'torrent_magnet':
item['download'] = provider.loginDownload if provider.urls.get('login') else provider.download item['download'] = provider.loginDownload if provider.urls.get('login') else provider.download
success = fireEvent('searcher.download', data = item, movie = rel.media.to_dict({ success = fireEvent('searcher.download', data = item, media = rel.media.to_dict({
'profile': {'types': {'quality': {}}}, 'profile': {'types': {'quality': {}}},
'releases': {'status': {}, 'quality': {}}, 'releases': {'status': {}, 'quality': {}},
'library': {'titles': {}, 'files':{}}, 'library': {'titles': {}, 'files':{}},

Loading…
Cancel
Save