1
0
Fork 0
mirror of https://github.com/morpheus65535/bazarr synced 2024-12-28 10:38:26 +00:00
bazarr/libs/subliminal_patch/converters/titlovi.py
Louis Vézina afd9cd6ddb Merge branch 'development' into python3
# Conflicts:
#	bazarr/get_movies.py
#	libs/subliminal_patch/core.py
#	libs/subliminal_patch/providers/subdivx.py
#	libs/subliminal_patch/providers/titlovi.py
2019-10-05 22:57:42 -04:00

44 lines
1.7 KiB
Python

# coding=utf-8
from __future__ import absolute_import
import logging
from babelfish import LanguageReverseConverter
from subliminal.exceptions import ConfigurationError
logger = logging.getLogger(__name__)
class TitloviConverter(LanguageReverseConverter):
def __init__(self):
self.from_titlovi = {'Bosanski': ('bos',),
'English': ('eng',),
'Hrvatski': ('hrv',),
'Makedonski': ('mkd',),
'Srpski': ('srp',),
'Cirilica': ('srp', None, 'Cyrl'),
'Slovenski': ('slv',),
}
self.to_titlovi = {('bos',): 'Bosanski',
('eng',): 'English',
('hrv',): 'Hrvatski',
('mkd',): 'Makedonski',
('srp',): 'Srpski',
('srp', None, 'Cyrl'): 'Cirilica',
('slv',): 'Slovenski'
}
self.codes = set(self.from_titlovi.keys())
def convert(self, alpha3, country=None, script=None):
if (alpha3, country, script) in self.to_titlovi:
return self.to_titlovi[(alpha3, country, script)]
if (alpha3,) in self.to_titlovi:
return self.to_titlovi[(alpha3,)]
raise ConfigurationError('Unsupported language code for titlovi: %s, %s, %s' % (alpha3, country, script))
def reverse(self, titlovi):
if titlovi in self.from_titlovi:
return self.from_titlovi[titlovi]
raise ConfigurationError('Unsupported language number for titlovi: %s' % titlovi)