From fca858c6692fc91df25e4ed29d30b755b929bbe5 Mon Sep 17 00:00:00 2001 From: panni Date: Thu, 29 Nov 2018 12:20:39 +0100 Subject: [PATCH] manual_search: implement hints, use full parsing with sceneName --- bazarr/get_subtitle.py | 15 ++++++++++----- bazarr/main.py | 6 ++++-- views/episodes.tpl | 3 ++- views/movie.tpl | 3 ++- 4 files changed, 18 insertions(+), 9 deletions(-) diff --git a/bazarr/get_subtitle.py b/bazarr/get_subtitle.py index 1533366a7..e002d0dce 100644 --- a/bazarr/get_subtitle.py +++ b/bazarr/get_subtitle.py @@ -280,7 +280,7 @@ def download_subtitle(path, language, hi, providers, providers_auth, sceneName, logging.debug('BAZARR Ended searching subtitles for file: ' + path) -def manual_search(path, language, hi, providers, providers_auth, sceneName, media_type): +def manual_search(path, language, hi, providers, providers_auth, sceneName, title, media_type): logging.debug('BAZARR Manually searching subtitles for this file: ' + path) final_subtitles = [] @@ -301,11 +301,16 @@ def manual_search(path, language, hi, providers, providers_auth, sceneName, medi use_postprocessing = get_general_settings()[10] postprocessing_cmd = get_general_settings()[11] + hints = {"title": title} + dont_use_actual_file = False + if sceneName != "None" and use_scenename: + # use the sceneName but keep the folder structure for better guessing + path = os.path.join(os.path.dirname(path), sceneName + os.path.splitext(path)[1]) + dont_use_actual_file = True + try: - if sceneName == "None" or not use_scenename: - video = parse_video(path, None, providers=providers) - else: - video = Video.fromname(sceneName) + video = parse_video(path, hints=hints, providers=providers, dry_run=dont_use_actual_file) + except: logging.exception("BAZARR Error trying to get video information for this file: " + path) else: diff --git a/bazarr/main.py b/bazarr/main.py index a863bcd20..5807af562 100644 --- a/bazarr/main.py +++ b/bazarr/main.py @@ -1650,11 +1650,12 @@ def manual_search_json(): sceneName = request.forms.get('sceneName') language = request.forms.get('language') hi = request.forms.get('hi') + title = request.forms.get('title') providers_list = get_providers() providers_auth = get_providers_auth() - data = manual_search(episodePath, language, hi, providers_list, providers_auth, sceneName, 'series') + data = manual_search(episodePath, language, hi, providers_list, providers_auth, sceneName, title, 'series') return dict(data=data) @@ -1727,11 +1728,12 @@ def manual_search_movie_json(): sceneName = request.forms.get('sceneName') language = request.forms.get('language') hi = request.forms.get('hi') + title = request.forms.get('title') providers_list = get_providers() providers_auth = get_providers_auth() - data = manual_search(moviePath, language, hi, providers_list, providers_auth, sceneName, 'movie') + data = manual_search(moviePath, language, hi, providers_list, providers_auth, sceneName, title, 'movie') return dict(data=data) diff --git a/views/episodes.tpl b/views/episodes.tpl index 8e11f50fe..e560b5891 100644 --- a/views/episodes.tpl +++ b/views/episodes.tpl @@ -473,7 +473,8 @@ language: language, hi: hi, sonarrSeriesId: sonarrSeriesId, - sonarrEpisodeId: sonarrEpisodeId + sonarrEpisodeId: sonarrEpisodeId, + title: $(this).data("series_title") }; $('#search_result').DataTable( { diff --git a/views/movie.tpl b/views/movie.tpl index de6e07957..daba0924d 100644 --- a/views/movie.tpl +++ b/views/movie.tpl @@ -416,7 +416,8 @@ sceneName: sceneName, language: language, hi: hi, - radarrId: radarrId + radarrId: radarrId, + title: $(this).data("movie_title") }; $('#search_result').DataTable( {