Temporary fix for "no content" error. Permanent fix will come with subliminal_patch integration.

pull/222/head
Louis Vézina 6 years ago
parent fbc919fa75
commit da9f559b1a

@ -96,70 +96,76 @@ def download_subtitle(path, language, hi, providers, providers_auth, sceneName,
logging.debug('BAZARR ' + str(len(subtitles_list)) + " subtitles have been found for this file: " + path) logging.debug('BAZARR ' + str(len(subtitles_list)) + " subtitles have been found for this file: " + path)
if len(subtitles_list) > 0: if len(subtitles_list) > 0:
try: try:
best_subtitle = subtitles_list[0] pdownload_result = False
download_subtitles([best_subtitle], providers=providers, provider_configs=providers_auth) for subtitle in subtitles_list:
logging.debug('BAZARR Subtitles file downloaded for this file:' + path) download_result = p.download_subtitle(subtitle)
if download_result == True:
logging.debug('BAZARR Subtitles file downloaded from ' + str(subtitle.provider_name) + ' for this file: ' + path)
break
else:
logging.warning('BAZARR Subtitles file skipped from ' + str(subtitle.provider_name) + ' for this file: ' + path + ' because no content was returned by the provider (probably throttled).')
continue
if download_result == False:
logging.error('BAZARR Tried to download a subtitles for file: ' + path + " but we weren't able to do it this time (probably being throttled). Going to retry on next search.")
return None
except Exception as e: except Exception as e:
logging.exception('BAZARR Error downloading subtitles for this file ' + path) logging.exception('BAZARR Error downloading subtitles for this file ' + path)
return None return None
else: else:
try: try:
calculated_score = round(float(compute_score(best_subtitle, video, hearing_impaired=hi)) / max_score * 100, 2) calculated_score = round(float(compute_score(subtitle, video, hearing_impaired=hi)) / max_score * 100, 2)
if used_sceneName == True: if used_sceneName == True:
video = scan_video(path) video = scan_video(path)
single = get_general_settings()[7] single = get_general_settings()[7]
if single is True: if single is True:
result = save_subtitles(video, [best_subtitle], single=True, encoding='utf-8') result = save_subtitles(video, [subtitle], single=True, encoding='utf-8')
else: else:
result = save_subtitles(video, [best_subtitle], encoding='utf-8') result = save_subtitles(video, [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 saving subtitles file to disk for this file:' + path)
pass pass
else: else:
if len(result) > 0: downloaded_provider = result[0].provider_name
downloaded_provider = result[0].provider_name downloaded_language = language_from_alpha3(result[0].language.alpha3)
downloaded_language = language_from_alpha3(result[0].language.alpha3) downloaded_language_code2 = alpha2_from_alpha3(result[0].language.alpha3)
downloaded_language_code2 = alpha2_from_alpha3(result[0].language.alpha3) downloaded_language_code3 = result[0].language.alpha3
downloaded_language_code3 = result[0].language.alpha3 downloaded_path = get_subtitle_path(path, language=language_set)
downloaded_path = get_subtitle_path(path, language=language_set) logging.debug('BAZARR Subtitles file saved to disk: ' + downloaded_path)
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
message = downloaded_language + " subtitles downloaded from " + downloaded_provider + " with a score of " + unicode(calculated_score) + "% using this scene name: " + sceneName else:
else: message = downloaded_language + " subtitles downloaded from " + downloaded_provider + " with a score of " + unicode(calculated_score) + "% using filename guessing."
message = downloaded_language + " subtitles downloaded from " + downloaded_provider + " with a score of " + unicode(calculated_score) + "% using filename guessing."
if use_postprocessing is True:
if use_postprocessing is True: command = pp_replace(postprocessing_cmd, path, downloaded_path, downloaded_language, downloaded_language_code2, downloaded_language_code3)
command = pp_replace(postprocessing_cmd, path, downloaded_path, downloaded_language, downloaded_language_code2, downloaded_language_code3) try:
try: if os.name == 'nt':
if os.name == 'nt': codepage = subprocess.Popen("chcp", shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
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, err = process.communicate() out_codepage, err_codepage = codepage.communicate()
encoding = out_codepage.split(':')[-1].strip()
if os.name == 'nt': process = subprocess.Popen(command, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
out = out.decode(encoding) # wait for the process to terminate
out, err = process.communicate()
except: if os.name == 'nt':
if out == "": out = out.decode(encoding)
logging.error('BAZARR Post-processing result for file ' + path + ' : Nothing returned from command execution')
else: except:
logging.error('BAZARR Post-processing result for file ' + path + ' : ' + out) if 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:
if out == "": logging.info('BAZARR Post-processing result for file ' + path + ' : ' + 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:
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
else: else:
logging.debug('BAZARR No subtitles were found for this file: ' + path)
return None return None
logging.debug('BAZARR Ended searching subtitles for file: ' + path) logging.debug('BAZARR Ended searching subtitles for file: ' + path)
@ -265,8 +271,7 @@ def manual_download_subtitle(path, language, hi, subtitle, provider, providers_a
pass pass
else: else:
try: try:
best_subtitle = subtitle download_subtitles([subtitle], providers=provider, provider_configs=providers_auth)
download_subtitles([best_subtitle], providers=provider, provider_configs=providers_auth)
logging.debug('BAZARR Subtitles file downloaded for this file:' + path) logging.debug('BAZARR Subtitles file downloaded for this file:' + path)
except Exception as e: except Exception as e:
logging.exception('BAZARR Error downloading subtitles for this file ' + path) logging.exception('BAZARR Error downloading subtitles for this file ' + path)
@ -274,13 +279,13 @@ def manual_download_subtitle(path, language, hi, subtitle, provider, providers_a
else: else:
single = get_general_settings()[7] single = get_general_settings()[7]
try: try:
score = round(float(compute_score(best_subtitle, video, hearing_impaired=hi)) / type_of_score * 100, 2) score = round(float(compute_score(subtitle, video, hearing_impaired=hi)) / type_of_score * 100, 2)
if used_sceneName == True: if used_sceneName == True:
video = scan_video(path) video = scan_video(path)
if single is True: if single is True:
result = save_subtitles(video, [best_subtitle], single=True, encoding='utf-8') result = save_subtitles(video, [subtitle], single=True, encoding='utf-8')
else: else:
result = save_subtitles(video, [best_subtitle], encoding='utf-8') result = save_subtitles(video, [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 saving subtitles file to disk for this file:' + path)
return None return None
@ -323,7 +328,7 @@ def manual_download_subtitle(path, language, hi, subtitle, provider, providers_a
return message return message
else: else:
logging.error('BAZARR Tried to manually download a subtitles for file: ' + path + ' but it had no content. Going to retry on next search.') logging.error('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 None
logging.debug('BAZARR Ended manually downloading subtitles for file: ' + path) logging.debug('BAZARR Ended manually downloading subtitles for file: ' + path)

Loading…
Cancel
Save