platform fix

This commit is contained in:
DiMartinoXBMC committed 2015-06-23 23:00:27 +03:00
1 parent 30df420b4f
commit ca92203b75
33 files changed
+1835 -1356

No files matched your search

+6 -7
View File
@@ -12,7 +12,6 @@ import xbmcgui
import Localization
from net import HTTP
try:
from sqlite3 import dbapi2 as sqlite
except:
@@ -33,7 +32,7 @@ class Cache:
def get(self, token, callback, *param):
cur = self.db.cursor()
cur.execute('select expire,data from cache where id=? limit 1', (token, ))
cur.execute('select expire,data from cache where id=? limit 1', (token,))
row = cur.fetchone()
cur.close()
@@ -67,7 +66,7 @@ class Cache:
def expire(self, expire):
# with rtrCache_lock:
cur = self.db.cursor()
cur.execute('delete from cache where addtime<?', (int(time.time()) - expire, ))
cur.execute('delete from cache where addtime<?', (int(time.time()) - expire,))
self.db.commit()
cur.close()
@@ -77,7 +76,7 @@ class Cache:
if os.path.getsize(self.filename) < size:
break
cur = self.db.cursor()
cur.execute('select id from cache order by addtime asc limit ?', (step, ))
cur.execute('select id from cache order by addtime asc limit ?', (step,))
rows = cur.fetchall()
if not rows:
cur.close()
@@ -129,7 +128,7 @@ class Cache:
cur.execute('create table cache(id varchar(255) unique, addtime integer, expire integer, data blob)')
cur.execute('create index time on cache(addtime asc)')
cur.execute('create table db_ver(version real)')
cur.execute('insert into db_ver(version) values(?)', (self.version, ))
cur.execute('insert into db_ver(version) values(?)', (self.version,))
self.db.commit()
cur.close()
@@ -137,7 +136,7 @@ class Cache:
scrapers = {'tvdb': 'TheTVDB.com', 'tmdb': 'TheMovieDB.org', 'kinopoisk': 'KinoPoisk.ru'}
ok = xbmcgui.Dialog().yesno(Localization.localize('Content Lists'),
Localization.localize('Do you want to preload full metadata?') + ' (%s)' % (
scrapers[os.path.basename(self.filename).split('.')[0]]),
scrapers[os.path.basename(self.filename).split('.')[0]]),
Localization.localize('It is highly recommended!'))
if ok:
return self.download()
@@ -146,7 +145,7 @@ class Cache:
def download(self):
dirname = os.path.dirname(self.filename)
zipname = os.path.basename(self.filename).replace('.db','') + '.zip'
zipname = os.path.basename(self.filename).replace('.db', '') + '.zip'
url = 'http://www.tat-store.ru/torrenter/' + zipname
self.http = HTTP()
response = self.http.fetch(url, download=os.path.join(dirname, zipname), progress=True)
+3 -5
View File
@@ -27,10 +27,8 @@ import math
import difflib
import translit
import LOGGER as Log
from HTTP import *
USER_AGENT = 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8_3) AppleWebKit/537.22 (KHTML, like Gecko) Chrome/25.0.1364.172 Safari/537.22'
# USER_AGENT = 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_7_2) AppleWebKit/534.51.22 (KHTML, like Gecko) Version/5.1.1 Safari/534.51.22'
ENCODING_PLEX = 'utf-8'
@@ -230,7 +228,7 @@ def scoreMediaTitleMatch(mediaName, mediaYear, title, altTitle, year, itemIndex)
elif yearDiff == 2:
yearPenalty = 25
score = score - yearPenalty
#print str(mediaYear)+' '+str(year)+' '+str(yearPenalty)
# print str(mediaYear)+' '+str(year)+' '+str(yearPenalty)
# Compute title penalty.
titlePenalty = computeTitlePenalty(mediaName, title)
@@ -364,8 +362,8 @@ def computeTitlePenalty(mediaName, title):
penaltyAlt = penaltyAlt + int(penaltyPerPart * (1 - partDiffRatio))
i = i + 1
penalty = min(penalty, penaltyAlt)
# print '++++++ DIFF("%s", "%s") = %g --> %d' % (mediaName.encode('utf8'), title.encode('utf8'), diffRatio, penalty)
# Log.Debug('++++++ DIFF("%s", "%s") = %g --> %d' % (mediaName.encode('utf8'), title.encode('utf8'), diffRatio, penalty))
# print '++++++ DIFF("%s", "%s") = %g --> %d' % (mediaName.encode('utf8'), title.encode('utf8'), diffRatio, penalty)
# Log.Debug('++++++ DIFF("%s", "%s") = %g --> %d' % (mediaName.encode('utf8'), title.encode('utf8'), diffRatio, penalty))
return penalty
return 0
+4 -4
View File
@@ -32,9 +32,11 @@ import pluginsettings as S
import translit
# MATCHER_MOVIE_DURATION = re.compile('\s*(\d+).*?', re.UNICODE | re.DOTALL)
#MATCHER_IMDB_RATING = re.compile('IMDb:\s*(\d+\.?\d*)\s*\(\s*([\s\d]+)\s*\)', re.UNICODE | re.DOTALL)
#MATCHER_IMDB_RATING = re.compile('IMDb:\s*(\d+\.?\d*)\s?\((.*)\)', re.UNICODE)
# MATCHER_IMDB_RATING = re.compile('IMDb:\s*(\d+\.?\d*)\s*\(\s*([\s\d]+)\s*\)', re.UNICODE | re.DOTALL)
# MATCHER_IMDB_RATING = re.compile('IMDb:\s*(\d+\.?\d*)\s?\((.*)\)', re.UNICODE)
USER_AGENT = 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8_3) AppleWebKit/537.22 (KHTML, like Gecko) Chrome/25.0.1364.172 Safari/537.22'
'''
@@ -171,5 +173,3 @@ class PageParser:
results.append([itemKinoPoiskId, itemTitle, itemYear, itemScore])
return results
+1 -3
View File
@@ -19,11 +19,9 @@ Simple transliteration
"""
# __id__ = __revision__ = "$Id: translit.py 102 2007-07-12 12:33:36Z the.pythy $"
#__url__ = "$URL: https://pythy.googlecode.com/svn/tags/pytils/0_2_2/pytils/translit.py $"
# __url__ = "$URL: https://pythy.googlecode.com/svn/tags/pytils/0_2_2/pytils/translit.py $"
import re
import sys
TRANSTABLE = (
(u"'", u"'"),
+4 -4
View File
@@ -11,7 +11,6 @@ import kinopoisk.LOGGER
import kinopoisk.pageparser
import kinopoisk.common
GENRE = {
'anime': 1750,
'biography': 22,
@@ -295,7 +294,7 @@ class KinoPoisk:
"""
def __init__(self, language='ru'):
dbname='kinopoisk.%s.db' % language
dbname = 'kinopoisk.%s.db' % language
self.cache = Cache(dbname, 1.0)
self.html = Clear()
@@ -463,8 +462,9 @@ class KinoPoisk:
if len(data) == 3:
i = 0
for mon in (
u'января', u'февраля', u'марта', u'апреля', u'мая', u'июня', u'июля', u'августа', u'сентября',
u'октября', u'ноября', u'декабря'):
u'января', u'февраля', u'марта', u'апреля', u'мая', u'июня', u'июля', u'августа',
u'сентября',
u'октября', u'ноября', u'декабря'):
i += 1
if mon == data[1]:
mon = str(i)
+1 -11
View File
@@ -12,10 +12,8 @@ import itertools
import xbmc
import xbmcgui
import xbmcaddon
import xbmcvfs
RE = {
'content-disposition': re.compile('attachment;\sfilename="*([^"\s]+)"|\s')
}
@@ -34,7 +32,6 @@ class HTTP:
if not xbmcvfs.exists(self._dirname):
xbmcvfs.mkdir(self._dirname)
def fetch(self, request, **kwargs):
self.con, self.fd, self.progress, self.cookies, self.request = None, None, None, None, request
@@ -74,7 +71,6 @@ class HTTP:
return self.response
def _opener(self):
build = [urllib2.HTTPHandler()]
@@ -101,7 +97,6 @@ class HTTP:
urllib2.install_opener(urllib2.build_opener(*build))
def _fetch(self):
params = {} if self.request.params is None else self.request.params
@@ -130,7 +125,7 @@ class HTTP:
':'.join([self.request.auth_username, self.request.auth_password])).strip())
self.con = urllib2.urlopen(req, timeout=self.request.timeout)
#self.con = urllib2.urlopen(req)
# self.con = urllib2.urlopen(req)
self.response.headers = self._headers(self.con.info())
if self.request.download:
@@ -141,7 +136,6 @@ class HTTP:
if self.request.cookies:
self.cookies.save(self.request.cookies)
def _download(self):
fd = open(self.request.download, 'wb')
if self.request.progress:
@@ -173,7 +167,6 @@ class HTTP:
self.response.filename = self.request.download
def _upload(self, upload, params):
res = []
boundary = mimetools.choose_boundary()
@@ -209,7 +202,6 @@ class HTTP:
result.append('')
return boundary, '\r\n'.join(result)
def _headers(self, raw):
headers = {}
for line in raw.headers:
@@ -221,7 +213,6 @@ class HTTP:
headers[tag] = value
return headers
def _progress(self, read, size, name):
res = []
if size < 0:
@@ -304,4 +295,3 @@ class HTTPResponse:
else:
args += ',body=None'
return '%s(%s)' % (self.__class__.__name__, args)
+6 -7
View File
@@ -383,7 +383,6 @@ def get_unicode_from_response(r):
except TypeError:
return r.content
# The unreserved URI characters (RFC 3986)
UNRESERVED_SET = frozenset(
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"
@@ -519,6 +518,7 @@ def should_bypass_proxies(url):
return False
def get_environ_proxies(url):
"""Return a dict of environment proxies."""
if should_bypass_proxies(url):
@@ -600,7 +600,6 @@ def parse_header_links(value):
return links
# Null bytes; no need to recreate these on each call to guess_json_utf
_null = '\x00'.encode('ascii') # encoding to ASCII for Python 3
_null2 = _null * 2
@@ -613,26 +612,26 @@ def guess_json_utf(data):
# determine the encoding. Also detect a BOM, if present.
sample = data[:4]
if sample in (codecs.BOM_UTF32_LE, codecs.BOM32_BE):
return 'utf-32' # BOM included
return 'utf-32' # BOM included
if sample[:3] == codecs.BOM_UTF8:
return 'utf-8-sig' # BOM included, MS style (discouraged)
if sample[:2] in (codecs.BOM_UTF16_LE, codecs.BOM_UTF16_BE):
return 'utf-16' # BOM included
return 'utf-16' # BOM included
nullcount = sample.count(_null)
if nullcount == 0:
return 'utf-8'
if nullcount == 2:
if sample[::2] == _null2: # 1st and 3rd are null
if sample[::2] == _null2: # 1st and 3rd are null
return 'utf-16-be'
if sample[1::2] == _null2: # 2nd and 4th are null
return 'utf-16-le'
# Did not detect 2 valid UTF-16 ascii-range characters
# Did not detect 2 valid UTF-16 ascii-range characters
if nullcount == 3:
if sample[:3] == _null3:
return 'utf-32-be'
if sample[1:] == _null3:
return 'utf-32-le'
# Did not detect a valid UTF-32 ascii-range character
# Did not detect a valid UTF-32 ascii-range character
return None
+2 -4
View File
@@ -2,13 +2,11 @@
# -*- coding: utf-8 -*-
import re
#import xbmc, xbmcgui, xbmcplugin, xbmcvfs
import xbmcaddon
# import xbmc, xbmcgui, xbmcplugin, xbmcvfs
from tvdb import TvDb
from tmdbs import TmDb
from kinopoisks import KinoPoisk
STATUS = {
'moder': (40501, 'FFFF0000'),
'check': (40502, 'FFFF0000'),
@@ -90,7 +88,7 @@ class Scrapers():
scraper = TvDb(language)
elif content == 'tmdb':
scraper = TmDb(language)
else: #if content == 'kinopoisk':
else: # if content == 'kinopoisk':
scraper = KinoPoisk(language)
name, search, year = item['label'], item['search'], item['year']