Merge remote-tracking branch 'origin/development' into halali

# Conflicts:
#	bazarr/list_subtitles.py
pull/489/head
Halali 6 years ago
commit 3f9e917757

@ -5,6 +5,7 @@ import sqlite3
import pycountry import pycountry
from get_args import args from get_args import args
from subzero.language import Language
def load_language_in_db(): def load_language_in_db():
@ -108,5 +109,21 @@ def alpha3_from_language(lang):
return result return result
def get_language_set():
db = sqlite3.connect(os.path.join(args.config_dir, 'db', 'bazarr.db'), timeout=30)
c = db.cursor()
languages = c.execute('''SELECT code3 FROM table_settings_languages WHERE enabled = 1''').fetchall()
db.close()
language_set = set()
for lang in languages:
if lang[0] == 'pob':
language_set.add(Language('por', 'BR'))
else:
language_set.add(Language(lang[0]))
return language_set
if __name__ == '__main__': if __name__ == '__main__':
load_language_in_db() load_language_in_db()

@ -16,7 +16,7 @@ from bs4 import UnicodeDammit
from itertools import islice from itertools import islice
from get_args import args from get_args import args
from get_languages import alpha2_from_alpha3 from get_languages import alpha2_from_alpha3, get_language_set
from config import settings from config import settings
from helper import path_replace, path_replace_movie, path_replace_reverse, \ from helper import path_replace, path_replace_movie, path_replace_reverse, \
path_replace_reverse_movie, get_subtitle_destination_folder path_replace_reverse_movie, get_subtitle_destination_folder
@ -56,7 +56,8 @@ def store_subtitles(file):
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) subtitles = search_external_subtitles(file, languages=get_language_set(),
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
@ -140,7 +141,8 @@ def store_subtitles_movie(file):
subtitles = search_external_subtitles(file) subtitles = search_external_subtitles(file)
brazilian_portuguese = [".pt-br", ".pob", "pb"] brazilian_portuguese = [".pt-br", ".pob", "pb"]
try: try:
subtitles = core.search_external_subtitles(file) subtitles = search_external_subtitles(file, languages=get_language_set(),
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

@ -600,7 +600,7 @@ def _search_external_subtitles(path, languages=None, only_one=False, scandir_gen
logger.error('Cannot parse language code %r', language_code) logger.error('Cannot parse language code %r', language_code)
language = None language = None
if not language and only_one: elif not language_code and only_one:
language = Language.rebuild(list(languages)[0], forced=forced) language = Language.rebuild(list(languages)[0], forced=forced)
subtitles[p] = language subtitles[p] = language

Loading…
Cancel
Save