From 37dd389aec214d3731afb3dcba9736198c69094f Mon Sep 17 00:00:00 2001 From: inpos Date: Sat, 28 Jan 2017 20:43:50 +0300 Subject: [PATCH] =?UTF-8?q?=D0=98=D0=B7=D0=BC=D0=B5=D0=BD=D0=B8=D0=BB=20?= =?UTF-8?q?=D0=BF=D1=80=D0=B8=D0=BD=D1=86=D0=B8=D0=BF=20=D0=B8=D0=B7=D0=B2?= =?UTF-8?q?=D0=BB=D0=B5=D1=87=D0=B5=D0=BD=D0=B8=D1=8F=20=D1=81=D1=81=D1=8B?= =?UTF-8?q?=D0=BB=D0=BE=D0=BA=20=D0=BD=D0=B0=20=D0=B2=D0=B8=D0=B4=D0=B5?= =?UTF-8?q?=D0=BE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- kodi-vk.inpos.ru/addon.xml | 1 - kodi-vk.inpos.ru/default.py | 15 +++------------ 2 files changed, 3 insertions(+), 13 deletions(-) diff --git a/kodi-vk.inpos.ru/addon.xml b/kodi-vk.inpos.ru/addon.xml index 34bafee..d7ddb27 100644 --- a/kodi-vk.inpos.ru/addon.xml +++ b/kodi-vk.inpos.ru/addon.xml @@ -5,7 +5,6 @@ name="VK Add-on" provider-name="inpos"> - image video audio diff --git a/kodi-vk.inpos.ru/default.py b/kodi-vk.inpos.ru/default.py index dc75a9e..d576d96 100644 --- a/kodi-vk.inpos.ru/default.py +++ b/kodi-vk.inpos.ru/default.py @@ -6,7 +6,6 @@ import urlparse import urllib2 from urllib import urlencode import re -import simplejson as json _VERSION = '0.0.1' @@ -336,27 +335,19 @@ class KodiVk: continue return conn def parse_vk_player_html(self, v_url): - p = re.compile('var\s+playerParams\s*=\s*(.*?);') + p = re.compile('"url(\d+)":"([^"]+)"') headers = {'User-Agent' : 'Kodi-vk/%s (linux gnu)' % (_VERSION,)} req = urllib2.Request(v_url, None, headers) http_res = urllib2.urlopen(req) if http_res.code != 200: return None html = http_res.read() - h_c_type = http_res.info()['Content-type'].split('charset=') - if len(h_c_type) < 2: - cs_re = re.compile('content="text/html; charset=([^"]+)"', re.I) - cs = cs_re.findall(html)[0] - else: - cs = h_c_type[1].strip() re_res = p.findall(html) if len(re_res) < 1: return None - playerParams = json.loads(re_res[0], encoding = cs) - v_keys = filter(lambda x: x.startswith('url'), playerParams['params'][0].keys()) res = {} - for k in v_keys: - res[k.lstrip('url')] = playerParams['params'][0][k] + for tup in re_res: + res[tup[0]] = tup[1].replace('\\', '') return res if __name__ == '__main__':