mirror of
https://github.com/morpheus65535/bazarr
synced 2025-03-13 07:32:52 +00:00
WIP
This commit is contained in:
parent
9981df48af
commit
a7a4aa97c6
4 changed files with 15 additions and 24 deletions
|
@ -2,6 +2,7 @@
|
|||
|
||||
from __future__ import absolute_import
|
||||
import os
|
||||
import six
|
||||
import requests
|
||||
import logging
|
||||
from queueconfig import notifications
|
||||
|
|
|
@ -891,7 +891,7 @@ def refine_from_db(path, video):
|
|||
"table_episodes.video_codec, table_episodes.audio_codec, table_episodes.path "
|
||||
"FROM table_episodes INNER JOIN table_shows on "
|
||||
"table_shows.sonarrSeriesId = table_episodes.sonarrSeriesId "
|
||||
"WHERE table_episodes.path = ?", (unicode(path_replace_reverse(path)),), only_one=True)
|
||||
"WHERE table_episodes.path = ?", (path_replace_reverse(path),), only_one=True)
|
||||
|
||||
if data:
|
||||
video.series, year, country = series_re.match(data['seriesTitle']).groups()
|
||||
|
|
|
@ -73,16 +73,16 @@ def store_subtitles(original_path, reversed_path):
|
|||
if str(os.path.splitext(subtitle)[0]).lower().endswith(tuple(brazilian_portuguese)):
|
||||
logging.debug("BAZARR external subtitles detected: " + "pb")
|
||||
actual_subtitles.append(
|
||||
[str("pb"), original_path])
|
||||
[str("pb"), path_replace_reverse(subtitle_path)])
|
||||
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:forced"), original_path])
|
||||
[str("pb:forced"), path_replace_reverse(subtitle_path)])
|
||||
|
||||
elif str(language) != 'und':
|
||||
logging.debug("BAZARR external subtitles detected: " + str(language))
|
||||
actual_subtitles.append(
|
||||
[str(language), original_path])
|
||||
[str(language), path_replace_reverse(subtitle_path)])
|
||||
else:
|
||||
if os.path.splitext(subtitle)[1] != ".sub":
|
||||
logging.debug("BAZARR falling back to file content analysis to detect language.")
|
||||
|
@ -103,8 +103,7 @@ def store_subtitles(original_path, reversed_path):
|
|||
logging.debug(
|
||||
"BAZARR external subtitles detected and analysis guessed this language: " + str(
|
||||
detected_language))
|
||||
actual_subtitles.append([str(detected_language), path_replace_reverse(
|
||||
os.path.join(os.path.dirname(reversed_path), subtitle))])
|
||||
actual_subtitles.append([str(detected_language), path_replace_reverse(subtitle_path)])
|
||||
|
||||
database.execute("UPDATE table_episodes SET subtitles=? WHERE path=?",
|
||||
(str(actual_subtitles), original_path))
|
||||
|
@ -164,24 +163,16 @@ def store_subtitles_movie(original_path, reversed_path):
|
|||
pass
|
||||
else:
|
||||
for subtitle, language in six.iteritems(subtitles):
|
||||
subtitle_path = get_external_subtitles_path(reversed_path, subtitle)
|
||||
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_movie(os.path.join(os.path.dirname(reversed_path), dest_folder, subtitle))]
|
||||
)
|
||||
actual_subtitles.append([str("pb"), path_replace_reverse_movie(subtitle_path)])
|
||||
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:forced"),
|
||||
path_replace_reverse_movie(os.path.join(os.path.dirname(reversed_path), dest_folder, subtitle))]
|
||||
)
|
||||
actual_subtitles.append([str("pb:forced"), path_replace_reverse_movie(subtitle_path)])
|
||||
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(reversed_path), dest_folder, subtitle))]
|
||||
)
|
||||
actual_subtitles.append([str(language), path_replace_reverse_movie(subtitle_path)])
|
||||
else:
|
||||
if os.path.splitext(subtitle)[1] != ".sub":
|
||||
logging.debug("BAZARR falling back to file content analysis to detect language.")
|
||||
|
@ -200,10 +191,9 @@ def store_subtitles_movie(original_path, reversed_path):
|
|||
else:
|
||||
if len(detected_language) > 0:
|
||||
logging.debug(
|
||||
"BAZARR external subtitles detected and analysis guessed this language: " + str(
|
||||
detected_language))
|
||||
actual_subtitles.append([str(detected_language), path_replace_reverse_movie(
|
||||
os.path.join(os.path.dirname(reversed_path), dest_folder, subtitle))])
|
||||
"BAZARR external subtitles detected and analysis guessed this language: " +
|
||||
str(detected_language))
|
||||
actual_subtitles.append([str(detected_language), path_replace_reverse_movie(subtitle_path)])
|
||||
|
||||
database.execute("UPDATE table_movies SET subtitles=? WHERE path=?",
|
||||
(str(actual_subtitles), original_path))
|
||||
|
|
|
@ -1733,7 +1733,7 @@ def remove_subtitles():
|
|||
history_log(0, sonarrSeriesId, sonarrEpisodeId, result)
|
||||
except OSError as e:
|
||||
logging.exception('BAZARR cannot delete subtitles file: ' + subtitlesPath)
|
||||
store_subtitles(episodePath, unicode(episodePath))
|
||||
store_subtitles(episodePath, path_replace(episodePath))
|
||||
|
||||
|
||||
@route(base_url + 'remove_subtitles_movie', method='POST')
|
||||
|
@ -1784,7 +1784,7 @@ def get_subtitle():
|
|||
score = result[4]
|
||||
history_log(1, sonarrSeriesId, sonarrEpisodeId, message, path, language_code, provider, score)
|
||||
send_notifications(sonarrSeriesId, sonarrEpisodeId, message)
|
||||
store_subtitles(episodePath, six.text_type(episodePath))
|
||||
store_subtitles(path, episodePath)
|
||||
redirect(ref)
|
||||
except OSError:
|
||||
pass
|
||||
|
|
Loading…
Add table
Reference in a new issue