mirror of
https://github.com/morpheus65535/bazarr.git
synced 2025-01-12 09:47:40 +08:00
Adding exception logging for subtitles file encoding detection #37
This commit is contained in:
parent
d805576f83
commit
47261c0c91
1 changed files with 8 additions and 4 deletions
|
@ -39,10 +39,14 @@ def store_subtitles(file):
|
||||||
text = list(islice(f, 20))
|
text = list(islice(f, 20))
|
||||||
text = ' '.join(text)
|
text = ' '.join(text)
|
||||||
encoding = chardet.detect(text)['encoding']
|
encoding = chardet.detect(text)['encoding']
|
||||||
text = text.decode(encoding)
|
try:
|
||||||
detected_language = langdetect.detect(text)
|
text = text.decode(encoding)
|
||||||
if len(detected_language) > 0:
|
except Exception as e:
|
||||||
actual_subtitles.append([str(detected_language), path_replace_reverse(os.path.join(os.path.dirname(file), subtitle))])
|
logging.exception('Error trying to detect character encoding for this subtitles file: ' + path_replace(os.path.join(os.path.dirname(file), subtitle)))
|
||||||
|
else:
|
||||||
|
detected_language = langdetect.detect(text)
|
||||||
|
if len(detected_language) > 0:
|
||||||
|
actual_subtitles.append([str(detected_language), path_replace_reverse(os.path.join(os.path.dirname(file), subtitle))])
|
||||||
|
|
||||||
conn_db = sqlite3.connect(os.path.join(os.path.dirname(__file__), 'data/db/bazarr.db'), timeout=30)
|
conn_db = sqlite3.connect(os.path.join(os.path.dirname(__file__), 'data/db/bazarr.db'), timeout=30)
|
||||||
c_db = conn_db.cursor()
|
c_db = conn_db.cursor()
|
||||||
|
|
Loading…
Reference in a new issue