Improved API to return better message/code on errors

pull/1934/head v1.1.1-beta.19
morpheus65535 2 years ago
parent 2c8a602aa7
commit c2c0cbda0b

@ -64,7 +64,7 @@ class EpisodesBlacklist(Resource):
.get_or_none()
if not episodeInfo:
return 'Episode not found', 500
return 'Episode not found', 404
media_path = episodeInfo['path']
subtitles_path = request.form.get('subtitles_path')

@ -22,7 +22,7 @@ class Episodes(Resource):
.order_by(TableEpisodes.season.desc(), TableEpisodes.episode.desc())\
.dicts()
else:
return "Series or Episode ID not provided", 400
return "Series or Episode ID not provided", 404
result = list(result)
for item in result:

@ -39,7 +39,7 @@ class EpisodesSubtitles(Resource):
.get_or_none()
if not episodeInfo:
return 'Episode not found', 500
return 'Episode not found', 404
title = episodeInfo['title']
episodePath = path_mappings.path_replace(episodeInfo['path'])
@ -98,7 +98,7 @@ class EpisodesSubtitles(Resource):
.get_or_none()
if not episodeInfo:
return 'Episode not found', 500
return 'Episode not found', 404
title = episodeInfo['title']
episodePath = path_mappings.path_replace(episodeInfo['path'])
@ -164,7 +164,7 @@ class EpisodesSubtitles(Resource):
.get_or_none()
if not episodeInfo:
return 'Episode not found', 500
return 'Episode not found', 404
episodePath = path_mappings.path_replace(episodeInfo['path'])

@ -60,7 +60,7 @@ class MoviesBlacklist(Resource):
data = TableMovies.select(TableMovies.path).where(TableMovies.radarrId == radarr_id).dicts().get_or_none()
if not data:
return 'Movie not found', 500
return 'Movie not found', 404
media_path = data['path']
subtitles_path = request.form.get('subtitles_path')

@ -49,7 +49,7 @@ class Movies(Resource):
try:
profileId = int(profileId)
except Exception:
return '', 400
return 'Languages profile not found', 404
TableMovies.update({
TableMovies.profileId: profileId
@ -79,4 +79,4 @@ class Movies(Resource):
wanted_search_missing_subtitles_movies()
return '', 204
return '', 400
return 'Unknown action', 400

@ -39,7 +39,7 @@ class MoviesSubtitles(Resource):
.get_or_none()
if not movieInfo:
return 'Movie not found', 500
return 'Movie not found', 404
moviePath = path_mappings.path_replace_movie(movieInfo['path'])
sceneName = movieInfo['sceneName'] or 'None'
@ -99,7 +99,7 @@ class MoviesSubtitles(Resource):
.get_or_none()
if not movieInfo:
return 'Movie not found', 500
return 'Movie not found', 404
moviePath = path_mappings.path_replace_movie(movieInfo['path'])
sceneName = movieInfo['sceneName'] or 'None'
@ -161,7 +161,7 @@ class MoviesSubtitles(Resource):
.get_or_none()
if not movieInfo:
return 'Movie not found', 500
return 'Movie not found', 404
moviePath = path_mappings.path_replace_movie(movieInfo['path'])

@ -50,4 +50,4 @@ class Providers(Resource):
reset_throttled_providers()
return '', 204
return '', 400
return 'Unknown action', 400

@ -30,7 +30,7 @@ class ProviderEpisodes(Resource):
.get_or_none()
if not episodeInfo:
return 'Episode not found', 500
return 'Episode not found', 404
title = episodeInfo['title']
episodePath = path_mappings.path_replace(episodeInfo['path'])
@ -58,7 +58,7 @@ class ProviderEpisodes(Resource):
.get_or_none()
if not episodeInfo:
return 'Episode not found', 500
return 'Episode not found', 404
title = episodeInfo['title']
episodePath = path_mappings.path_replace(episodeInfo['path'])

@ -31,7 +31,7 @@ class ProviderMovies(Resource):
.get_or_none()
if not movieInfo:
return 'Movie not found', 500
return 'Movie not found', 404
title = movieInfo['title']
moviePath = path_mappings.path_replace_movie(movieInfo['path'])
@ -58,7 +58,7 @@ class ProviderMovies(Resource):
.get_or_none()
if not movieInfo:
return 'Movie not found', 500
return 'Movie not found', 404
title = movieInfo['title']
moviePath = path_mappings.path_replace_movie(movieInfo['path'])

@ -75,7 +75,7 @@ class Series(Resource):
try:
profileId = int(profileId)
except Exception:
return '', 400
return 'Languages profile not found', 404
TableShows.update({
TableShows.profileId: profileId
@ -113,4 +113,4 @@ class Series(Resource):
wanted_search_missing_subtitles_series()
return '', 204
return '', 400
return 'Unknown action', 400

@ -37,14 +37,14 @@ class Subtitles(Resource):
.get_or_none()
if not metadata:
return 'Episode not found', 500
return 'Episode not found', 404
video_path = path_mappings.path_replace(metadata['path'])
else:
metadata = TableMovies.select(TableMovies.path).where(TableMovies.radarrId == id).dicts().get_or_none()
if not metadata:
return 'Movie not found', 500
return 'Movie not found', 404
video_path = path_mappings.path_replace_movie(metadata['path'])

@ -12,7 +12,7 @@ from utilities.helper import check_credentials
class SystemAccount(Resource):
def post(self):
if settings.auth.type != 'form':
return '', 405
return 'Unknown authentication type define in config.ini', 404
action = request.args.get('action')
if action == 'login':
@ -26,4 +26,4 @@ class SystemAccount(Resource):
gc.collect()
return '', 204
return '', 401
return 'Unknown action', 400

@ -26,7 +26,7 @@ class SystemBackups(Resource):
restored = prepare_restore(filename)
if restored:
return '', 204
return '', 501
return 'Filename not provided', 400
@authenticate
def delete(self):
@ -35,4 +35,4 @@ class SystemBackups(Resource):
deleted = delete_backup_file(filename)
if deleted:
return '', 204
return '', 501
return 'Filename not provided', 400

@ -39,7 +39,7 @@ class WebHooksPlex(Resource):
if len(splitted_id) == 2:
ids.append({splitted_id[0]: splitted_id[1]})
if not ids:
return '', 404
return 'No GUID found', 400
if media_type == 'episode':
try:
@ -53,7 +53,7 @@ class WebHooksPlex(Resource):
series_imdb_id = show_metadata_dict['props']['pageProps']['aboveTheFoldData']['series']['series']['id']
except Exception:
logging.debug('BAZARR is unable to get series IMDB id.')
return '', 404
return 'IMDB series ID not found', 404
else:
sonarrEpisodeId = TableEpisodes.select(TableEpisodes.sonarrEpisodeId) \
.join(TableShows, on=(TableEpisodes.sonarrSeriesId == TableShows.sonarrSeriesId)) \
@ -69,7 +69,8 @@ class WebHooksPlex(Resource):
try:
movie_imdb_id = [x['imdb'] for x in ids if 'imdb' in x][0]
except Exception:
return '', 404
logging.debug('BAZARR is unable to get movie IMDB id.')
return 'IMDB movie ID not found', 404
else:
radarrId = TableMovies.select(TableMovies.radarrId)\
.where(TableMovies.imdbId == movie_imdb_id)\

Loading…
Cancel
Save