Renamed Release.movie references to Release.media
This commit is contained in:
1 parent
6bcb279f0e
commit
4eb73e3609
3 files changed
+9
-35
No files matched your search
@@ -24,7 +24,6 @@ class Searcher(SearcherBase):
|
|||||||
addEvent('searcher.correct_year', self.correctYear)
|
addEvent('searcher.correct_year', self.correctYear)
|
||||||
addEvent('searcher.correct_name', self.correctName)
|
addEvent('searcher.correct_name', self.correctName)
|
||||||
addEvent('searcher.correct_words', self.correctWords)
|
addEvent('searcher.correct_words', self.correctWords)
|
||||||
addEvent('searcher.try_download_result', self.tryDownloadResult)
|
|
||||||
addEvent('searcher.download', self.download)
|
addEvent('searcher.download', self.download)
|
||||||
addEvent('searcher.search', self.search)
|
addEvent('searcher.search', self.search)
|
||||||
|
|
||||||
@@ -52,30 +51,6 @@ class Searcher(SearcherBase):
|
|||||||
progress = fireEvent('searcher.progress', merge = True)
|
progress = fireEvent('searcher.progress', merge = True)
|
||||||
return progress
|
return progress
|
||||||
|
|
||||||
def tryDownloadResult(self, results, media, quality_type, manual = False):
|
|
||||||
ignored_status, failed_status = fireEvent('status.get', ['ignored', 'failed'], single = True)
|
|
||||||
|
|
||||||
for rel in results:
|
|
||||||
if not quality_type.get('finish', False) and quality_type.get('wait_for', 0) > 0 and rel.get('age') <= quality_type.get('wait_for', 0):
|
|
||||||
log.info('Ignored, waiting %s days: %s', (quality_type.get('wait_for'), rel['name']))
|
|
||||||
continue
|
|
||||||
|
|
||||||
if rel['status_id'] in [ignored_status.get('id'), failed_status.get('id')]:
|
|
||||||
log.info('Ignored: %s', rel['name'])
|
|
||||||
continue
|
|
||||||
|
|
||||||
if rel['score'] <= 0:
|
|
||||||
log.info('Ignored, score to low: %s', rel['name'])
|
|
||||||
continue
|
|
||||||
|
|
||||||
downloaded = fireEvent('searcher.download', data = rel, media = media, manual = manual, single = True)
|
|
||||||
if downloaded is True:
|
|
||||||
return True
|
|
||||||
elif downloaded != 'try_next':
|
|
||||||
break
|
|
||||||
|
|
||||||
return False
|
|
||||||
|
|
||||||
def download(self, data, media, manual = False):
|
def download(self, data, media, manual = False):
|
||||||
|
|
||||||
# TODO what is this for?
|
# TODO what is this for?
|
||||||
|
|||||||
@@ -108,7 +108,7 @@ class ShowSearcher(Plugin):
|
|||||||
found_releases += fireEvent('release.create_from_search', results, media, quality_type, single = True)
|
found_releases += fireEvent('release.create_from_search', results, media, quality_type, single = True)
|
||||||
|
|
||||||
# Try find a valid result and download it
|
# Try find a valid result and download it
|
||||||
if fireEvent('searcher.try_download_result', results, media, quality_type, manual, single = True):
|
if fireEvent('release.try_download_result', results, media, quality_type, manual, single = True):
|
||||||
ret = True
|
ret = True
|
||||||
|
|
||||||
# Remove releases that aren't found anymore
|
# Remove releases that aren't found anymore
|
||||||
|
|||||||
@@ -100,14 +100,14 @@ class Release(Plugin):
|
|||||||
done_status, snatched_status = fireEvent('status.get', ['done', 'snatched'], single = True)
|
done_status, snatched_status = fireEvent('status.get', ['done', 'snatched'], single = True)
|
||||||
|
|
||||||
# Add movie
|
# Add movie
|
||||||
movie = db.query(Media).filter_by(library_id = group['library'].get('id')).first()
|
media = db.query(Media).filter_by(library_id = group['library'].get('id')).first()
|
||||||
if not movie:
|
if not media:
|
||||||
movie = Media(
|
media = Media(
|
||||||
library_id = group['library'].get('id'),
|
library_id = group['library'].get('id'),
|
||||||
profile_id = 0,
|
profile_id = 0,
|
||||||
status_id = done_status.get('id')
|
status_id = done_status.get('id')
|
||||||
)
|
)
|
||||||
db.add(movie)
|
db.add(media)
|
||||||
db.commit()
|
db.commit()
|
||||||
|
|
||||||
# Add Release
|
# Add Release
|
||||||
@@ -120,7 +120,7 @@ class Release(Plugin):
|
|||||||
if not rel:
|
if not rel:
|
||||||
rel = Relea(
|
rel = Relea(
|
||||||
identifier = identifier,
|
identifier = identifier,
|
||||||
movie = movie,
|
media = media,
|
||||||
quality_id = group['meta_data']['quality'].get('id'),
|
quality_id = group['meta_data']['quality'].get('id'),
|
||||||
status_id = done_status.get('id')
|
status_id = done_status.get('id')
|
||||||
)
|
)
|
||||||
@@ -142,7 +142,7 @@ class Release(Plugin):
|
|||||||
except:
|
except:
|
||||||
log.debug('Failed to attach "%s" to release: %s', (added_files, traceback.format_exc()))
|
log.debug('Failed to attach "%s" to release: %s', (added_files, traceback.format_exc()))
|
||||||
|
|
||||||
fireEvent('movie.restatus', movie.id)
|
fireEvent('movie.restatus', media.id)
|
||||||
|
|
||||||
return True
|
return True
|
||||||
|
|
||||||
@@ -228,7 +228,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 = self.download(data = item, media = rel.movie.to_dict({
|
success = self.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':{}},
|
||||||
@@ -365,8 +365,7 @@ class Release(Plugin):
|
|||||||
if not rls:
|
if not rls:
|
||||||
rls = Relea(
|
rls = Relea(
|
||||||
identifier = rel_identifier,
|
identifier = rel_identifier,
|
||||||
movie_id = media.get('id'),
|
media_id = media.get('id'),
|
||||||
#media_id = media.get('id'),
|
|
||||||
quality_id = quality_type.get('quality_id'),
|
quality_id = quality_type.get('quality_id'),
|
||||||
status_id = available_status.get('id')
|
status_id = available_status.get('id')
|
||||||
)
|
)
|
||||||
|
|||||||
Reference in new issue
Block a user