|
|
@ -17,8 +17,8 @@ from datetime import datetime, timedelta
|
|
|
|
from subzero.language import Language
|
|
|
|
from subzero.language import Language
|
|
|
|
from subzero.video import parse_video
|
|
|
|
from subzero.video import parse_video
|
|
|
|
from subliminal import region, Video, score as subliminal_scores, \
|
|
|
|
from subliminal import region, Video, score as subliminal_scores, \
|
|
|
|
list_subtitles, download_subtitles
|
|
|
|
list_subtitles
|
|
|
|
from subliminal_patch.core import SZAsyncProviderPool, download_best_subtitles, save_subtitles
|
|
|
|
from subliminal_patch.core import SZAsyncProviderPool, download_best_subtitles, save_subtitles, download_subtitles
|
|
|
|
from subliminal_patch.score import compute_score
|
|
|
|
from subliminal_patch.score import compute_score
|
|
|
|
from subliminal.subtitle import get_subtitle_path
|
|
|
|
from subliminal.subtitle import get_subtitle_path
|
|
|
|
from get_languages import language_from_alpha3, alpha2_from_alpha3, alpha3_from_alpha2
|
|
|
|
from get_languages import language_from_alpha3, alpha2_from_alpha3, alpha3_from_alpha2
|
|
|
@ -343,6 +343,7 @@ def manual_search(path, language, hi, providers, providers_auth, sceneName, titl
|
|
|
|
|
|
|
|
|
|
|
|
not_matched = scores - matches
|
|
|
|
not_matched = scores - matches
|
|
|
|
score = compute_score(matches, s, video, hearing_impaired=hi)
|
|
|
|
score = compute_score(matches, s, video, hearing_impaired=hi)
|
|
|
|
|
|
|
|
s.score = score
|
|
|
|
if score < min_score:
|
|
|
|
if score < min_score:
|
|
|
|
continue
|
|
|
|
continue
|
|
|
|
|
|
|
|
|
|
|
@ -359,64 +360,45 @@ def manual_search(path, language, hi, providers, providers_auth, sceneName, titl
|
|
|
|
return final_subtitles
|
|
|
|
return final_subtitles
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def manual_download_subtitle(path, language, hi, subtitle, provider, providers_auth, sceneName, media_type):
|
|
|
|
def manual_download_subtitle(path, language, hi, subtitle, provider, providers_auth, sceneName, title, media_type):
|
|
|
|
logging.debug('BAZARR Manually downloading subtitles for this file: ' + path)
|
|
|
|
logging.debug('BAZARR Manually downloading subtitles for this file: ' + path)
|
|
|
|
if hi == "True":
|
|
|
|
if hi == "True":
|
|
|
|
hi = True
|
|
|
|
hi = True
|
|
|
|
else:
|
|
|
|
else:
|
|
|
|
hi = False
|
|
|
|
hi = False
|
|
|
|
subtitle = pickle.loads(codecs.decode(subtitle.encode(), "base64"))
|
|
|
|
subtitle = pickle.loads(codecs.decode(subtitle.encode(), "base64"))
|
|
|
|
if media_type == 'series':
|
|
|
|
|
|
|
|
type_of_score = 360
|
|
|
|
|
|
|
|
elif media_type == 'movie':
|
|
|
|
|
|
|
|
type_of_score = 120
|
|
|
|
|
|
|
|
use_scenename = get_general_settings()[9]
|
|
|
|
use_scenename = get_general_settings()[9]
|
|
|
|
use_postprocessing = get_general_settings()[10]
|
|
|
|
use_postprocessing = get_general_settings()[10]
|
|
|
|
postprocessing_cmd = get_general_settings()[11]
|
|
|
|
postprocessing_cmd = get_general_settings()[11]
|
|
|
|
|
|
|
|
single = get_general_settings()[7]
|
|
|
|
|
|
|
|
|
|
|
|
language = alpha3_from_alpha2(language)
|
|
|
|
video = get_video(path, title, sceneName, use_scenename, providers={provider}, media_type=media_type)
|
|
|
|
if language == 'pob':
|
|
|
|
if video:
|
|
|
|
lang_obj = Language('por', 'BR')
|
|
|
|
min_score, max_score, scores = get_scores(video, media_type)
|
|
|
|
else:
|
|
|
|
|
|
|
|
lang_obj = Language(language)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
try:
|
|
|
|
|
|
|
|
if sceneName is None or not use_scenename:
|
|
|
|
|
|
|
|
used_sceneName = False
|
|
|
|
|
|
|
|
video = parse_video(path, None, providers={provider})
|
|
|
|
|
|
|
|
else:
|
|
|
|
|
|
|
|
used_sceneName = True
|
|
|
|
|
|
|
|
video = Video.fromname(sceneName)
|
|
|
|
|
|
|
|
except Exception as e:
|
|
|
|
|
|
|
|
logging.exception("BAZARR Error trying to get video information for this file: " + path)
|
|
|
|
|
|
|
|
pass
|
|
|
|
|
|
|
|
else:
|
|
|
|
|
|
|
|
try:
|
|
|
|
try:
|
|
|
|
download_subtitles([subtitle], providers=provider, provider_configs=providers_auth)
|
|
|
|
download_subtitles([subtitle], providers={provider}, provider_configs=providers_auth,
|
|
|
|
|
|
|
|
pool_class=SZAsyncProviderPool,
|
|
|
|
|
|
|
|
throttle_callback=None) # fixme
|
|
|
|
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)
|
|
|
|
return None
|
|
|
|
return None
|
|
|
|
else:
|
|
|
|
else:
|
|
|
|
single = get_general_settings()[7]
|
|
|
|
|
|
|
|
try:
|
|
|
|
try:
|
|
|
|
score = round(float(compute_score(subtitle, video, hearing_impaired=hi)) / type_of_score * 100, 2)
|
|
|
|
score = round(subtitle.score / max_score * 100, 2)
|
|
|
|
if used_sceneName == True:
|
|
|
|
saved_subtitles = save_subtitles(video.name, [subtitle], single=single)
|
|
|
|
video = parse_video(path, None, providers={provider})
|
|
|
|
|
|
|
|
if single is True:
|
|
|
|
|
|
|
|
result = save_subtitles(video, [subtitle], single=True, encoding='utf-8')
|
|
|
|
|
|
|
|
else:
|
|
|
|
|
|
|
|
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
|
|
|
|
else:
|
|
|
|
else:
|
|
|
|
if len(result) > 0:
|
|
|
|
if saved_subtitles:
|
|
|
|
downloaded_provider = result[0].provider_name
|
|
|
|
for saved_subtitle in saved_subtitles:
|
|
|
|
downloaded_language = language_from_alpha3(result[0].language.alpha3)
|
|
|
|
downloaded_provider = saved_subtitle.provider_name
|
|
|
|
downloaded_language_code2 = alpha2_from_alpha3(result[0].language.alpha3)
|
|
|
|
downloaded_language = language_from_alpha3(saved_subtitle.language.alpha3)
|
|
|
|
downloaded_language_code3 = result[0].language.alpha3
|
|
|
|
downloaded_language_code2 = alpha2_from_alpha3(saved_subtitle.language.alpha3)
|
|
|
|
downloaded_path = get_subtitle_path(path, downloaded_language_code2)
|
|
|
|
downloaded_language_code3 = saved_subtitle.language.alpha3
|
|
|
|
|
|
|
|
downloaded_path = saved_subtitle.storage_path
|
|
|
|
logging.debug('BAZARR Subtitles file saved to disk: ' + downloaded_path)
|
|
|
|
logging.debug('BAZARR Subtitles file saved to disk: ' + downloaded_path)
|
|
|
|
message = downloaded_language + " subtitles downloaded from " + downloaded_provider + " with a score of " + unicode(
|
|
|
|
message = downloaded_language + " subtitles downloaded from " + downloaded_provider + " with a score of " + unicode(
|
|
|
|
score) + "% using manual search."
|
|
|
|
score) + "% using manual search."
|
|
|
|