subtitle language improvement
This commit is contained in:
parent
f23a9ab4af
commit
02d61250cf
5 changed files with 20 additions and 25 deletions
|
|
@ -17,7 +17,7 @@
|
||||||
# You should have received a copy of the GNU Affero General Public License
|
# You should have received a copy of the GNU Affero General Public License
|
||||||
# along with weboob. If not, see <http://www.gnu.org/licenses/>.
|
# along with weboob. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
from weboob.capabilities.subtitle import ICapSubtitle
|
from weboob.capabilities.subtitle import ICapSubtitle,LanguageNotSupported
|
||||||
from weboob.tools.backend import BaseBackend
|
from weboob.tools.backend import BaseBackend
|
||||||
|
|
||||||
from .browser import AttilasubBrowser
|
from .browser import AttilasubBrowser
|
||||||
|
|
@ -52,5 +52,5 @@ class AttilasubBackend(BaseBackend, ICapSubtitle):
|
||||||
|
|
||||||
def iter_subtitles(self, language, pattern):
|
def iter_subtitles(self, language, pattern):
|
||||||
if language not in self.LANGUAGE_LIST:
|
if language not in self.LANGUAGE_LIST:
|
||||||
return []
|
raise LanguageNotSupported()
|
||||||
return self.browser.iter_subtitles(language,quote_plus(pattern.encode('utf-8')))
|
return self.browser.iter_subtitles(language,quote_plus(pattern.encode('utf-8')))
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,7 @@
|
||||||
# You should have received a copy of the GNU Affero General Public License
|
# You should have received a copy of the GNU Affero General Public License
|
||||||
# along with weboob. If not, see <http://www.gnu.org/licenses/>.
|
# along with weboob. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
from weboob.capabilities.subtitle import ICapSubtitle
|
from weboob.capabilities.subtitle import ICapSubtitle,LanguageNotSupported
|
||||||
from weboob.tools.backend import BaseBackend
|
from weboob.tools.backend import BaseBackend
|
||||||
|
|
||||||
from .browser import OpensubtitlesBrowser,LANGUAGE_CONV
|
from .browser import OpensubtitlesBrowser,LANGUAGE_CONV
|
||||||
|
|
@ -51,5 +51,5 @@ class OpensubtitlesBackend(BaseBackend, ICapSubtitle):
|
||||||
|
|
||||||
def iter_subtitles(self, language, pattern):
|
def iter_subtitles(self, language, pattern):
|
||||||
if language not in LANGUAGE_CONV.keys():
|
if language not in LANGUAGE_CONV.keys():
|
||||||
return []
|
raise LanguageNotSupported()
|
||||||
return self.browser.iter_subtitles(language,quote_plus(pattern.encode('utf-8')))
|
return self.browser.iter_subtitles(language,quote_plus(pattern.encode('utf-8')))
|
||||||
|
|
|
||||||
|
|
@ -17,10 +17,10 @@
|
||||||
# You should have received a copy of the GNU Affero General Public License
|
# You should have received a copy of the GNU Affero General Public License
|
||||||
# along with weboob. If not, see <http://www.gnu.org/licenses/>.
|
# along with weboob. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
from weboob.capabilities.subtitle import ICapSubtitle
|
from weboob.capabilities.subtitle import ICapSubtitle,LanguageNotSupported
|
||||||
from weboob.tools.backend import BaseBackend
|
from weboob.tools.backend import BaseBackend
|
||||||
|
|
||||||
from .browser import TvsubtitlesBrowser,LANGUAGE_CONV
|
from .browser import TvsubtitlesBrowser,LANGUAGE_LIST
|
||||||
|
|
||||||
from urllib import quote_plus
|
from urllib import quote_plus
|
||||||
|
|
||||||
|
|
@ -50,6 +50,6 @@ class TvsubtitlesBackend(BaseBackend, ICapSubtitle):
|
||||||
return self.browser.openurl(subtitle.url.encode('utf-8')).read()
|
return self.browser.openurl(subtitle.url.encode('utf-8')).read()
|
||||||
|
|
||||||
def iter_subtitles(self, language, pattern):
|
def iter_subtitles(self, language, pattern):
|
||||||
if language not in LANGUAGE_CONV.keys():
|
if language not in LANGUAGE_LIST:
|
||||||
return []
|
raise LanguageNotSupported()
|
||||||
return self.browser.iter_subtitles(language,quote_plus(pattern.encode('utf-8')))
|
return self.browser.iter_subtitles(language,quote_plus(pattern.encode('utf-8')))
|
||||||
|
|
|
||||||
|
|
@ -25,23 +25,9 @@ from .pages import SeriePage, SearchPage, SeasonPage,HomePage
|
||||||
|
|
||||||
__all__ = ['OpensubtitlesBrowser']
|
__all__ = ['OpensubtitlesBrowser']
|
||||||
|
|
||||||
LANGUAGE_CONV = {
|
LANGUAGE_LIST = ['en','es','fr','de','br','ru','ua','it','gr',
|
||||||
'ar':'ara', 'eo':'epo', 'ga':'', 'ru':'rus',
|
'ar','hu','pl','tr','nl','pt','sv','da','fi',
|
||||||
'af':'' , 'et':'est', 'it':'ita', 'sr':'scc',
|
'ko','cn','jp','bg','cz','ro']
|
||||||
'sq':'alb', 'tl':'' , 'ja':'jpn', 'sk':'slo',
|
|
||||||
'hy':'arm', 'fi':'fin', 'kn':'', 'sl':'slv',
|
|
||||||
'az':'' , 'fr':'fre', 'ko':'kor', 'es':'spa',
|
|
||||||
'eu':'baq', 'gl':'glg', 'la':'', 'sw':'swa',
|
|
||||||
'be':'' , 'ka':'geo', 'lv':'lav', 'sv':'swe',
|
|
||||||
'bn':'ben', 'de':'ger', 'lt':'lit', 'ta':'',
|
|
||||||
'bg':'bul', 'gr':'ell', 'mk':'mac', 'te':'tel',
|
|
||||||
'ca':'cat', 'gu':'' , 'ms':'may', 'th':'tha',
|
|
||||||
'zh':'chi', 'ht':'' , 'mt':'', 'tr':'tur',
|
|
||||||
'hr':'hrv', 'iw':'heb', 'no':'nor', 'uk':'ukr',
|
|
||||||
'cz':'cze', 'hi':'hin', 'fa':'per', 'ur':'urd',
|
|
||||||
'da':'dan', 'hu':'hun', 'pl':'pol', 'vi':'vie',
|
|
||||||
'nl':'dut', 'is':'ice', 'pt':'por', 'cy':'',
|
|
||||||
'en':'eng', 'id':'ind', 'ro':'rum', 'yi':''}
|
|
||||||
|
|
||||||
class TvsubtitlesBrowser(BaseBrowser):
|
class TvsubtitlesBrowser(BaseBrowser):
|
||||||
DOMAIN = 'www.tvsubtitles.net'
|
DOMAIN = 'www.tvsubtitles.net'
|
||||||
|
|
|
||||||
|
|
@ -25,6 +25,15 @@ from .base import IBaseCap, CapBaseObject, Field, StringField, FloatField, \
|
||||||
__all__ = ['Subtitle', 'ICapSubtitle']
|
__all__ = ['Subtitle', 'ICapSubtitle']
|
||||||
|
|
||||||
|
|
||||||
|
class LanguageNotSupported(UserError):
|
||||||
|
"""
|
||||||
|
Raised when the language is not supported
|
||||||
|
"""
|
||||||
|
|
||||||
|
def __init__(self, msg='language is not supported'):
|
||||||
|
UserError.__init__(self, msg)
|
||||||
|
|
||||||
|
|
||||||
class Subtitle(CapBaseObject):
|
class Subtitle(CapBaseObject):
|
||||||
"""
|
"""
|
||||||
Subtitle object.
|
Subtitle object.
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue