KoD 1.7.2
- corretto il playback in tutti i casi (torrent, autoplay, videoteca, libreria ecc..)\n- piccole migliorie prestazionali nella ricerca globale\n- fix trailer\n\n
This commit is contained in:
@@ -4,12 +4,6 @@
|
||||
# Use of this source code is governed by the 3-clause BSD license
|
||||
# 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
|
||||
|
||||
if sys.version_info[0] >= 3:
|
||||
|
||||
@@ -2,20 +2,22 @@
|
||||
# Use of this source code is governed by the 3-clause BSD license
|
||||
# that can be found in the LICENSE file.
|
||||
#
|
||||
import collections
|
||||
import functools
|
||||
from importlib import import_module
|
||||
|
||||
# from pkg_resources import iter_entry_points, EntryPoint
|
||||
from ..exceptions import LanguageConvertError, LanguageReverseError
|
||||
|
||||
try:
|
||||
# Python 3.3+
|
||||
from collections.abc import Mapping, MutableMapping
|
||||
except ImportError:
|
||||
from collections import Mapping, MutableMapping
|
||||
from importlib import import_module
|
||||
|
||||
# from https://github.com/kennethreitz/requests/blob/master/requests/structures.py
|
||||
class CaseInsensitiveDict(collections.MutableMapping):
|
||||
class CaseInsensitiveDict(MutableMapping):
|
||||
"""A case-insensitive ``dict``-like object.
|
||||
|
||||
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``.
|
||||
|
||||
All keys are expected to be strings. The structure remembers the
|
||||
@@ -66,7 +68,7 @@ class CaseInsensitiveDict(collections.MutableMapping):
|
||||
)
|
||||
|
||||
def __eq__(self, other):
|
||||
if isinstance(other, collections.Mapping):
|
||||
if isinstance(other, Mapping):
|
||||
other = CaseInsensitiveDict(other)
|
||||
else:
|
||||
return NotImplemented
|
||||
@@ -242,6 +244,7 @@ class ConverterManager(object):
|
||||
# if ep.name == name:
|
||||
# self.converters[ep.name] = ep.load()()
|
||||
# return self.converters[ep.name]
|
||||
|
||||
def parse(str):
|
||||
import re
|
||||
match = re.match('(?P<name>\w+) = (?P<module>[a-z0-9.]+):(?P<class>\w+)', str)
|
||||
|
||||
@@ -14,10 +14,10 @@ class OpenSubtitlesConverter(LanguageReverseConverter):
|
||||
def __init__(self):
|
||||
self.alpha3b_converter = language_converters['alpha3b']
|
||||
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),
|
||||
'scc': ('srp', None), 'mne': ('srp', 'ME')})
|
||||
self.codes = (self.alpha2_converter.codes | self.alpha3b_converter.codes | set(['pob', 'pb', 'scc', 'mne']))
|
||||
'scc': ('srp', None), 'mne': ('srp', 'ME'), 'zht': ('zho', 'TW')})
|
||||
self.codes = (self.alpha2_converter.codes | self.alpha3b_converter.codes | set(self.from_opensubtitles.keys()))
|
||||
|
||||
def convert(self, alpha3, country=None, script=None):
|
||||
alpha3b = self.alpha3b_converter.convert(alpha3, country, script)
|
||||
|
||||
@@ -8,9 +8,9 @@ from __future__ import unicode_literals
|
||||
from collections import namedtuple
|
||||
from functools import partial
|
||||
# from pkg_resources import resource_stream # @UnresolvedImport
|
||||
import os, io
|
||||
from .converters import ConverterManager
|
||||
from . import basestr
|
||||
import os, io
|
||||
|
||||
|
||||
COUNTRIES = {}
|
||||
|
||||
@@ -7,13 +7,13 @@
|
||||
from __future__ import unicode_literals
|
||||
from collections import namedtuple
|
||||
from functools import partial
|
||||
import os, io
|
||||
# from pkg_resources import resource_stream # @UnresolvedImport
|
||||
from .converters import ConverterManager
|
||||
from .country import Country
|
||||
from .exceptions import LanguageConvertError
|
||||
from .script import Script
|
||||
from . import basestr
|
||||
import os, io
|
||||
|
||||
|
||||
LANGUAGES = set()
|
||||
|
||||
@@ -5,11 +5,10 @@
|
||||
# that can be found in the LICENSE file.
|
||||
#
|
||||
from __future__ import unicode_literals
|
||||
|
||||
import os, io
|
||||
from collections import namedtuple
|
||||
# from pkg_resources import resource_stream # @UnresolvedImport
|
||||
from . import basestr
|
||||
import os, io
|
||||
|
||||
#: Script code to script name mapping
|
||||
SCRIPTS = {}
|
||||
|
||||
+1
-1
@@ -38,7 +38,7 @@ def query(name, type='A', server=DOH_SERVER, path="/dns-query", fallback=True):
|
||||
|
||||
try:
|
||||
req = _Request("https://%s%s?name=%s&type=%s" % (server, path, name, type), headers={"Accept": "application/dns-json"})
|
||||
content = _urlopen(req).read().decode()
|
||||
content = _urlopen(req, timeout=2).read().decode()
|
||||
reply = json.loads(content)
|
||||
|
||||
if "Answer" in reply:
|
||||
|
||||
+18
-3
@@ -38,6 +38,9 @@ from threading import Thread
|
||||
|
||||
__version__ = '1.7.0.dev0'
|
||||
|
||||
import xbmc
|
||||
kodi_monitor = xbmc.Monitor()
|
||||
|
||||
major_version = sys.version_info[0]
|
||||
if major_version < 3: # py <= 2.x
|
||||
if sys.version_info[1] < 5: # py <= 2.4
|
||||
@@ -172,6 +175,7 @@ class SqliteDict(DictClass):
|
||||
self.encode = encode
|
||||
self.decode = decode
|
||||
self.timeout = timeout
|
||||
self.cache = {}
|
||||
|
||||
logger.info("opening Sqlite table %r in %r" % (tablename, filename))
|
||||
self.conn = self._new_conn()
|
||||
@@ -234,7 +238,9 @@ class SqliteDict(DictClass):
|
||||
def iteritems(self):
|
||||
GET_ITEMS = 'SELECT key, value FROM "%s" ORDER BY rowid' % self.tablename
|
||||
for key, value in self.conn.select(GET_ITEMS):
|
||||
yield key, self.decode(value)
|
||||
ret = key, self.decode(value)
|
||||
self.cache[key] = ret[1]
|
||||
yield ret
|
||||
|
||||
def keys(self):
|
||||
return self.iterkeys() if major_version > 2 else list(self.iterkeys())
|
||||
@@ -250,11 +256,15 @@ class SqliteDict(DictClass):
|
||||
return self.conn.select_one(HAS_ITEM, (key,)) is not None
|
||||
|
||||
def __getitem__(self, key):
|
||||
if key in self.cache.keys():
|
||||
return self.cache[key]
|
||||
GET_ITEM = 'SELECT value FROM "%s" WHERE key = ?' % self.tablename
|
||||
item = self.conn.select_one(GET_ITEM, (key,))
|
||||
if item is None:
|
||||
raise KeyError(key)
|
||||
return self.decode(item[0])
|
||||
ret = self.decode(item[0])
|
||||
self.cache[key] = ret
|
||||
return ret
|
||||
|
||||
def __setitem__(self, key, value):
|
||||
if self.flag == 'r':
|
||||
@@ -264,6 +274,7 @@ class SqliteDict(DictClass):
|
||||
self.conn.execute(ADD_ITEM, (key, self.encode(value)))
|
||||
if self.autocommit:
|
||||
self.commit()
|
||||
self.cache[key] = value
|
||||
|
||||
def __delitem__(self, key):
|
||||
if self.flag == 'r':
|
||||
@@ -275,6 +286,7 @@ class SqliteDict(DictClass):
|
||||
self.conn.execute(DEL_ITEM, (key,))
|
||||
if self.autocommit:
|
||||
self.commit()
|
||||
del self.cache[key]
|
||||
|
||||
def update(self, items=(), **kwds):
|
||||
if self.flag == 'r':
|
||||
@@ -292,6 +304,7 @@ class SqliteDict(DictClass):
|
||||
self.update(kwds)
|
||||
if self.autocommit:
|
||||
self.commit()
|
||||
self.cache.update(items)
|
||||
|
||||
def __iter__(self):
|
||||
return self.iterkeys()
|
||||
@@ -305,6 +318,7 @@ class SqliteDict(DictClass):
|
||||
self.conn.commit()
|
||||
self.conn.execute(CLEAR_ALL)
|
||||
self.conn.commit()
|
||||
self.cache = {}
|
||||
|
||||
@staticmethod
|
||||
def get_tablenames(filename):
|
||||
@@ -403,6 +417,7 @@ class SqliteMultithread(Thread):
|
||||
self.log = logging.getLogger('sqlitedict.SqliteMultithread')
|
||||
self.start()
|
||||
|
||||
|
||||
def run(self):
|
||||
try:
|
||||
if self.autocommit:
|
||||
@@ -428,7 +443,7 @@ class SqliteMultithread(Thread):
|
||||
self._sqlitedict_thread_initialized = True
|
||||
|
||||
res = None
|
||||
while True:
|
||||
while not kodi_monitor.abortRequested():
|
||||
req, arg, res, outer_stack = self.reqs.get()
|
||||
if req == '--close--':
|
||||
assert res, ('--close-- without return queue', res)
|
||||
|
||||
@@ -60,6 +60,7 @@ class UnshortenIt(object):
|
||||
|
||||
def unshorten(self, uri, type=None):
|
||||
code = 0
|
||||
originalUri = uri
|
||||
while True:
|
||||
uri = uri.strip()
|
||||
oldUri = uri
|
||||
@@ -114,6 +115,8 @@ class UnshortenIt(object):
|
||||
|
||||
logger.info(uri)
|
||||
|
||||
if originalUri == uri and logger.testMode:
|
||||
raise Exception('Not un-shortened link: ' + uri)
|
||||
return uri, code
|
||||
|
||||
def unwrap_30x(self, uri, timeout=10):
|
||||
|
||||
Reference in New Issue
Block a user