diff --git a/bazarr/api.py b/bazarr/api.py index 07c73d77e..55659871a 100644 --- a/bazarr/api.py +++ b/bazarr/api.py @@ -37,7 +37,7 @@ from scheduler import scheduler from subsyncer import subsync from filesystem import browse_bazarr_filesystem, browse_sonarr_filesystem, browse_radarr_filesystem -from subliminal_patch.core import SUBTITLE_EXTENSIONS +from subliminal_patch.core import SUBTITLE_EXTENSIONS, guessit from flask import Flask, jsonify, request, Response, Blueprint, url_for, make_response @@ -549,6 +549,19 @@ class Episodes(Resource): item.update({"desired_languages": desired_languages}) return jsonify(draw=draw, recordsTotal=row_count, recordsFiltered=row_count, data=result) +class SubtitleNameInfo(Resource): + @authenticate + def get(self): + name = request.args.get('filename') + if name is not None: + opts = dict() + opts['type'] = 'episode' + result = guessit(name, options=opts) + if 'subtitle_language' in result: + result['subtitle_language'] = str(result['subtitle_language']) + return jsonify(data=result) + else: + return '', 400 class EpisodesSubtitlesDelete(Resource): @authenticate @@ -1990,6 +2003,8 @@ api.add_resource(SystemProviders, '/systemproviders') api.add_resource(SystemStatus, '/systemstatus') api.add_resource(SystemReleases, '/systemreleases') +api.add_resource(SubtitleNameInfo, '/subtitle_name_info') + api.add_resource(Series, '/series') api.add_resource(SeriesEditor, '/series_editor') api.add_resource(SeriesEditSave, '/series_edit_save') diff --git a/views/episodes.html b/views/episodes.html index c0c1e9a88..ddbc89844 100644 --- a/views/episodes.html +++ b/views/episodes.html @@ -62,6 +62,10 @@ {% block bcright %}
+
+ +