mirror of
https://github.com/morpheus65535/bazarr.git
synced 2025-01-12 09:47:40 +08:00
Increased number of line to check for language detection and fixed conversion #36
This commit is contained in:
parent
916f1add59
commit
d8aa94e632
1 changed files with 5 additions and 2 deletions
|
@ -6,6 +6,7 @@ import pycountry
|
|||
import sqlite3
|
||||
import ast
|
||||
import langdetect
|
||||
import chardet
|
||||
|
||||
from get_general_settings import *
|
||||
|
||||
|
@ -35,7 +36,9 @@ def list_subtitles(file):
|
|||
else:
|
||||
with open(path_replace(os.path.join(os.path.dirname(file), subtitle)), 'r') as f:
|
||||
text = [next(f) for x in xrange(5)]
|
||||
text = ' '.join(text).decode('iso-8859-1')
|
||||
text = ' '.join(text)
|
||||
encoding = chardet.detect(text)['encoding']
|
||||
text = text.decode(encoding)
|
||||
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))])
|
||||
|
@ -67,7 +70,7 @@ def store_subtitles(file):
|
|||
actual_subtitles.append([str(language), path_replace_reverse(os.path.join(os.path.dirname(file), subtitle))])
|
||||
else:
|
||||
with open(path_replace(os.path.join(os.path.dirname(file), subtitle)), 'r') as f:
|
||||
text = [next(f) for x in xrange(5)]
|
||||
text = [next(f) for x in xrange(20)]
|
||||
text = ' '.join(text).decode('iso-8859-1')
|
||||
detected_language = langdetect.detect(text)
|
||||
if len(detected_language) > 0:
|
||||
|
|
Loading…
Reference in a new issue