mirror of
https://github.com/morpheus65535/bazarr.git
synced 2025-02-12 17:03:59 +08:00
Exclude .sub of subtitles encoding detection
This commit is contained in:
parent
f3056a548a
commit
d130adfa6b
1 changed files with 13 additions and 12 deletions
|
@ -85,18 +85,19 @@ def store_subtitles_movie(file):
|
||||||
if str(language) != 'und':
|
if str(language) != 'und':
|
||||||
actual_subtitles.append([str(language), path_replace_reverse_movie(os.path.join(os.path.dirname(file), subtitle))])
|
actual_subtitles.append([str(language), path_replace_reverse_movie(os.path.join(os.path.dirname(file), subtitle))])
|
||||||
else:
|
else:
|
||||||
with open(path_replace_movie(os.path.join(os.path.dirname(file), subtitle)), 'r') as f:
|
if os.path.splitext(subtitle)[1] != ".sub":
|
||||||
text = list(islice(f, 100))
|
with open(path_replace_movie(os.path.join(os.path.dirname(file), subtitle)), 'r') as f:
|
||||||
text = ' '.join(text)
|
text = list(islice(f, 100))
|
||||||
encoding = UnicodeDammit(text)
|
text = ' '.join(text)
|
||||||
try:
|
encoding = UnicodeDammit(text)
|
||||||
text = text.decode(encoding.original_encoding)
|
try:
|
||||||
except Exception as e:
|
text = text.decode(encoding.original_encoding)
|
||||||
logging.exception('Error trying to detect character encoding for this subtitles file: ' + path_replace_movie(os.path.join(os.path.dirname(file), subtitle)) + ' You should try to delete this subtitles file manually and ask Bazarr to download it again.')
|
except Exception as e:
|
||||||
else:
|
logging.exception('Error trying to detect character encoding for this subtitles file: ' + path_replace_movie(os.path.join(os.path.dirname(file), subtitle)) + ' You should try to delete this subtitles file manually and ask Bazarr to download it again.')
|
||||||
detected_language = langdetect.detect(text)
|
else:
|
||||||
if len(detected_language) > 0:
|
detected_language = langdetect.detect(text)
|
||||||
actual_subtitles.append([str(detected_language), path_replace_reverse_movie(os.path.join(os.path.dirname(file), subtitle))])
|
if len(detected_language) > 0:
|
||||||
|
actual_subtitles.append([str(detected_language), path_replace_reverse_movie(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