Изменил принцип извлечения ссылок на видео
This commit is contained in:
		
							parent
							
								
									0cf97194b1
								
							
						
					
					
						commit
						37dd389aec
					
				@ -5,7 +5,6 @@ name="VK Add-on"
 | 
				
			|||||||
provider-name="inpos">
 | 
					provider-name="inpos">
 | 
				
			||||||
<requires>
 | 
					<requires>
 | 
				
			||||||
  <import addon="xbmc.python" version="2.1"/>
 | 
					  <import addon="xbmc.python" version="2.1"/>
 | 
				
			||||||
  <import addon="script.module.simplejson" />
 | 
					 | 
				
			||||||
</requires>
 | 
					</requires>
 | 
				
			||||||
<extension point="xbmc.python.pluginsource" library="default.py">
 | 
					<extension point="xbmc.python.pluginsource" library="default.py">
 | 
				
			||||||
  <provides>image video audio</provides>
 | 
					  <provides>image video audio</provides>
 | 
				
			||||||
 | 
				
			|||||||
@ -6,7 +6,6 @@ import urlparse
 | 
				
			|||||||
import urllib2
 | 
					import urllib2
 | 
				
			||||||
from urllib import urlencode
 | 
					from urllib import urlencode
 | 
				
			||||||
import re
 | 
					import re
 | 
				
			||||||
import simplejson as json
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
_VERSION = '0.0.1'
 | 
					_VERSION = '0.0.1'
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -336,27 +335,19 @@ class KodiVk:
 | 
				
			|||||||
                    continue
 | 
					                    continue
 | 
				
			||||||
        return conn
 | 
					        return conn
 | 
				
			||||||
    def parse_vk_player_html(self, v_url):
 | 
					    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,)}
 | 
					        headers = {'User-Agent' : 'Kodi-vk/%s (linux gnu)' % (_VERSION,)}
 | 
				
			||||||
        req = urllib2.Request(v_url, None, headers)
 | 
					        req = urllib2.Request(v_url, None, headers)
 | 
				
			||||||
        http_res = urllib2.urlopen(req)
 | 
					        http_res = urllib2.urlopen(req)
 | 
				
			||||||
        if http_res.code != 200:
 | 
					        if http_res.code != 200:
 | 
				
			||||||
            return None
 | 
					            return None
 | 
				
			||||||
        html = http_res.read()
 | 
					        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)
 | 
					        re_res = p.findall(html)
 | 
				
			||||||
        if len(re_res) < 1:
 | 
					        if len(re_res) < 1:
 | 
				
			||||||
            return None
 | 
					            return None
 | 
				
			||||||
        playerParams = json.loads(re_res[0], encoding = cs)
 | 
					 | 
				
			||||||
        v_keys = filter(lambda x: x.startswith('url'), playerParams['params'][0].keys())
 | 
					 | 
				
			||||||
        res = {}
 | 
					        res = {}
 | 
				
			||||||
        for k in v_keys:
 | 
					        for tup in re_res:
 | 
				
			||||||
            res[k.lstrip('url')] = playerParams['params'][0][k]
 | 
					            res[tup[0]] = tup[1].replace('\\', '')
 | 
				
			||||||
        return res
 | 
					        return res
 | 
				
			||||||
 | 
					
 | 
				
			||||||
if __name__ == '__main__':
 | 
					if __name__ == '__main__':
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user