Re: Kartina и XBMC (windows,linux,mac на xbox не работает)
Я не использую XBMC.
Я не использую XBMC.
<player name="vlc" type="ExternalPlayer" audio="false" video="true"> <filename>/Applications/VLC.app/Contents/MacOS/VLC</filename> <args>--fullscreen</args> <hideconsole>true</hideconsole> <hidecursor>true</hidecursor> <forceontop>true</forceontop> </player>
<!-- Internet streams --> <rule name="streams" internetstream="true" player="vlc" />
# (c) Eugene Bond # eugene.bond@gmail.com # # kartina tv XML api import urllib2 from xml.dom import minidom from elementtree.ElementTree import parse, tostring from pprint import pprint from time import time import re import os KARTINA_API = 'http://iptv.kartina.tv/api/xml/%s' class kartina: def __init__(self, login, password): self.SID = None self.channels = [] self.channels_ttl = 0 self.login = login self.password = password def _request(self, cmd, params): if self.SID == None: if cmd != 'login': self._auth(self.login, self.password) url = KARTINA_API % cmd url = url + '?' + params if (self.SID != None): url = url + '&' + self.SID #log.info('Requesting %s' % url) req = urllib2.Request(url, None, {'User-agent': 'Mozilla/5.0', 'Connection': 'Close'}) res = parse(urllib2.urlopen(req)).getroot() self._errors_check(res) return res def _auth(self, user, password): response = self._request('login', 'login=%s&pass=%s' % (user, password)) if response.findtext('sid'): self.SID = '%s=%s' % (response.findtext('sid_name'), response.findtext('sid')) print tostring(response, 'UTF-8') def _errors_check(self, xml): if len(xml.findall('error')): print 'ERROR' print tostring(xml, 'UTF-8') self.SID = None def channel_list(self): if self.channels_ttl < time(): xmlChannels = self._request('channel_list', '') self.channels = [] print tostring(xmlChannels, 'UTF-8') for channel in xmlChannels.findall('groups/item/channels/item'): programm = channel.findtext('epg_progname') if not programm: programm = "" m = re.search("[^\n]+", programm) prog = "" desc = "" if m: prog = m.group(0).strip() if len(m.groups()) > 1: desc = m.group(1).strip() self.channels.append( ( channel.findtext('id'), channel.findtext('name'), "", "", prog, desc, channel.findtext('is_video'), channel.findtext('have_archive'), channel.findtext('protected') )) self.channels_ttl = time() + 600 return self.channels def channel_url(self, id): params = 'cid=%s&protect_code=%s' % (id, self.password) response = self._request('get_url', params) print tostring(response, "UTF-8") url = response.findtext('url') url = re.search("http[^ ]*.",url).group(0).replace("\"","").strip() #http/ts://217.19.222.34:18046/?ticket=W4z3WFdoSRnMMXHgYFq...md4ZGtVyT6mjgqGZk%3D #url = re.sub('http/ts(.*?)\s(.*)', 'http\\1', url) return url def test(self): pprint(self.channel_list()) pprint(self.channel_url(6)) if __name__ == '__main__': foo = kartina('147', '741') foo.test()
Комментарий