Continuing development.

pull/479/head
Louis Vézina 6 years ago
parent 6734656aeb
commit 679a76b476

@ -339,12 +339,10 @@ def manual_search(path, language, hi, forced, providers, providers_auth, sceneNa
score = compute_score(matches, s, video, hearing_impaired=hi) score = compute_score(matches, s, video, hearing_impaired=hi)
not_matched = scores - matches not_matched = scores - matches
s.score = score s.score = score
# if score < min_score:
# continue
subtitles_list.append( subtitles_list.append(
dict(score=round((score / max_score * 100), 2), dict(score=round((score / max_score * 100), 2),
language=alpha2_from_alpha3(s.language.alpha3), hearing_impaired=str(s.hearing_impaired), language=str(s.language), hearing_impaired=str(s.hearing_impaired),
provider=s.provider_name, provider=s.provider_name,
subtitle=codecs.encode(pickle.dumps(s.make_picklable()), "base64").decode(), subtitle=codecs.encode(pickle.dumps(s.make_picklable()), "base64").decode(),
url=s.page_link, matches=list(matches), dont_matches=list(not_matched))) url=s.page_link, matches=list(matches), dont_matches=list(not_matched)))

@ -69,16 +69,16 @@ def store_subtitles(file):
if str(os.path.splitext(subtitle)[0]).lower().endswith(tuple(brazilian_portuguese)): if str(os.path.splitext(subtitle)[0]).lower().endswith(tuple(brazilian_portuguese)):
logging.debug("BAZARR external subtitles detected: " + "pb") logging.debug("BAZARR external subtitles detected: " + "pb")
actual_subtitles.append( actual_subtitles.append(
[str("pb"), path_replace_reverse(subtitle_path), False]) [str("pb"), path_replace_reverse(subtitle_path)])
elif str(os.path.splitext(subtitle)[0]).lower().endswith(tuple(brazilian_portuguese_forced)): elif str(os.path.splitext(subtitle)[0]).lower().endswith(tuple(brazilian_portuguese_forced)):
logging.debug("BAZARR external subtitles detected: " + "pb:forced") logging.debug("BAZARR external subtitles detected: " + "pb:forced")
actual_subtitles.append( actual_subtitles.append(
[str("pb"), path_replace_reverse(subtitle_path), True]) [str("pb:forced"), path_replace_reverse(subtitle_path)])
elif str(language) != 'und': elif str(language) != 'und':
logging.debug("BAZARR external subtitles detected: " + str(language)) logging.debug("BAZARR external subtitles detected: " + str(language))
actual_subtitles.append( actual_subtitles.append(
[str(language).split(':')[0], path_replace_reverse(subtitle_path), language.forced]) [str(language), path_replace_reverse(subtitle_path)])
else: else:
if os.path.splitext(subtitle)[1] != ".sub": if os.path.splitext(subtitle)[1] != ".sub":
logging.debug("BAZARR falling back to file content analysis to detect language.") logging.debug("BAZARR falling back to file content analysis to detect language.")
@ -134,6 +134,8 @@ def store_subtitles_movie(file):
try: try:
if alpha2_from_alpha3(subtitle_track.language) is not None: if alpha2_from_alpha3(subtitle_track.language) is not None:
lang = str(alpha2_from_alpha3(subtitle_track.language)) lang = str(alpha2_from_alpha3(subtitle_track.language))
if subtitle_track.forced:
lang = lang + ':forced'
logging.debug("BAZARR embedded subtitles detected: " + lang) logging.debug("BAZARR embedded subtitles detected: " + lang)
actual_subtitles.append([lang, None]) actual_subtitles.append([lang, None])
except: except:
@ -160,15 +162,15 @@ def store_subtitles_movie(file):
if str(os.path.splitext(subtitle)[0]).lower().endswith(tuple(brazilian_portuguese)) is True: if str(os.path.splitext(subtitle)[0]).lower().endswith(tuple(brazilian_portuguese)) is True:
logging.debug("BAZARR external subtitles detected: " + "pb") logging.debug("BAZARR external subtitles detected: " + "pb")
actual_subtitles.append( actual_subtitles.append(
[str("pb"), path_replace_reverse_movie(os.path.join(os.path.dirname(file), subtitle)), False]) [str("pb"), path_replace_reverse_movie(os.path.join(os.path.dirname(file), subtitle))])
elif str(os.path.splitext(subtitle)[0]).lower().endswith(tuple(brazilian_portuguese_forced)) is True: elif str(os.path.splitext(subtitle)[0]).lower().endswith(tuple(brazilian_portuguese_forced)) is True:
logging.debug("BAZARR external subtitles detected: " + "pb:forced") logging.debug("BAZARR external subtitles detected: " + "pb:forced")
actual_subtitles.append( actual_subtitles.append(
[str("pb"), path_replace_reverse_movie(os.path.join(os.path.dirname(file), subtitle)), True]) [str("pb:forced"), path_replace_reverse_movie(os.path.join(os.path.dirname(file), subtitle))])
elif str(language) != 'und': elif str(language) != 'und':
logging.debug("BAZARR external subtitles detected: " + str(language)) logging.debug("BAZARR external subtitles detected: " + str(language))
actual_subtitles.append( actual_subtitles.append(
[str(language).split(':')[0], path_replace_reverse_movie(os.path.join(os.path.dirname(file), subtitle)), language.forced]) [str(language), path_replace_reverse_movie(os.path.join(os.path.dirname(file), subtitle))])
else: else:
if os.path.splitext(subtitle)[1] != ".sub": if os.path.splitext(subtitle)[1] != ".sub":
logging.debug("BAZARR falling back to file content analysis to detect language.") logging.debug("BAZARR falling back to file content analysis to detect language.")

@ -147,18 +147,18 @@
subtitles_files.sort() subtitles_files.sort()
if subtitles_files is not None: if subtitles_files is not None:
for subtitles_file in subtitles_files: for subtitles_file in subtitles_files:
if len(subtitles_file) > 2: if subtitles_file[0].endswith(':forced'):
forced = subtitles_file[2] forced = True
else: else:
forced = False forced = False
end end
%> %>
<tr> <tr>
<td>{{path_replace_movie(subtitles_file[1]) if subtitles_file[1] is not None else 'Video file subtitles track'}}</td> <td>{{path_replace_movie(subtitles_file[1]) if subtitles_file[1] is not None else 'Video file subtitles track'}}</td>
<td><div class="ui tiny inverted label" style='background-color: #777777;'>{{!'<span class="ui" data-tooltip="Forced" data-inverted=""><i class="exclamation icon"></i></span>' if forced else ''}}{{language_from_alpha2(subtitles_file[0])}}</div></td> <td><div class="ui tiny inverted label" style='background-color: #777777;'>{{!'<span class="ui" data-tooltip="Forced" data-inverted=""><i class="exclamation icon"></i></span>' if forced else ''}}{{language_from_alpha2(subtitles_file[0].split(':')[0])}}</div></td>
<td> <td>
%if subtitles_file[1] is not None: %if subtitles_file[1] is not None:
<a class="remove_subtitles ui inverted basic compact icon" data-tooltip="Delete subtitles file from disk" data-inverted="" data-moviePath="{{details[8]}}" data-subtitlesPath="{{path_replace_movie(subtitles_file[1])}}" data-language="{{alpha3_from_alpha2(subtitles_file[0])}}" data-radarrId={{details[10]}}> <a class="remove_subtitles ui inverted basic compact icon" data-tooltip="Delete subtitles file from disk" data-inverted="" data-position="top right" data-moviePath="{{details[8]}}" data-subtitlesPath="{{path_replace_movie(subtitles_file[1])}}" data-language="{{alpha3_from_alpha2(subtitles_file[0].split(':')[0])}}" data-radarrId={{details[10]}}>
<i class="ui black delete icon"></i> <i class="ui black delete icon"></i>
</a> </a>
%end %end
@ -474,6 +474,8 @@
render: function ( data, type, row ) { render: function ( data, type, row ) {
if ( data.language === "pt" && is_pb === true && is_pt === false) { if ( data.language === "pt" && is_pb === true && is_pt === false) {
return 'pb' return 'pb'
} else if ( data.language === "pt:forced" && is_pb === true && is_pt === false) {
return 'pb:forced'
} else { } else {
return data.language return data.language
} }

Loading…
Cancel
Save