core: update to subliminal_patch:head; subscene: add pt-BR support; fix unknown language code on empty response

pull/479/head^2
panni 5 years ago
parent bce41d8002
commit 490468f7b3

@ -12,6 +12,13 @@ from_subscene = {
'Malay': 'msa', 'Pashto': 'pus', 'Punjabi': 'pan', 'Swahili': 'swa' 'Malay': 'msa', 'Pashto': 'pus', 'Punjabi': 'pan', 'Swahili': 'swa'
} }
from_subscene_with_country = {
'Brazillian Portuguese': ('por', 'BR')
}
to_subscene_with_country = {val: key for key, val in from_subscene_with_country.items()}
to_subscene = {v: k for k, v in from_subscene.items()} to_subscene = {v: k for k, v in from_subscene.items()}
exact_languages_alpha3 = [ exact_languages_alpha3 = [
@ -34,12 +41,12 @@ language_ids = {
'mkd': 48, 'mal': 64, 'mni': 65, 'mon': 72, 'pus': 67, 'pol': 31, 'mkd': 48, 'mal': 64, 'mni': 65, 'mon': 72, 'pus': 67, 'pol': 31,
'por': 32, 'pan': 66, 'rus': 34, 'srp': 35, 'sin': 58, 'slk': 36, 'por': 32, 'pan': 66, 'rus': 34, 'srp': 35, 'sin': 58, 'slk': 36,
'slv': 37, 'som': 70, 'tgl': 53, 'tam': 59, 'tel': 63, 'tha': 40, 'slv': 37, 'som': 70, 'tgl': 53, 'tam': 59, 'tel': 63, 'tha': 40,
'tur': 41, 'ukr': 56, 'urd': 42, 'yor': 71 'tur': 41, 'ukr': 56, 'urd': 42, 'yor': 71, 'pt-BR': 4
} }
# TODO: specify codes for unspecified_languages # TODO: specify codes for unspecified_languages
unspecified_languages = [ unspecified_languages = [
'Big 5 code', 'Brazillian Portuguese', 'Bulgarian/ English', 'Big 5 code', 'Bulgarian/ English',
'Chinese BG code', 'Dutch/ English', 'English/ German', 'Chinese BG code', 'Dutch/ English', 'English/ German',
'Hungarian/ English', 'Rohingya' 'Hungarian/ English', 'Rohingya'
] ]
@ -50,6 +57,8 @@ alpha3_of_code = {l.name: l.alpha3 for l in supported_languages}
supported_languages.update({Language(l) for l in to_subscene}) supported_languages.update({Language(l) for l in to_subscene})
supported_languages.update({Language(lang, cr) for lang, cr in to_subscene_with_country})
class SubsceneConverter(LanguageReverseConverter): class SubsceneConverter(LanguageReverseConverter):
codes = {l.name for l in supported_languages} codes = {l.name for l in supported_languages}
@ -61,9 +70,15 @@ class SubsceneConverter(LanguageReverseConverter):
if alpha3 in to_subscene: if alpha3 in to_subscene:
return to_subscene[alpha3] return to_subscene[alpha3]
if (alpha3, country) in to_subscene_with_country:
return to_subscene_with_country[(alpha3, country)]
raise ConfigurationError('Unsupported language for subscene: %s, %s, %s' % (alpha3, country, script)) raise ConfigurationError('Unsupported language for subscene: %s, %s, %s' % (alpha3, country, script))
def reverse(self, code): def reverse(self, code):
if code in from_subscene_with_country:
return from_subscene_with_country[code]
if code in from_subscene: if code in from_subscene:
return (from_subscene[code],) return (from_subscene[code],)

@ -208,7 +208,13 @@ class SubsceneProvider(Provider, ProviderSubtitleArchiveMixin):
acc_filters["ForeignOnly"] = self.filters["ForeignOnly"].lower() acc_filters["ForeignOnly"] = self.filters["ForeignOnly"].lower()
logger.info("Only searching for foreign/forced subtitles") logger.info("Only searching for foreign/forced subtitles")
acc_filters["SelectedIds"] = [str(language_ids[l.alpha3]) for l in languages if l.alpha3 in language_ids] selected_ids = []
for l in languages:
lid = language_ids.get(l.basename, language_ids.get(l.alpha3, None))
if lid:
selected_ids.append(str(lid))
acc_filters["SelectedIds"] = selected_ids
self.filters["LanguageFilter"] = ",".join(acc_filters["SelectedIds"]) self.filters["LanguageFilter"] = ",".join(acc_filters["SelectedIds"])
last_filters = region.get("subscene_filters") last_filters = region.get("subscene_filters")

@ -125,7 +125,7 @@ class Subtitle(object):
subtitles = [] subtitles = []
for row in rows: for row in rows:
if row.td.a is not None: if row.td.a is not None and row.td.get("class", ["lazy"])[0] != "empty":
subtitles.append(cls.from_row(row)) subtitles.append(cls.from_row(row))
return subtitles return subtitles

Loading…
Cancel
Save