Added more feedback to UI on automatic and interactive search issues.

This commit is contained in:
morpheus65535 2023-09-06 23:12:58 -04:00
parent 296d497673
commit fbe6b765ae
5 changed files with 39 additions and 27 deletions

View File

@ -38,7 +38,7 @@ class EpisodesSubtitles(Resource):
@api_ns_episodes_subtitles.response(401, 'Not Authenticated')
@api_ns_episodes_subtitles.response(404, 'Episode not found')
@api_ns_episodes_subtitles.response(409, 'Unable to save subtitles file. Permission or path mapping issue?')
@api_ns_episodes_subtitles.response(500, 'Episode file not found. Path mapping issue?')
@api_ns_episodes_subtitles.response(500, 'Custom error messages')
def patch(self):
"""Download an episode subtitles"""
args = self.patch_request_parser.parse_args()
@ -79,13 +79,14 @@ class EpisodesSubtitles(Resource):
try:
result = list(generate_subtitles(episodePath, [(language, hi, forced)], audio_language, sceneName,
title, 'series', profile_id=get_profile_id(episode_id=sonarrEpisodeId)))
if result:
if isinstance(result, list) and len(result):
result = result[0]
history_log(1, sonarrSeriesId, sonarrEpisodeId, result)
send_notifications(sonarrSeriesId, sonarrEpisodeId, result.message)
store_subtitles(result.path, episodePath)
else:
event_stream(type='episode', payload=sonarrEpisodeId)
return 'No subtitles found', 500
except OSError:
return 'Unable to save subtitles file. Permission or path mapping issue?', 409
else:

View File

@ -37,7 +37,7 @@ class MoviesSubtitles(Resource):
@api_ns_movies_subtitles.response(401, 'Not Authenticated')
@api_ns_movies_subtitles.response(404, 'Movie not found')
@api_ns_movies_subtitles.response(409, 'Unable to save subtitles file. Permission or path mapping issue?')
@api_ns_movies_subtitles.response(500, 'Movie file not found. Path mapping issue?')
@api_ns_movies_subtitles.response(500, 'Custom error messages')
def patch(self):
"""Download a movie subtitles"""
args = self.patch_request_parser.parse_args()
@ -77,12 +77,13 @@ class MoviesSubtitles(Resource):
try:
result = list(generate_subtitles(moviePath, [(language, hi, forced)], audio_language,
sceneName, title, 'movie', profile_id=get_profile_id(movie_id=radarrId)))
if result:
if isinstance(result, list) and len(result):
result = result[0]
history_log_movie(1, radarrId, result)
store_subtitles_movie(result.path, moviePath)
else:
event_stream(type='movie', payload=radarrId)
return 'No subtitles found', 500
except OSError:
return 'Unable to save subtitles file. Permission or path mapping issue?', 409
else:

View File

@ -12,6 +12,7 @@ from sonarr.history import history_log
from app.config import settings
from app.notifier import send_notifications
from subtitles.indexer.series import store_subtitles
from subtitles.processing import ProcessSubtitlesResult
from ..utils import authenticate
@ -43,7 +44,7 @@ class ProviderEpisodes(Resource):
@authenticate
@api_ns_providers_episodes.response(401, 'Not Authenticated')
@api_ns_providers_episodes.response(404, 'Episode not found')
@api_ns_providers_episodes.response(500, 'Episode file not found. Path mapping issue?')
@api_ns_providers_episodes.response(500, 'Custom error messages')
@api_ns_providers_episodes.doc(parser=get_request_parser)
def get(self):
"""Search manually for an episode subtitles"""
@ -74,8 +75,8 @@ class ProviderEpisodes(Resource):
providers_list = get_providers()
data = manual_search(episodePath, profileId, providers_list, sceneName, title, 'series')
if not data:
data = []
if isinstance(data, str):
return data, 500
return marshal(data, self.get_response_model, envelope='data')
post_request_parser = reqparse.RequestParser()
@ -93,6 +94,7 @@ class ProviderEpisodes(Resource):
@api_ns_providers_episodes.response(204, 'Success')
@api_ns_providers_episodes.response(401, 'Not Authenticated')
@api_ns_providers_episodes.response(404, 'Episode not found')
@api_ns_providers_episodes.response(500, 'Custom error messages')
def post(self):
"""Manually download an episode subtitles"""
args = self.post_request_parser.parse_args()
@ -132,12 +134,15 @@ class ProviderEpisodes(Resource):
result = manual_download_subtitle(episodePath, audio_language, hi, forced, subtitle, selected_provider,
sceneName, title, 'series', use_original_format,
profile_id=get_profile_id(episode_id=sonarrEpisodeId))
if result:
except OSError:
return 'Unable to save subtitles file', 500
else:
if isinstance(result, ProcessSubtitlesResult):
history_log(2, sonarrSeriesId, sonarrEpisodeId, result)
if not settings.general.getboolean('dont_notify_manual_actions'):
send_notifications(sonarrSeriesId, sonarrEpisodeId, result.message)
store_subtitles(result.path, episodePath)
except OSError:
pass
return '', 204
elif isinstance(result, str):
return result, 500
else:
return '', 204

View File

@ -12,6 +12,7 @@ from radarr.history import history_log_movie
from app.config import settings
from app.notifier import send_notifications_movie
from subtitles.indexer.movies import store_subtitles_movie
from subtitles.processing import ProcessSubtitlesResult
from ..utils import authenticate
@ -44,7 +45,7 @@ class ProviderMovies(Resource):
@authenticate
@api_ns_providers_movies.response(401, 'Not Authenticated')
@api_ns_providers_movies.response(404, 'Movie not found')
@api_ns_providers_movies.response(500, 'Movie file not found. Path mapping issue?')
@api_ns_providers_movies.response(500, 'Custom error messages')
@api_ns_providers_movies.doc(parser=get_request_parser)
def get(self):
"""Search manually for a movie subtitles"""
@ -73,8 +74,8 @@ class ProviderMovies(Resource):
providers_list = get_providers()
data = manual_search(moviePath, profileId, providers_list, sceneName, title, 'movie')
if not data:
data = []
if isinstance(data, str):
return data, 500
return marshal(data, self.get_response_model, envelope='data')
post_request_parser = reqparse.RequestParser()
@ -91,6 +92,7 @@ class ProviderMovies(Resource):
@api_ns_providers_movies.response(204, 'Success')
@api_ns_providers_movies.response(401, 'Not Authenticated')
@api_ns_providers_movies.response(404, 'Movie not found')
@api_ns_providers_movies.response(500, 'Custom error messages')
def post(self):
"""Manually download a movie subtitles"""
args = self.post_request_parser.parse_args()
@ -126,12 +128,15 @@ class ProviderMovies(Resource):
result = manual_download_subtitle(moviePath, audio_language, hi, forced, subtitle, selected_provider,
sceneName, title, 'movie', use_original_format,
profile_id=get_profile_id(movie_id=radarrId))
if result is not None:
except OSError:
return 'Unable to save subtitles file', 500
else:
if isinstance(result, ProcessSubtitlesResult):
history_log_movie(2, radarrId, result)
if not settings.general.getboolean('dont_notify_manual_actions'):
send_notifications_movie(radarrId, result.message)
store_subtitles_movie(result.path, moviePath)
except OSError:
pass
return '', 204
elif isinstance(result, str):
return result, 500
else:
return '', 204

View File

@ -41,7 +41,7 @@ def manual_search(path, profile_id, providers, sceneName, title, media_type):
video = get_video(force_unicode(path), title, sceneName, providers=providers, media_type=media_type)
else:
logging.info("BAZARR All providers are throttled")
return None
return 'All providers are throttled'
if video:
try:
if providers:
@ -62,7 +62,7 @@ def manual_search(path, profile_id, providers, sceneName, title, media_type):
else:
subtitles = []
logging.info("BAZARR All providers are throttled")
return None
return 'All providers are throttled'
except Exception:
logging.exception("BAZARR Error trying to get Subtitle list from provider for this file: " + path)
else:
@ -183,14 +183,14 @@ def manual_download_subtitle(path, audio_language, hi, forced, subtitle, provide
logging.debug('BAZARR Subtitles file downloaded for this file:' + path)
else:
logging.info("BAZARR All providers are throttled")
return None
return 'All providers are throttled'
except Exception:
logging.exception('BAZARR Error downloading Subtitles for this file ' + path)
return None
return 'Error downloading Subtitles'
else:
if not subtitle.is_valid():
logging.exception('BAZARR No valid Subtitles file found for this file: ' + path)
return
return 'No valid Subtitles file found'
try:
chmod = int(settings.general.chmod, 8) if not sys.platform.startswith(
'win') and settings.general.getboolean('chmod_enabled') else None
@ -203,7 +203,7 @@ def manual_download_subtitle(path, audio_language, hi, forced, subtitle, provide
path_decoder=force_unicode)
except Exception:
logging.exception('BAZARR Error saving Subtitles file to disk for this file:' + path)
return
return 'Error saving Subtitles file to disk'
else:
if saved_subtitles:
_, max_score, _ = _get_scores(media_type)
@ -221,7 +221,7 @@ def manual_download_subtitle(path, audio_language, hi, forced, subtitle, provide
"BAZARR Tried to manually download a Subtitles for file: " + path
+ " but we weren't able to do (probably throttled by " + str(subtitle.provider_name)
+ ". Please retry later or select a Subtitles from another provider.")
return None
return 'Something went wrong, check the logs for error'
subliminal.region.backend.sync()