mirror of https://github.com/morpheus65535/bazarr
WIP
This commit is contained in:
parent
9981df48af
commit
a7a4aa97c6
|
@ -2,6 +2,7 @@
|
||||||
|
|
||||||
from __future__ import absolute_import
|
from __future__ import absolute_import
|
||||||
import os
|
import os
|
||||||
|
import six
|
||||||
import requests
|
import requests
|
||||||
import logging
|
import logging
|
||||||
from queueconfig import notifications
|
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 "
|
"table_episodes.video_codec, table_episodes.audio_codec, table_episodes.path "
|
||||||
"FROM table_episodes INNER JOIN table_shows on "
|
"FROM table_episodes INNER JOIN table_shows on "
|
||||||
"table_shows.sonarrSeriesId = table_episodes.sonarrSeriesId "
|
"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:
|
if data:
|
||||||
video.series, year, country = series_re.match(data['seriesTitle']).groups()
|
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)):
|
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"), original_path])
|
[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:forced"), original_path])
|
[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), original_path])
|
[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.")
|
||||||
|
@ -103,8 +103,7 @@ def store_subtitles(original_path, reversed_path):
|
||||||
logging.debug(
|
logging.debug(
|
||||||
"BAZARR external subtitles detected and analysis guessed this language: " + str(
|
"BAZARR external subtitles detected and analysis guessed this language: " + str(
|
||||||
detected_language))
|
detected_language))
|
||||||
actual_subtitles.append([str(detected_language), path_replace_reverse(
|
actual_subtitles.append([str(detected_language), path_replace_reverse(subtitle_path)])
|
||||||
os.path.join(os.path.dirname(reversed_path), subtitle))])
|
|
||||||
|
|
||||||
database.execute("UPDATE table_episodes SET subtitles=? WHERE path=?",
|
database.execute("UPDATE table_episodes SET subtitles=? WHERE path=?",
|
||||||
(str(actual_subtitles), original_path))
|
(str(actual_subtitles), original_path))
|
||||||
|
@ -164,24 +163,16 @@ def store_subtitles_movie(original_path, reversed_path):
|
||||||
pass
|
pass
|
||||||
else:
|
else:
|
||||||
for subtitle, language in six.iteritems(subtitles):
|
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)):
|
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_movie(subtitle_path)])
|
||||||
[str("pb"),
|
|
||||||
path_replace_reverse_movie(os.path.join(os.path.dirname(reversed_path), dest_folder, subtitle))]
|
|
||||||
)
|
|
||||||
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:forced"), path_replace_reverse_movie(subtitle_path)])
|
||||||
[str("pb:forced"),
|
|
||||||
path_replace_reverse_movie(os.path.join(os.path.dirname(reversed_path), dest_folder, 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), path_replace_reverse_movie(subtitle_path)])
|
||||||
[str(language),
|
|
||||||
path_replace_reverse_movie(os.path.join(os.path.dirname(reversed_path), dest_folder, 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.")
|
||||||
|
@ -200,10 +191,9 @@ def store_subtitles_movie(original_path, reversed_path):
|
||||||
else:
|
else:
|
||||||
if len(detected_language) > 0:
|
if len(detected_language) > 0:
|
||||||
logging.debug(
|
logging.debug(
|
||||||
"BAZARR external subtitles detected and analysis guessed this language: " + str(
|
"BAZARR external subtitles detected and analysis guessed this language: " +
|
||||||
detected_language))
|
str(detected_language))
|
||||||
actual_subtitles.append([str(detected_language), path_replace_reverse_movie(
|
actual_subtitles.append([str(detected_language), path_replace_reverse_movie(subtitle_path)])
|
||||||
os.path.join(os.path.dirname(reversed_path), dest_folder, subtitle))])
|
|
||||||
|
|
||||||
database.execute("UPDATE table_movies SET subtitles=? WHERE path=?",
|
database.execute("UPDATE table_movies SET subtitles=? WHERE path=?",
|
||||||
(str(actual_subtitles), original_path))
|
(str(actual_subtitles), original_path))
|
||||||
|
|
|
@ -1733,7 +1733,7 @@ def remove_subtitles():
|
||||||
history_log(0, sonarrSeriesId, sonarrEpisodeId, result)
|
history_log(0, sonarrSeriesId, sonarrEpisodeId, result)
|
||||||
except OSError as e:
|
except OSError as e:
|
||||||
logging.exception('BAZARR cannot delete subtitles file: ' + subtitlesPath)
|
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')
|
@route(base_url + 'remove_subtitles_movie', method='POST')
|
||||||
|
@ -1784,7 +1784,7 @@ def get_subtitle():
|
||||||
score = result[4]
|
score = result[4]
|
||||||
history_log(1, sonarrSeriesId, sonarrEpisodeId, message, path, language_code, provider, score)
|
history_log(1, sonarrSeriesId, sonarrEpisodeId, message, path, language_code, provider, score)
|
||||||
send_notifications(sonarrSeriesId, sonarrEpisodeId, message)
|
send_notifications(sonarrSeriesId, sonarrEpisodeId, message)
|
||||||
store_subtitles(episodePath, six.text_type(episodePath))
|
store_subtitles(path, episodePath)
|
||||||
redirect(ref)
|
redirect(ref)
|
||||||
except OSError:
|
except OSError:
|
||||||
pass
|
pass
|
||||||
|
|
Loading…
Reference in New Issue