Your ROOT_URL in app.ini is https://git.cloudchain.link/ but you are visiting https://dash.bss.nz/open-source-mirrors/bazarr/commit/0fac16c4327bc4f5689d1091fd68806ebaab8e7e?style=split&whitespace=ignore-eol You should set ROOT_URL correctly, otherwise the web may not work correctly.

Add exception logging for compute_score().

pull/222/head
Louis Vézina 6 years ago
parent 3a0ca513d9
commit 0fac16c432

@ -65,97 +65,102 @@ def download_subtitle(path, language, hi, providers, providers_auth, sceneName,
logging.exception("BAZARR Error trying to get subtitle list from provider for this file: " + path) logging.exception("BAZARR Error trying to get subtitle list from provider for this file: " + path)
else: else:
subtitles_list = [] subtitles_list = []
sorted_subtitles = sorted([(s, compute_score(s, video, hearing_impaired=hi)) for s in subtitles], key=operator.itemgetter(1), reverse=True) try:
for s, preliminary_score in sorted_subtitles: sorted_subtitles = sorted([(s, compute_score(s, video, hearing_impaired=hi)) for s in subtitles], key=operator.itemgetter(1), reverse=True)
if media_type == "movie": except Exception as e:
if (preliminary_score / max_score * 100) < int(minimum_score_movie): logging.exception('BAZARR Exception raised while trying to compute score for this file: ' + path)
continue return None
matched = set(s.get_matches(video)) else:
if hi == s.hearing_impaired: for s, preliminary_score in sorted_subtitles:
matched.add('hearing_impaired') if media_type == "movie":
not_matched = set(score.movie_scores.keys()) - matched if (preliminary_score / max_score * 100) < int(minimum_score_movie):
required = set(['title']) continue
if any(elem in required for elem in not_matched): matched = set(s.get_matches(video))
continue if hi == s.hearing_impaired:
elif media_type == "series": matched.add('hearing_impaired')
if (preliminary_score / max_score * 100) < int(minimum_score): not_matched = set(score.movie_scores.keys()) - matched
continue required = set(['title'])
matched = set(s.get_matches(video)) if any(elem in required for elem in not_matched):
if hi == s.hearing_impaired: continue
matched.add('hearing_impaired') elif media_type == "series":
not_matched = set(score.episode_scores.keys()) - matched if (preliminary_score / max_score * 100) < int(minimum_score):
required = set(['series', 'season', 'episode']) continue
if any(elem in required for elem in not_matched): matched = set(s.get_matches(video))
continue if hi == s.hearing_impaired:
subtitles_list.append(s) matched.add('hearing_impaired')
logging.debug('BAZARR ' + str(len(subtitles_list)) + " subtitles have been found for this file: " + path) not_matched = set(score.episode_scores.keys()) - matched
if len(subtitles_list) > 0: required = set(['series', 'season', 'episode'])
try: if any(elem in required for elem in not_matched):
best_subtitle = subtitles_list[0] continue
download_subtitles([best_subtitle], providers=providers, provider_configs=providers_auth) subtitles_list.append(s)
logging.debug('BAZARR Subtitles file downloaded for this file:' + path) logging.debug('BAZARR ' + str(len(subtitles_list)) + " subtitles have been found for this file: " + path)
except Exception as e: if len(subtitles_list) > 0:
logging.exception('BAZARR Error downloading subtitles for this file ' + path)
return None
else:
try: try:
calculated_score = round(float(compute_score(best_subtitle, video, hearing_impaired=hi)) / max_score * 100, 2) best_subtitle = subtitles_list[0]
if used_sceneName == True: download_subtitles([best_subtitle], providers=providers, provider_configs=providers_auth)
video = scan_video(path) logging.debug('BAZARR Subtitles file downloaded for this file:' + path)
single = get_general_settings()[7]
if single is True:
result = save_subtitles(video, [best_subtitle], single=True, encoding='utf-8')
else:
result = save_subtitles(video, [best_subtitle], encoding='utf-8')
except Exception as e: except Exception as e:
logging.exception('BAZARR Error saving subtitles file to disk for this file:' + path) logging.exception('BAZARR Error downloading subtitles for this file ' + path)
pass return None
else: else:
if len(result) > 0: try:
downloaded_provider = result[0].provider_name calculated_score = round(float(compute_score(best_subtitle, video, hearing_impaired=hi)) / max_score * 100, 2)
downloaded_language = language_from_alpha3(result[0].language.alpha3)
downloaded_language_code2 = alpha2_from_alpha3(result[0].language.alpha3)
downloaded_language_code3 = result[0].language.alpha3
downloaded_path = get_subtitle_path(path, language=language_set)
logging.debug('BAZARR Subtitles file saved to disk: ' + downloaded_path)
if used_sceneName == True: if used_sceneName == True:
message = downloaded_language + " subtitles downloaded from " + downloaded_provider + " with a score of " + unicode(calculated_score) + "% using this scene name: " + sceneName video = scan_video(path)
single = get_general_settings()[7]
if single is True:
result = save_subtitles(video, [best_subtitle], single=True, encoding='utf-8')
else: else:
message = downloaded_language + " subtitles downloaded from " + downloaded_provider + " with a score of " + unicode(calculated_score) + "% using filename guessing." result = save_subtitles(video, [best_subtitle], encoding='utf-8')
except Exception as e:
if use_postprocessing is True: logging.exception('BAZARR Error saving subtitles file to disk for this file:' + path)
command = pp_replace(postprocessing_cmd, path, downloaded_path, downloaded_language, downloaded_language_code2, downloaded_language_code3) pass
try: else:
if os.name == 'nt': if len(result) > 0:
codepage = subprocess.Popen("chcp", shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE) downloaded_provider = result[0].provider_name
downloaded_language = language_from_alpha3(result[0].language.alpha3)
downloaded_language_code2 = alpha2_from_alpha3(result[0].language.alpha3)
downloaded_language_code3 = result[0].language.alpha3
downloaded_path = get_subtitle_path(path, language=language_set)
logging.debug('BAZARR Subtitles file saved to disk: ' + downloaded_path)
if used_sceneName == True:
message = downloaded_language + " subtitles downloaded from " + downloaded_provider + " with a score of " + unicode(calculated_score) + "% using this scene name: " + sceneName
else:
message = downloaded_language + " subtitles downloaded from " + downloaded_provider + " with a score of " + unicode(calculated_score) + "% using filename guessing."
if use_postprocessing is True:
command = pp_replace(postprocessing_cmd, path, downloaded_path, downloaded_language, downloaded_language_code2, downloaded_language_code3)
try:
if os.name == 'nt':
codepage = subprocess.Popen("chcp", shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
# wait for the process to terminate
out_codepage, err_codepage = codepage.communicate()
encoding = out_codepage.split(':')[-1].strip()
process = subprocess.Popen(command, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
# wait for the process to terminate # wait for the process to terminate
out_codepage, err_codepage = codepage.communicate() out, err = process.communicate()
encoding = out_codepage.split(':')[-1].strip()
process = subprocess.Popen(command, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE) if os.name == 'nt':
# wait for the process to terminate out = out.decode(encoding)
out, err = process.communicate()
if os.name == 'nt': except:
out = out.decode(encoding) if out == "":
logging.error('BAZARR Post-processing result for file ' + path + ' : Nothing returned from command execution')
except: else:
if out == "": logging.error('BAZARR Post-processing result for file ' + path + ' : ' + out)
logging.error('BAZARR Post-processing result for file ' + path + ' : Nothing returned from command execution')
else:
logging.error('BAZARR Post-processing result for file ' + path + ' : ' + out)
else:
if out == "":
logging.info('BAZARR Post-processing result for file ' + path + ' : Nothing returned from command execution')
else: else:
logging.info('BAZARR Post-processing result for file ' + path + ' : ' + out) if out == "":
logging.info('BAZARR Post-processing result for file ' + path + ' : Nothing returned from command execution')
else:
logging.info('BAZARR Post-processing result for file ' + path + ' : ' + out)
return message return message
else: else:
logging.error('BAZARR Tried to download best subtitles available for file: ' + path + ' but it had no content. Going to retry on next search.') logging.error('BAZARR Tried to download best subtitles available for file: ' + path + ' but it had no content. Going to retry on next search.')
return None return None
else: else:
return None return None
logging.debug('BAZARR Ended searching subtitles for file: ' + path) 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, media_type):

Loading…
Cancel
Save