Merge branch 'master' of https://github.com/kodiondemand/addon
This commit is contained in:
@@ -53,9 +53,10 @@ def peliculas(item):
|
|||||||
patron = r'>(?P<quality>[^"<]+)'
|
patron = r'>(?P<quality>[^"<]+)'
|
||||||
patron += '<TD[^>]+><A class="tab" HREF="(?P<url>[^"]+)"\s*>[^<]+<[^>]+>[^>]+>[^>]+>[^>]+>[^>]+>(?P<size>[^<]+)<[^>]+>[^>]+>[^>]+><form action="[^"]+/\d+/(?P<title>[^"]+)[^>]+>[^>]+>[^>]+>[^>]+>[^>]+>[^>]+>[^>]+>[^>]+>[^>]+>[^>]+>[^>]+>[^>]+>[^>]+>(?P<seed>[^<]+)'
|
patron += '<TD[^>]+><A class="tab" HREF="(?P<url>[^"]+)"\s*>[^<]+<[^>]+>[^>]+>[^>]+>[^>]+>[^>]+>(?P<size>[^<]+)<[^>]+>[^>]+>[^>]+><form action="[^"]+/\d+/(?P<title>[^"]+)[^>]+>[^>]+>[^>]+>[^>]+>[^>]+>[^>]+>[^>]+>[^>]+>[^>]+>[^>]+>[^>]+>[^>]+>[^>]+>(?P<seed>[^<]+)'
|
||||||
|
|
||||||
if not sceneTitle:
|
|
||||||
def itemHook(item):
|
def itemHook(item):
|
||||||
|
if not sceneTitle:
|
||||||
item.title = item.title.replace('_', ' ')
|
item.title = item.title.replace('_', ' ')
|
||||||
|
item.title = support.urlparse.unquote(item.title)
|
||||||
return item
|
return item
|
||||||
|
|
||||||
if 'search' not in item.args:
|
if 'search' not in item.args:
|
||||||
|
|||||||
@@ -4,12 +4,6 @@
|
|||||||
# Use of this source code is governed by the 3-clause BSD license
|
# Use of this source code is governed by the 3-clause BSD license
|
||||||
# that can be found in the LICENSE file.
|
# that can be found in the LICENSE file.
|
||||||
#
|
#
|
||||||
__title__ = 'babelfish'
|
|
||||||
__version__ = '0.5.5-dev'
|
|
||||||
__author__ = 'Antoine Bertin'
|
|
||||||
__license__ = 'BSD'
|
|
||||||
__copyright__ = 'Copyright 2015 the BabelFish authors'
|
|
||||||
|
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
if sys.version_info[0] >= 3:
|
if sys.version_info[0] >= 3:
|
||||||
|
|||||||
@@ -2,20 +2,22 @@
|
|||||||
# Use of this source code is governed by the 3-clause BSD license
|
# Use of this source code is governed by the 3-clause BSD license
|
||||||
# that can be found in the LICENSE file.
|
# that can be found in the LICENSE file.
|
||||||
#
|
#
|
||||||
import collections
|
from pkg_resources import iter_entry_points, EntryPoint
|
||||||
import functools
|
|
||||||
from importlib import import_module
|
|
||||||
|
|
||||||
# from pkg_resources import iter_entry_points, EntryPoint
|
|
||||||
from ..exceptions import LanguageConvertError, LanguageReverseError
|
from ..exceptions import LanguageConvertError, LanguageReverseError
|
||||||
|
|
||||||
|
try:
|
||||||
|
# Python 3.3+
|
||||||
|
from collections.abc import Mapping, MutableMapping
|
||||||
|
except ImportError:
|
||||||
|
from collections import Mapping, MutableMapping
|
||||||
|
|
||||||
|
|
||||||
# from https://github.com/kennethreitz/requests/blob/master/requests/structures.py
|
# from https://github.com/kennethreitz/requests/blob/master/requests/structures.py
|
||||||
class CaseInsensitiveDict(collections.MutableMapping):
|
class CaseInsensitiveDict(MutableMapping):
|
||||||
"""A case-insensitive ``dict``-like object.
|
"""A case-insensitive ``dict``-like object.
|
||||||
|
|
||||||
Implements all methods and operations of
|
Implements all methods and operations of
|
||||||
``collections.MutableMapping`` as well as dict's ``copy``. Also
|
``collections.abc.MutableMapping`` as well as dict's ``copy``. Also
|
||||||
provides ``lower_items``.
|
provides ``lower_items``.
|
||||||
|
|
||||||
All keys are expected to be strings. The structure remembers the
|
All keys are expected to be strings. The structure remembers the
|
||||||
@@ -66,7 +68,7 @@ class CaseInsensitiveDict(collections.MutableMapping):
|
|||||||
)
|
)
|
||||||
|
|
||||||
def __eq__(self, other):
|
def __eq__(self, other):
|
||||||
if isinstance(other, collections.Mapping):
|
if isinstance(other, Mapping):
|
||||||
other = CaseInsensitiveDict(other)
|
other = CaseInsensitiveDict(other)
|
||||||
else:
|
else:
|
||||||
return NotImplemented
|
return NotImplemented
|
||||||
@@ -238,19 +240,21 @@ class ConverterManager(object):
|
|||||||
"""Get a converter, lazy loading it if necessary"""
|
"""Get a converter, lazy loading it if necessary"""
|
||||||
if name in self.converters:
|
if name in self.converters:
|
||||||
return self.converters[name]
|
return self.converters[name]
|
||||||
# for ep in iter_entry_points(self.entry_point):
|
for ep in iter_entry_points(self.entry_point):
|
||||||
# if ep.name == name:
|
if ep.name == name:
|
||||||
# self.converters[ep.name] = ep.load()()
|
self.converters[ep.name] = ep.load()()
|
||||||
# return self.converters[ep.name]
|
return self.converters[ep.name]
|
||||||
def parse(str):
|
for ep in (EntryPoint.parse(c) for c in self.registered_converters + self.internal_converters):
|
||||||
import re
|
if ep.name == name:
|
||||||
match = re.match('(?P<name>\w+) = (?P<module>[a-z0-9.]+):(?P<class>\w+)', str)
|
# `require` argument of ep.load() is deprecated in newer versions of setuptools
|
||||||
return match.groupdict()
|
if hasattr(ep, 'resolve'):
|
||||||
for ep in (parse(c) for c in self.registered_converters + self.internal_converters):
|
plugin = ep.resolve()
|
||||||
if ep.get('name') == name:
|
elif hasattr(ep, '_load'):
|
||||||
cl = getattr(import_module(ep.get('module')), ep.get('class'))
|
plugin = ep._load()
|
||||||
self.converters[ep.get('name')] = cl()
|
else:
|
||||||
return self.converters[ep.get('name')]
|
plugin = ep.load(require=False)
|
||||||
|
self.converters[ep.name] = plugin()
|
||||||
|
return self.converters[ep.name]
|
||||||
raise KeyError(name)
|
raise KeyError(name)
|
||||||
|
|
||||||
def __setitem__(self, name, converter):
|
def __setitem__(self, name, converter):
|
||||||
|
|||||||
@@ -14,10 +14,10 @@ class OpenSubtitlesConverter(LanguageReverseConverter):
|
|||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.alpha3b_converter = language_converters['alpha3b']
|
self.alpha3b_converter = language_converters['alpha3b']
|
||||||
self.alpha2_converter = language_converters['alpha2']
|
self.alpha2_converter = language_converters['alpha2']
|
||||||
self.to_opensubtitles = {('por', 'BR'): 'pob', ('gre', None): 'ell', ('srp', None): 'scc', ('srp', 'ME'): 'mne'}
|
self.to_opensubtitles = {('por', 'BR'): 'pob', ('gre', None): 'ell', ('srp', None): 'scc', ('srp', 'ME'): 'mne', ('chi', 'TW'): 'zht'}
|
||||||
self.from_opensubtitles = CaseInsensitiveDict({'pob': ('por', 'BR'), 'pb': ('por', 'BR'), 'ell': ('ell', None),
|
self.from_opensubtitles = CaseInsensitiveDict({'pob': ('por', 'BR'), 'pb': ('por', 'BR'), 'ell': ('ell', None),
|
||||||
'scc': ('srp', None), 'mne': ('srp', 'ME')})
|
'scc': ('srp', None), 'mne': ('srp', 'ME'), 'zht': ('zho', 'TW')})
|
||||||
self.codes = (self.alpha2_converter.codes | self.alpha3b_converter.codes | set(['pob', 'pb', 'scc', 'mne']))
|
self.codes = (self.alpha2_converter.codes | self.alpha3b_converter.codes | set(self.from_opensubtitles.keys()))
|
||||||
|
|
||||||
def convert(self, alpha3, country=None, script=None):
|
def convert(self, alpha3, country=None, script=None):
|
||||||
alpha3b = self.alpha3b_converter.convert(alpha3, country, script)
|
alpha3b = self.alpha3b_converter.convert(alpha3, country, script)
|
||||||
|
|||||||
@@ -7,8 +7,7 @@
|
|||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
from collections import namedtuple
|
from collections import namedtuple
|
||||||
from functools import partial
|
from functools import partial
|
||||||
# from pkg_resources import resource_stream # @UnresolvedImport
|
from pkg_resources import resource_stream # @UnresolvedImport
|
||||||
import os, io
|
|
||||||
from .converters import ConverterManager
|
from .converters import ConverterManager
|
||||||
from . import basestr
|
from . import basestr
|
||||||
|
|
||||||
@@ -19,10 +18,10 @@ COUNTRY_MATRIX = []
|
|||||||
#: The namedtuple used in the :data:`COUNTRY_MATRIX`
|
#: The namedtuple used in the :data:`COUNTRY_MATRIX`
|
||||||
IsoCountry = namedtuple('IsoCountry', ['name', 'alpha2'])
|
IsoCountry = namedtuple('IsoCountry', ['name', 'alpha2'])
|
||||||
|
|
||||||
f = io.open(os.path.join(os.path.dirname(__file__), 'data/iso-3166-1.txt'), encoding='utf-8')
|
f = resource_stream('babelfish', 'data/iso-3166-1.txt')
|
||||||
f.readline()
|
f.readline()
|
||||||
for l in f:
|
for l in f:
|
||||||
iso_country = IsoCountry(*l.strip().split(';'))
|
iso_country = IsoCountry(*l.decode('utf-8').strip().split(';'))
|
||||||
COUNTRIES[iso_country.alpha2] = iso_country.name
|
COUNTRIES[iso_country.alpha2] = iso_country.name
|
||||||
COUNTRY_MATRIX.append(iso_country)
|
COUNTRY_MATRIX.append(iso_country)
|
||||||
f.close()
|
f.close()
|
||||||
|
|||||||
@@ -7,8 +7,7 @@
|
|||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
from collections import namedtuple
|
from collections import namedtuple
|
||||||
from functools import partial
|
from functools import partial
|
||||||
import os, io
|
from pkg_resources import resource_stream # @UnresolvedImport
|
||||||
# from pkg_resources import resource_stream # @UnresolvedImport
|
|
||||||
from .converters import ConverterManager
|
from .converters import ConverterManager
|
||||||
from .country import Country
|
from .country import Country
|
||||||
from .exceptions import LanguageConvertError
|
from .exceptions import LanguageConvertError
|
||||||
@@ -22,10 +21,10 @@ LANGUAGE_MATRIX = []
|
|||||||
#: The namedtuple used in the :data:`LANGUAGE_MATRIX`
|
#: The namedtuple used in the :data:`LANGUAGE_MATRIX`
|
||||||
IsoLanguage = namedtuple('IsoLanguage', ['alpha3', 'alpha3b', 'alpha3t', 'alpha2', 'scope', 'type', 'name', 'comment'])
|
IsoLanguage = namedtuple('IsoLanguage', ['alpha3', 'alpha3b', 'alpha3t', 'alpha2', 'scope', 'type', 'name', 'comment'])
|
||||||
|
|
||||||
f = io.open(os.path.join(os.path.dirname(__file__), 'data/iso-639-3.tab'), encoding='utf-8')
|
f = resource_stream('babelfish', 'data/iso-639-3.tab')
|
||||||
f.readline()
|
f.readline()
|
||||||
for l in f:
|
for l in f:
|
||||||
iso_language = IsoLanguage(*l.split('\t'))
|
iso_language = IsoLanguage(*l.decode('utf-8').split('\t'))
|
||||||
LANGUAGES.add(iso_language.alpha3)
|
LANGUAGES.add(iso_language.alpha3)
|
||||||
LANGUAGE_MATRIX.append(iso_language)
|
LANGUAGE_MATRIX.append(iso_language)
|
||||||
f.close()
|
f.close()
|
||||||
|
|||||||
@@ -5,10 +5,8 @@
|
|||||||
# that can be found in the LICENSE file.
|
# that can be found in the LICENSE file.
|
||||||
#
|
#
|
||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
|
|
||||||
import os, io
|
|
||||||
from collections import namedtuple
|
from collections import namedtuple
|
||||||
# from pkg_resources import resource_stream # @UnresolvedImport
|
from pkg_resources import resource_stream # @UnresolvedImport
|
||||||
from . import basestr
|
from . import basestr
|
||||||
|
|
||||||
#: Script code to script name mapping
|
#: Script code to script name mapping
|
||||||
@@ -20,10 +18,10 @@ SCRIPT_MATRIX = []
|
|||||||
#: The namedtuple used in the :data:`SCRIPT_MATRIX`
|
#: The namedtuple used in the :data:`SCRIPT_MATRIX`
|
||||||
IsoScript = namedtuple('IsoScript', ['code', 'number', 'name', 'french_name', 'pva', 'date'])
|
IsoScript = namedtuple('IsoScript', ['code', 'number', 'name', 'french_name', 'pva', 'date'])
|
||||||
|
|
||||||
f = io.open(os.path.join(os.path.dirname(__file__), 'data/iso15924-utf8-20131012.txt'), encoding='utf-8')
|
f = resource_stream('babelfish', 'data/iso15924-utf8-20131012.txt')
|
||||||
f.readline()
|
f.readline()
|
||||||
for l in f:
|
for l in f:
|
||||||
l = l.strip()
|
l = l.decode('utf-8').strip()
|
||||||
if not l or l.startswith('#'):
|
if not l or l.startswith('#'):
|
||||||
continue
|
continue
|
||||||
script = IsoScript._make(l.split(';'))
|
script = IsoScript._make(l.split(';'))
|
||||||
|
|||||||
Reference in New Issue
Block a user