Continuing development.

pull/684/head
Louis Vézina 5 years ago
parent b51838f2cf
commit ae35529de8

@ -5,7 +5,7 @@ import requests
import logging import logging
import re import re
from queueconfig import notifications from queueconfig import notifications
from database import TableShows, TableEpisodes, wal_cleaning from database import database, TableShows, TableEpisodes, wal_cleaning
from get_args import args from get_args import args
from config import settings, url_sonarr from config import settings, url_sonarr
@ -188,7 +188,7 @@ def sync_episodes():
for i, altered_episode in enumerate(altered_episodes, 1): for i, altered_episode in enumerate(altered_episodes, 1):
notifications.write(msg='Indexing episodes embedded subtitles...', queue='get_episodes', item=i, notifications.write(msg='Indexing episodes embedded subtitles...', queue='get_episodes', item=i,
length=len(altered_episodes)) length=len(altered_episodes))
store_subtitles(path_replace(altered_episode[1])) store_subtitles(altered_episode[1], path_replace(altered_episode[1]))
list_missing_subtitles(altered_episode[2]) list_missing_subtitles(altered_episode[2])
logging.debug('BAZARR All episodes synced from Sonarr into database.') logging.debug('BAZARR All episodes synced from Sonarr into database.')

@ -270,7 +270,7 @@ def update_movies():
for i, altered_movie in enumerate(altered_movies, 1): for i, altered_movie in enumerate(altered_movies, 1):
notifications.write(msg='Indexing movies embedded subtitles...', queue='get_movies', item=i, notifications.write(msg='Indexing movies embedded subtitles...', queue='get_movies', item=i,
length=len(altered_movies)) length=len(altered_movies))
store_subtitles_movie(path_replace_movie(altered_movie[1])) store_subtitles_movie(altered_movie[1], path_replace_movie(altered_movie[1]))
list_missing_subtitles_movies(altered_movie[2]) list_missing_subtitles_movies(altered_movie[2])
logging.debug('BAZARR All movies synced from Radarr into database.') logging.debug('BAZARR All movies synced from Radarr into database.')

@ -607,7 +607,7 @@ def series_download_subtitles(no):
language_code = result[2] + ":forced" if forced else result[2] language_code = result[2] + ":forced" if forced else result[2]
provider = result[3] provider = result[3]
score = result[4] score = result[4]
store_subtitles(path_replace(episode.path)) store_subtitles(episode.path, path_replace(episode.path))
history_log(1, no, episode.sonarr_episode_id, message, path, language_code, provider, score) history_log(1, no, episode.sonarr_episode_id, message, path, language_code, provider, score)
send_notifications(no, episode.sonarr_episode_id, message) send_notifications(no, episode.sonarr_episode_id, message)
else: else:
@ -671,7 +671,7 @@ def episode_download_subtitles(no):
language_code = result[2] + ":forced" if forced else result[2] language_code = result[2] + ":forced" if forced else result[2]
provider = result[3] provider = result[3]
score = result[4] score = result[4]
store_subtitles(path_replace(episode.path)) store_subtitles(episode.path, path_replace(episode.path))
history_log(1, episode.sonarr_series_id, episode.sonarr_episode_id, message, path, language_code, provider, score) history_log(1, episode.sonarr_series_id, episode.sonarr_episode_id, message, path, language_code, provider, score)
send_notifications(episode.sonarr_series_id, episode.sonarr_episode_id, message) send_notifications(episode.sonarr_series_id, episode.sonarr_episode_id, message)
list_missing_subtitles(episode.sonarr_series_id) list_missing_subtitles(episode.sonarr_series_id)
@ -720,7 +720,7 @@ def movies_download_subtitles(no):
language_code = result[2] + ":forced" if forced else result[2] language_code = result[2] + ":forced" if forced else result[2]
provider = result[3] provider = result[3]
score = result[4] score = result[4]
store_subtitles_movie(path_replace_movie(movie.path)) store_subtitles_movie(movie.path, path_replace_movie(movie.path))
history_log_movie(1, no, message, path, language_code, provider, score) history_log_movie(1, no, message, path, language_code, provider, score)
send_notifications_movie(no, message) send_notifications_movie(no, message)
else: else:
@ -798,7 +798,7 @@ def wanted_download_subtitles(path, l, count_episodes):
language_code = result[2] + ":forced" if forced else result[2] language_code = result[2] + ":forced" if forced else result[2]
provider = result[3] provider = result[3]
score = result[4] score = result[4]
store_subtitles(path_replace(episode.path)) store_subtitles(episode.path, path_replace(episode.path))
list_missing_subtitles(episode.sonarr_series_id.sonarr_series_id) list_missing_subtitles(episode.sonarr_series_id.sonarr_series_id)
history_log(1, episode.sonarr_series_id.sonarr_series_id, episode.sonarr_episode_id, message, path, language_code, provider, score) history_log(1, episode.sonarr_series_id.sonarr_series_id, episode.sonarr_episode_id, message, path, language_code, provider, score)
send_notifications(episode.sonarr_series_id.sonarr_series_id, episode.sonarr_episode_id, message) send_notifications(episode.sonarr_series_id.sonarr_series_id, episode.sonarr_episode_id, message)
@ -867,7 +867,7 @@ def wanted_download_subtitles_movie(path, l, count_movies):
language_code = result[2] + ":forced" if forced else result[2] language_code = result[2] + ":forced" if forced else result[2]
provider = result[3] provider = result[3]
score = result[4] score = result[4]
store_subtitles_movie(path_replace_movie(movie.path)) store_subtitles_movie(movie.path, path_replace_movie(movie.path))
list_missing_subtitles_movies(movie.radarr_id) list_missing_subtitles_movies(movie.radarr_id)
history_log_movie(1, movie.radarr_id, message, path, language_code, provider, score) history_log_movie(1, movie.radarr_id, message, path, language_code, provider, score)
send_notifications_movie(movie.radarr_id, message) send_notifications_movie(movie.radarr_id, message)
@ -1222,7 +1222,7 @@ def upgrade_subtitles():
language_code = result[2] + ":forced" if forced else result[2] language_code = result[2] + ":forced" if forced else result[2]
provider = result[3] provider = result[3]
score = result[4] score = result[4]
store_subtitles(path_replace(episode['video_path'])) store_subtitles(episode['video_path'], path_replace(episode['video_path']))
history_log(3, episode['sonarr_series_id'], episode['sonarr_episode_id'], message, path, language_code, provider, score) history_log(3, episode['sonarr_series_id'], episode['sonarr_episode_id'], message, path, language_code, provider, score)
send_notifications(episode['sonarr_series_id'], episode['sonarr_episode_id'], message) send_notifications(episode['sonarr_series_id'], episode['sonarr_episode_id'], message)
@ -1271,6 +1271,6 @@ def upgrade_subtitles():
language_code = result[2] + ":forced" if forced else result[2] language_code = result[2] + ":forced" if forced else result[2]
provider = result[3] provider = result[3]
score = result[4] score = result[4]
store_subtitles_movie(path_replace_movie(movie['video_path'])) store_subtitles_movie(movie['video_path'], path_replace_movie(movie['video_path']))
history_log_movie(3, movie['radarr_id'], message, path, language_code, provider, score) history_log_movie(3, movie['radarr_id'], message, path, language_code, provider, score)
send_notifications_movie(movie['radarr_id'], message) send_notifications_movie(movie['radarr_id'], message)

@ -53,21 +53,34 @@ def sonarr_path_mapping_reverse_regex():
def radarr_path_mapping_regex(): def radarr_path_mapping_regex():
global path_mapping_movie global path_mapping_movie
global radarr_regex global radarr_regex
global radarr_use_path_mapping
path_mapping_movie = dict(ast.literal_eval(settings.general.path_mappings_movie))
radarr_regex = re.compile("|".join(map(re.escape, path_mapping_movie.keys()))) path_mapping_movie = ast.literal_eval(settings.general.path_mappings_movie)
path_mapping_movie = sorted(path_mapping_movie, key=operator.itemgetter(0), reverse=True)
path_mapping_movie = OrderedDict((mapping[0], mapping[1]) for mapping in path_mapping_movie if mapping[0] != '')
if any(item for sublist in path_mapping_movie for item in sublist):
radarr_use_path_mapping = True
radarr_regex = re.compile("|".join(path_mapping_movie.keys()))
else:
radarr_use_path_mapping = False
def radarr_path_mapping_reverse_regex(): def radarr_path_mapping_reverse_regex():
global radarr_platform global radarr_platform
global path_mapping_reverse_movie global path_mapping_reverse_movie
global radarr_reverse_regex global radarr_reverse_regex
global radarr_use_path_mapping
radarr_platform = get_radarr_platform() radarr_platform = get_sonarr_platform()
path_mapping_reverse_movie_temp = ast.literal_eval(settings.general.path_mappings_movie) path_mapping_reverse_movie = ast.literal_eval(settings.general.path_mappings)
path_mapping_reverse_movie = dict([sublist[::-1] for sublist in path_mapping_reverse_movie_temp]) path_mapping_reverse_movie = sorted(path_mapping_reverse_movie, key=operator.itemgetter(0), reverse=True)
radarr_reverse_regex = re.compile("|".join(map(re.escape, path_mapping_reverse_movie.keys()))) path_mapping_reverse_movie = OrderedDict((mapping[1], mapping[0]) for mapping in path_mapping_reverse_movie if mapping[0] != '')
if any(item for sublist in path_mapping_reverse_movie for item in sublist):
radarr_use_path_mapping = True
radarr_reverse_regex = re.compile("|".join(map(re.escape, path_mapping_reverse_movie.keys())))
else:
radarr_use_path_mapping = False
def path_replace(path): def path_replace(path):
@ -98,7 +111,7 @@ def path_replace_reverse(path):
def path_replace_movie(path): def path_replace_movie(path):
if path is None: if path is None or radarr_use_path_mapping is False:
return None return None
reverted_path = radarr_regex.sub(lambda match: path_mapping_movie[match.group(0)], path, count=1) reverted_path = radarr_regex.sub(lambda match: path_mapping_movie[match.group(0)], path, count=1)
@ -109,17 +122,17 @@ def path_replace_movie(path):
def path_replace_reverse_movie(path): def path_replace_reverse_movie(path):
if path is None: if path is None or radarr_use_path_mapping is False:
return None return path
reverted_path_movie_temp = radarr_reverse_regex.sub(lambda match: path_mapping_reverse_movie[match.group(0)], path, count=1) reverted_path_temp = radarr_reverse_regex.sub(lambda match: path_mapping_reverse_movie[match.group(0)], path, count=1)
if radarr_platform == 'posix': if radarr_platform == 'posix':
from posixpath import normpath from posixpath import normpath
reverted_path = reverted_path_movie_temp.replace('\\', '/') reverted_path = reverted_path_temp.replace('\\', '/')
elif radarr_platform == 'nt': elif radarr_platform == 'nt':
from ntpath import normpath from ntpath import normpath
reverted_path = reverted_path_movie_temp.replace('/', '\\') reverted_path = reverted_path_temp.replace('/', '\\')
return normpath(reverted_path) return normpath(reverted_path)

@ -31,14 +31,14 @@ import six
gc.enable() gc.enable()
def store_subtitles(file): def store_subtitles(original_path, reversed_path):
logging.debug('BAZARR started subtitles indexing for this file: ' + file) logging.debug('BAZARR started subtitles indexing for this file: ' + reversed_path)
actual_subtitles = [] actual_subtitles = []
if os.path.exists(file): if os.path.exists(reversed_path):
if settings.general.getboolean('use_embedded_subs'): if settings.general.getboolean('use_embedded_subs'):
logging.debug("BAZARR is trying to index embedded subtitles.") logging.debug("BAZARR is trying to index embedded subtitles.")
try: try:
subtitle_languages = embedded_subs_reader.list_languages(file) subtitle_languages = embedded_subs_reader.list_languages(reversed_path)
for subtitle_language, subtitle_forced, subtitle_codec in subtitle_languages: for subtitle_language, subtitle_forced, subtitle_codec in subtitle_languages:
try: try:
if settings.general.getboolean("ignore_pgs_subs") and subtitle_codec == "hdmv_pgs_subtitle": if settings.general.getboolean("ignore_pgs_subs") and subtitle_codec == "hdmv_pgs_subtitle":
@ -56,39 +56,39 @@ def store_subtitles(file):
pass pass
except Exception as e: except Exception as e:
logging.exception( logging.exception(
"BAZARR error when trying to analyze this %s file: %s" % (os.path.splitext(file)[1], file)) "BAZARR error when trying to analyze this %s file: %s" % (os.path.splitext(reversed_path)[1], reversed_path))
pass pass
brazilian_portuguese = [".pt-br", ".pob", "pb"] brazilian_portuguese = [".pt-br", ".pob", "pb"]
brazilian_portuguese_forced = [".pt-br.forced", ".pob.forced", "pb.forced"] brazilian_portuguese_forced = [".pt-br.forced", ".pob.forced", "pb.forced"]
try: try:
dest_folder = get_subtitle_destination_folder() dest_folder = get_subtitle_destination_folder()
subliminal_patch.core.CUSTOM_PATHS = [dest_folder] if dest_folder else [] subliminal_patch.core.CUSTOM_PATHS = [dest_folder] if dest_folder else []
subtitles = search_external_subtitles(file, languages=get_language_set(), subtitles = search_external_subtitles(reversed_path, languages=get_language_set(),
only_one=settings.general.getboolean('single_language')) only_one=settings.general.getboolean('single_language'))
except Exception as e: except Exception as e:
logging.exception("BAZARR unable to index external subtitles.") logging.exception("BAZARR unable to index external subtitles.")
pass pass
else: else:
for subtitle, language in six.iteritems(subtitles): for subtitle, language in six.iteritems(subtitles):
subtitle_path = get_external_subtitles_path(file, subtitle) 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(subtitle_path)]) [str("pb"), original_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"), path_replace_reverse(subtitle_path)]) [str("pb:forced"), original_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), path_replace_reverse(subtitle_path)]) [str(language), original_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.")
with open(os.path.join(os.path.dirname(file), subtitle), 'r') as f: with open(os.path.join(os.path.dirname(reversed_path), subtitle), 'r') as f:
text = list(islice(f, 100)) text = list(islice(f, 100))
text = ' '.join(text) text = ' '.join(text)
encoding = UnicodeDammit(text) encoding = UnicodeDammit(text)
@ -98,7 +98,7 @@ def store_subtitles(file):
except Exception as e: except Exception as e:
logging.exception( logging.exception(
'BAZARR Error trying to detect language for this subtitles file: ' + 'BAZARR Error trying to detect language for this subtitles file: ' +
os.path.join(os.path.dirname(file), subtitle) + os.path.join(os.path.dirname(reversed_path), subtitle) +
' You should try to delete this subtitles file manually and ask Bazarr to download it again.') ' You should try to delete this subtitles file manually and ask Bazarr to download it again.')
else: else:
if len(detected_language) > 0: if len(detected_language) > 0:
@ -106,14 +106,14 @@ def store_subtitles(file):
"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(
os.path.join(os.path.dirname(file), subtitle))]) os.path.join(os.path.dirname(reversed_path), subtitle))])
update_count = TableEpisodes.update( update_count = TableEpisodes.update(
{ {
TableEpisodes.subtitles: str(actual_subtitles) TableEpisodes.subtitles: str(actual_subtitles)
} }
).where( ).where(
TableEpisodes.path == path_replace_reverse(file) TableEpisodes.path == original_path
).execute() ).execute()
if update_count > 0: if update_count > 0:
logging.debug("BAZARR storing those languages to DB: " + str(actual_subtitles)) logging.debug("BAZARR storing those languages to DB: " + str(actual_subtitles))
@ -122,19 +122,19 @@ def store_subtitles(file):
else: else:
logging.debug("BAZARR this file doesn't seems to exist or isn't accessible.") logging.debug("BAZARR this file doesn't seems to exist or isn't accessible.")
logging.debug('BAZARR ended subtitles indexing for this file: ' + file) logging.debug('BAZARR ended subtitles indexing for this file: ' + reversed_path)
return actual_subtitles return actual_subtitles
def store_subtitles_movie(file): def store_subtitles_movie(original_path, reversed_path):
logging.debug('BAZARR started subtitles indexing for this file: ' + file) logging.debug('BAZARR started subtitles indexing for this file: ' + reversed_path)
actual_subtitles = [] actual_subtitles = []
if os.path.exists(file): if os.path.exists(reversed_path):
if settings.general.getboolean('use_embedded_subs'): if settings.general.getboolean('use_embedded_subs'):
logging.debug("BAZARR is trying to index embedded subtitles.") logging.debug("BAZARR is trying to index embedded subtitles.")
try: try:
subtitle_languages = embedded_subs_reader.list_languages(file) subtitle_languages = embedded_subs_reader.list_languages(reversed_path)
for subtitle_language, subtitle_forced, subtitle_codec in subtitle_languages: for subtitle_language, subtitle_forced, subtitle_codec in subtitle_languages:
try: try:
if settings.general.getboolean("ignore_pgs_subs") and subtitle_codec == "hdmv_pgs_subtitle": if settings.general.getboolean("ignore_pgs_subs") and subtitle_codec == "hdmv_pgs_subtitle":
@ -152,7 +152,7 @@ def store_subtitles_movie(file):
pass pass
except Exception as e: except Exception as e:
logging.exception( logging.exception(
"BAZARR error when trying to analyze this %s file: %s" % (os.path.splitext(file)[1], file)) "BAZARR error when trying to analyze this %s file: %s" % (os.path.splitext(reversed_path)[1], reversed_path))
pass pass
dest_folder = get_subtitle_destination_folder() or '' dest_folder = get_subtitle_destination_folder() or ''
@ -160,32 +160,29 @@ def store_subtitles_movie(file):
brazilian_portuguese = [".pt-br", ".pob", "pb"] brazilian_portuguese = [".pt-br", ".pob", "pb"]
brazilian_portuguese_forced = [".pt-br.forced", ".pob.forced", "pb.forced"] brazilian_portuguese_forced = [".pt-br.forced", ".pob.forced", "pb.forced"]
try: try:
subtitles = search_external_subtitles(file, languages=get_language_set(), subtitles = search_external_subtitles(reversed_path, languages=get_language_set(),
only_one=settings.general.getboolean('single_language')) only_one=settings.general.getboolean('single_language'))
except Exception as e: except Exception as e:
logging.exception("BAZARR unable to index external subtitles.") logging.exception("BAZARR unable to index external subtitles.")
pass pass
else: else:
for subtitle, language in six.iteritems(subtitles): for subtitle, language in six.iteritems(subtitles):
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)):
logging.debug("BAZARR external subtitles detected: " + "pb") logging.debug("BAZARR external subtitles detected: " + "pb")
actual_subtitles.append( actual_subtitles.append(
[str("pb"), [str("pb"), original_path])
path_replace_reverse_movie(os.path.join(os.path.dirname(file), 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)) 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:forced"), [str("pb:forced"), original_path])
path_replace_reverse_movie(os.path.join(os.path.dirname(file), 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), [str(language), original_path])
path_replace_reverse_movie(os.path.join(os.path.dirname(file), 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.")
with open(os.path.join(os.path.dirname(file), dest_folder, subtitle), 'r') as f: with open(os.path.join(os.path.dirname(reversed_path), dest_folder, subtitle), 'r') as f:
text = list(islice(f, 100)) text = list(islice(f, 100))
text = ' '.join(text) text = ' '.join(text)
encoding = UnicodeDammit(text) encoding = UnicodeDammit(text)
@ -195,7 +192,7 @@ def store_subtitles_movie(file):
except Exception as e: except Exception as e:
logging.exception( logging.exception(
'BAZARR Error trying to detect language for this subtitles file: ' + 'BAZARR Error trying to detect language for this subtitles file: ' +
os.path.join(os.path.dirname(file), subtitle) + os.path.join(os.path.dirname(reversed_path), subtitle) +
' You should try to delete this subtitles file manually and ask Bazarr to download it again.') ' You should try to delete this subtitles file manually and ask Bazarr to download it again.')
else: else:
if len(detected_language) > 0: if len(detected_language) > 0:
@ -203,14 +200,14 @@ def store_subtitles_movie(file):
"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_movie( actual_subtitles.append([str(detected_language), path_replace_reverse_movie(
os.path.join(os.path.dirname(file), dest_folder, subtitle))]) os.path.join(os.path.dirname(reversed_path), dest_folder, subtitle))])
update_count = TableMovies.update( update_count = TableMovies.update(
{ {
TableMovies.subtitles: str(actual_subtitles) TableMovies.subtitles: str(actual_subtitles)
} }
).where( ).where(
TableMovies.path == path_replace_reverse_movie(file) TableMovies.path == original_path
).execute() ).execute()
if update_count > 0: if update_count > 0:
logging.debug("BAZARR storing those languages to DB: " + str(actual_subtitles)) logging.debug("BAZARR storing those languages to DB: " + str(actual_subtitles))
@ -219,7 +216,7 @@ def store_subtitles_movie(file):
else: else:
logging.debug("BAZARR this file doesn't seems to exist or isn't accessible.") logging.debug("BAZARR this file doesn't seems to exist or isn't accessible.")
logging.debug('BAZARR ended subtitles indexing for this file: ' + file) logging.debug('BAZARR ended subtitles indexing for this file: ' + reversed_path)
return actual_subtitles return actual_subtitles
@ -363,7 +360,7 @@ def series_full_scan_subtitles():
for i, episode in enumerate(episodes, 1): for i, episode in enumerate(episodes, 1):
notifications.write(msg='Updating all episodes subtitles from disk...', notifications.write(msg='Updating all episodes subtitles from disk...',
queue='list_subtitles_series', item=i, length=count_episodes) queue='list_subtitles_series', item=i, length=count_episodes)
store_subtitles(path_replace(episode.path)) store_subtitles(episode.path, path_replace(episode.path))
gc.collect() gc.collect()
@ -377,7 +374,7 @@ def movies_full_scan_subtitles():
for i, movie in enumerate(movies, 1): for i, movie in enumerate(movies, 1):
notifications.write(msg='Updating all movies subtitles from disk...', notifications.write(msg='Updating all movies subtitles from disk...',
queue='list_subtitles_movies', item=i, length=count_movies) queue='list_subtitles_movies', item=i, length=count_movies)
store_subtitles_movie(path_replace_movie(movie.path)) store_subtitles_movie(movie.path, path_replace_movie(movie.path))
gc.collect() gc.collect()
@ -390,7 +387,7 @@ def series_scan_subtitles(no):
) )
for episode in episodes: for episode in episodes:
store_subtitles(path_replace(episode.path)) store_subtitles(episode.path, path_replace(episode.path))
list_missing_subtitles(no) list_missing_subtitles(no)
@ -403,7 +400,7 @@ def movies_scan_subtitles(no):
) )
for movie in movies: for movie in movies:
store_subtitles_movie(path_replace_movie(movie.path)) store_subtitles_movie(movie.path, path_replace_movie(movie.path))
list_missing_subtitles_movies(no) list_missing_subtitles_movies(no)

@ -2060,7 +2060,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(six.text_type(episodePath)) store_subtitles(episodePath, six.text_type(episodePath))
list_missing_subtitles(sonarrSeriesId) list_missing_subtitles(sonarrSeriesId)
@ -2079,7 +2079,7 @@ def remove_subtitles_movie():
history_log_movie(0, radarrId, result) history_log_movie(0, radarrId, 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_movie(six.text_type(moviePath)) store_subtitles_movie(moviePath, six.text_type(moviePath))
list_missing_subtitles_movies(radarrId) list_missing_subtitles_movies(radarrId)
@ -2113,7 +2113,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(six.text_type(episodePath)) store_subtitles(episodePath, six.text_type(episodePath))
list_missing_subtitles(sonarrSeriesId) list_missing_subtitles(sonarrSeriesId)
redirect(ref) redirect(ref)
except OSError: except OSError:
@ -2171,7 +2171,7 @@ def manual_get_subtitle():
score = result[4] score = result[4]
history_log(2, sonarrSeriesId, sonarrEpisodeId, message, path, language_code, provider, score) history_log(2, sonarrSeriesId, sonarrEpisodeId, message, path, language_code, provider, score)
send_notifications(sonarrSeriesId, sonarrEpisodeId, message) send_notifications(sonarrSeriesId, sonarrEpisodeId, message)
store_subtitles(six.text_type(episodePath)) store_subtitles(episodePath, six.text_type(episodePath))
list_missing_subtitles(sonarrSeriesId) list_missing_subtitles(sonarrSeriesId)
redirect(ref) redirect(ref)
except OSError: except OSError:
@ -2215,7 +2215,7 @@ def perform_manual_upload_subtitle():
score = 360 score = 360
history_log(4, sonarrSeriesId, sonarrEpisodeId, message, path, language_code, provider, score) history_log(4, sonarrSeriesId, sonarrEpisodeId, message, path, language_code, provider, score)
send_notifications(sonarrSeriesId, sonarrEpisodeId, message) send_notifications(sonarrSeriesId, sonarrEpisodeId, message)
store_subtitles(six.text_type(episodePath)) store_subtitles(episodePath, six.text_type(episodePath))
list_missing_subtitles(sonarrSeriesId) list_missing_subtitles(sonarrSeriesId)
redirect(ref) redirect(ref)
@ -2252,7 +2252,7 @@ def get_subtitle_movie():
score = result[4] score = result[4]
history_log_movie(1, radarrId, message, path, language_code, provider, score) history_log_movie(1, radarrId, message, path, language_code, provider, score)
send_notifications_movie(radarrId, message) send_notifications_movie(radarrId, message)
store_subtitles_movie(six.text_type(moviePath)) store_subtitles_movie(moviePath, six.text_type(moviePath))
list_missing_subtitles_movies(radarrId) list_missing_subtitles_movies(radarrId)
redirect(ref) redirect(ref)
except OSError: except OSError:
@ -2308,7 +2308,7 @@ def manual_get_subtitle_movie():
score = result[4] score = result[4]
history_log_movie(2, radarrId, message, path, language_code, provider, score) history_log_movie(2, radarrId, message, path, language_code, provider, score)
send_notifications_movie(radarrId, message) send_notifications_movie(radarrId, message)
store_subtitles_movie(six.text_type(moviePath)) store_subtitles_movie(moviePath, six.text_type(moviePath))
list_missing_subtitles_movies(radarrId) list_missing_subtitles_movies(radarrId)
redirect(ref) redirect(ref)
except OSError: except OSError:
@ -2351,7 +2351,7 @@ def perform_manual_upload_subtitle_movie():
score = 120 score = 120
history_log_movie(4, radarrId, message, path, language_code, provider, score) history_log_movie(4, radarrId, message, path, language_code, provider, score)
send_notifications_movie(radarrId, message) send_notifications_movie(radarrId, message)
store_subtitles_movie(six.text_type(moviePath)) store_subtitles_movie(moviePath, six.text_type(moviePath))
list_missing_subtitles_movies(radarrId) list_missing_subtitles_movies(radarrId)
redirect(ref) redirect(ref)

Loading…
Cancel
Save