mirror of
https://github.com/morpheus65535/bazarr
synced 2024-12-26 01:27:07 +00:00
Index and identify in UI forced subtitles.
This commit is contained in:
parent
1a3b6ec289
commit
6045252d15
3 changed files with 29 additions and 8 deletions
|
@ -42,7 +42,7 @@ def store_subtitles(file):
|
|||
if alpha2_from_alpha3(subtitle_track.language) is not None:
|
||||
lang = str(alpha2_from_alpha3(subtitle_track.language))
|
||||
logging.debug("BAZARR embedded subtitles detected: " + lang)
|
||||
actual_subtitles.append([lang, None])
|
||||
actual_subtitles.append([lang, None, subtitle_track.forced])
|
||||
except:
|
||||
logging.debug("BAZARR unable to index this unrecognized language: " + subtitle_track.language)
|
||||
pass
|
||||
|
@ -53,6 +53,7 @@ def store_subtitles(file):
|
|||
logging.debug("BAZARR This file isn't an .mkv file.")
|
||||
|
||||
brazilian_portuguese = [".pt-br", ".pob", "pb"]
|
||||
brazilian_portuguese_forced = [".pt-br.forced", ".pob.forced", "pb.forced"]
|
||||
try:
|
||||
dest_folder = get_subtitle_destination_folder()
|
||||
subliminal_patch.core.CUSTOM_PATHS = [dest_folder] if dest_folder else []
|
||||
|
@ -67,11 +68,16 @@ def store_subtitles(file):
|
|||
if str(os.path.splitext(subtitle)[0]).lower().endswith(tuple(brazilian_portuguese)):
|
||||
logging.debug("BAZARR external subtitles detected: " + "pb")
|
||||
actual_subtitles.append(
|
||||
[str("pb"), path_replace_reverse(subtitle_path)])
|
||||
[str("pb"), path_replace_reverse(subtitle_path), False])
|
||||
elif str(os.path.splitext(subtitle)[0]).lower().endswith(tuple(brazilian_portuguese_forced)):
|
||||
logging.debug("BAZARR external subtitles detected: " + "pb:forced")
|
||||
actual_subtitles.append(
|
||||
[str("pb"), path_replace_reverse(subtitle_path), True])
|
||||
|
||||
elif str(language) != 'und':
|
||||
logging.debug("BAZARR external subtitles detected: " + str(language))
|
||||
actual_subtitles.append(
|
||||
[str(language), path_replace_reverse(subtitle_path)])
|
||||
[str(language).split(':')[0], path_replace_reverse(subtitle_path), language.forced])
|
||||
else:
|
||||
if os.path.splitext(subtitle)[1] != ".sub":
|
||||
logging.debug("BAZARR falling back to file content analysis to detect language.")
|
||||
|
@ -127,7 +133,7 @@ def store_subtitles_movie(file):
|
|||
if alpha2_from_alpha3(subtitle_track.language) is not None:
|
||||
lang = str(alpha2_from_alpha3(subtitle_track.language))
|
||||
logging.debug("BAZARR embedded subtitles detected: " + lang)
|
||||
actual_subtitles.append([lang, None])
|
||||
actual_subtitles.append([lang, None, subtitle_track.forced])
|
||||
except:
|
||||
logging.debug("BAZARR unable to index this unrecognized language: " + subtitle_track.language)
|
||||
pass
|
||||
|
@ -140,6 +146,7 @@ def store_subtitles_movie(file):
|
|||
dest_folder = get_subtitle_destination_folder()
|
||||
subliminal_patch.core.CUSTOM_PATHS = [dest_folder] if dest_folder else []
|
||||
brazilian_portuguese = [".pt-br", ".pob", "pb"]
|
||||
brazilian_portuguese_forced = [".pt-br.forced", ".pob.forced", "pb.forced"]
|
||||
try:
|
||||
subtitles = search_external_subtitles(file, languages=get_language_set(),
|
||||
only_one=settings.general.getboolean('single_language'))
|
||||
|
@ -151,11 +158,15 @@ def store_subtitles_movie(file):
|
|||
if str(os.path.splitext(subtitle)[0]).lower().endswith(tuple(brazilian_portuguese)) is True:
|
||||
logging.debug("BAZARR external subtitles detected: " + "pb")
|
||||
actual_subtitles.append(
|
||||
[str("pb"), path_replace_reverse_movie(os.path.join(os.path.dirname(file), subtitle))])
|
||||
[str("pb"), path_replace_reverse_movie(os.path.join(os.path.dirname(file), subtitle)), False])
|
||||
elif str(os.path.splitext(subtitle)[0]).lower().endswith(tuple(brazilian_portuguese_forced)) is True:
|
||||
logging.debug("BAZARR external subtitles detected: " + "pb:forced")
|
||||
actual_subtitles.append(
|
||||
[str("pb"), path_replace_reverse_movie(os.path.join(os.path.dirname(file), subtitle)), True])
|
||||
elif str(language) != 'und':
|
||||
logging.debug("BAZARR external subtitles detected: " + str(language))
|
||||
actual_subtitles.append(
|
||||
[str(language), path_replace_reverse_movie(os.path.join(os.path.dirname(file), subtitle))])
|
||||
[str(language).split(':')[0], path_replace_reverse_movie(os.path.join(os.path.dirname(file), subtitle)), language.forced])
|
||||
else:
|
||||
if os.path.splitext(subtitle)[1] != ".sub":
|
||||
logging.debug("BAZARR falling back to file content analysis to detect language.")
|
||||
|
|
|
@ -197,9 +197,14 @@
|
|||
%end
|
||||
%try:
|
||||
%for language in actual_languages:
|
||||
%if len(language) > 2:
|
||||
% forced = language[2]
|
||||
%else:
|
||||
% forced = False
|
||||
%end
|
||||
%if language[1] is not None:
|
||||
<a data-episodePath="{{episode[1]}}" data-subtitlesPath="{{path_replace(language[1])}}" data-language="{{alpha3_from_alpha2(str(language[0]))}}" data-sonarrSeriesId={{episode[5]}} data-sonarrEpisodeId={{episode[7]}} class="remove_subtitles ui tiny label">
|
||||
{{language[0]}}
|
||||
{{!'<span class="ui" data-tooltip="Forced" data-inverted=""><i class="exclamation icon"></i></span>' if forced else ''}}{{language[0]}}
|
||||
<i class="delete icon"></i>
|
||||
</a>
|
||||
%else:
|
||||
|
|
|
@ -147,10 +147,15 @@
|
|||
subtitles_files.sort()
|
||||
if subtitles_files is not None:
|
||||
for subtitles_file in subtitles_files:
|
||||
if len(subtitles_file) > 2:
|
||||
forced = subtitles_file[2]
|
||||
else:
|
||||
forced = False
|
||||
end
|
||||
%>
|
||||
<tr>
|
||||
<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;'>{{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])}}</div></td>
|
||||
<td>
|
||||
%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]}}>
|
||||
|
|
Loading…
Reference in a new issue