Fix for list_subtitles doing path mapping over already mapped path.

This commit is contained in:
Louis Vézina 2019-08-26 16:51:41 -04:00
parent 24ea056ca6
commit 5eba6db10d
1 changed files with 8 additions and 9 deletions

View File

@ -81,7 +81,7 @@ def store_subtitles(file):
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(path_replace(os.path.join(os.path.dirname(file), subtitle)), 'r') as f: with open(os.path.join(os.path.dirname(file), 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)
@ -90,9 +90,9 @@ def store_subtitles(file):
detected_language = langdetect.detect(text) detected_language = langdetect.detect(text)
except Exception as e: except Exception as e:
logging.exception( logging.exception(
'BAZARR Error trying to detect language for this subtitles file: ' + path_replace( 'BAZARR Error trying to detect language for this subtitles file: ' +
os.path.join(os.path.dirname(file), os.path.join(os.path.dirname(file), subtitle) +
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:
logging.debug( logging.debug(
@ -171,8 +171,7 @@ def store_subtitles_movie(file):
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(path_replace_movie(os.path.join(os.path.dirname(file), dest_folder, subtitle)), with open(os.path.join(os.path.dirname(file), dest_folder, subtitle), 'r') as f:
'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)
@ -181,9 +180,9 @@ def store_subtitles_movie(file):
detected_language = langdetect.detect(text) detected_language = langdetect.detect(text)
except Exception as e: except Exception as e:
logging.exception( logging.exception(
'BAZARR Error trying to detect language for this subtitles file: ' + path_replace( 'BAZARR Error trying to detect language for this subtitles file: ' +
os.path.join(os.path.dirname(file), os.path.join(os.path.dirname(file), subtitle) +
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:
logging.debug( logging.debug(