def getVideoLink(url,prefix,name,desc): logDbg("getVideoLink()") req = urllib2.Request(url) req.add_header('User-Agent', _UserAgent_) response = urllib2.urlopen(req) httpdata = response.read().decode("windows-1250") response.close() match = re.compile('_fn\(t\)(.+?)</script>', re.S).findall(httpdata) if match: items = re.compile('var rev=(.+?);.+?"file", escape\("(.+?)"\+ rev \+"(.+?)"\)\);', re.S).findall(match[0]) if items: rev,link1,link2 = items[0] link = link1+str(rev)+link2 req = urllib2.Request(link) req.add_header('User-Agent', _UserAgent_) response = urllib2.urlopen(req) httpdata = response.read().decode("utf-8") response.close() item = re.compile('<title>(.+?)</title>.+?<location>(.+?)</location>.+?<image>(.+?)</image>', re.S).findall(httpdata) if item: title, link, img = item[0] addLink(prefix+name,link,img,desc) else: logErr("Video location not found!") else: logErr("Video informations not found!") else: logErr("Player script not found!")
def VIDEOLINK(url, name): req = urllib2.Request(url) req.add_header('User-Agent', _UserAgent_) response = urllib2.urlopen(req) httpdata = response.read() response.close() thumb = re.compile('<meta property="og:image" content="(.+?)" />').findall( httpdata) popis = re.compile( '<meta property="og:description" content="(.+?)" />').findall(httpdata) try: desc = popis[0] except: desc = name #Ziskani adresy configu ze stranky poradu, zacina u parametru configUrl - jen jsem slepil vsechny parametry k sobe a nacetl httpdata = httpdata.replace("\r", "").replace("\n", "").replace("\t", "") parametry = re.compile('params = (.+?);').findall(httpdata) linkgenerator = parametry[0].replace(" ", "").replace("?',", "?").replace( "{configUrl:'", "").replace(":'", "=").replace("',", "&").replace( "'+'", "").replace("'}", "").replace(",", "").replace(":parseInt(", "") req = urllib2.Request(linkgenerator) req.add_header('User-Agent', _UserAgent_) response = urllib2.urlopen(req) httpdata = response.read() response.close() #Dolovani rtmp adresy z configu rtmp_url = re.compile('src":"(.+?)"').findall(httpdata) rtmp_url = rtmp_url[0].replace("\\", "") #Slozeni vysledneho linku, sklada se z adresy rtmp_url a pak jeste jednou z adresy rtmp_url, ale ta uz musi byt rozdelena a slouzi jako parametry playpath a tcUrl #rtmp://nova-voyo-cz-pc.service.cdn.cra.cz/vod/&mp4:oldcdn/2015/11/06/1561560/2015-11-19_ulice-218_cyklus_dil_2919-b041884-np-mp4-lq.mp4?SIGV=2&IS=0&ET=1448109213&CIP=31.30.37.226&KO=1&KN=1&US=2338c0708283dbc363f88ecdbf53233c27d52ef3 tcUrl=rtmp://nova-voyo-cz-pc.service.cdn.cra.cz/vod playpath=mp4:oldcdn/2015/11/06/1561560/2015-11-19_ulice-218_cyklus_dil_2919-b041884-np-mp4-lq.mp4?SIGV=2&IS=0&ET=1448109213&CIP=31.30.37.226&KO=1&KN=1&US=2338c0708283dbc363f88ecdbf53233c27d52ef3 addLink(name, rtmp_url, thumb[0], desc)
def VIDEOLINK(url,name): req = urllib2.Request(url) req.add_header('User-Agent', _UserAgent_) response = urllib2.urlopen(req) httpdata = response.read() response.close() cast_url = urlparse(url) videoid = re.compile('videoId=(.+?)&').findall(httpdata) playlisturl = 'http://'+cast_url[1]+'/services/Video.php?clip='+videoid[0] print playlisturl doc = read_page(playlisturl) title = str(doc.event['title'].encode('utf-8')) thumb = str(doc.event['image']) items = doc.find('files') for item in items.findAll('file'): link = str(item['url']) cesta = str(item['path']) kvalita = str(item['label']) server = re.compile('rtmp://(.+?)/').findall(link) name = kvalita+ ' - ' + title tcurl = 'rtmp://'+server[0] swfurl = 'http://b.static.huste.tv/fileadmin/templates/swf/HusteMainPlayer.swf' rtmp_url = tcurl+' playpath='+cesta+' pageUrl='+url+' swfUrl='+swfurl+' swfVfy=true' print name,rtmp_url,thumb[0] addLink(name,rtmp_url,thumb[0],name)
def CATEGORIES(url, page): # rewrite by MN html = get_url(url) section = re.search( "<div class=\"b-show-listing\".*?ady</h3>(.*?)</section>", html, re.S) if section != None: articles = re.findall("<article(.*?)</article>", section.group(1), re.S) if articles != None: for article in articles: url = re.search("<a href=\"(.*?)\"", article, re.S) or "" title = re.search("<a.*?title=\"(.*?)\"", article, re.S) or "" thumb = re.search("<img.*?data-original=\"(.*?)\"", article, re.S) or "" if url != "" and title != "": if thumb != "": addDir( title.group(1).replace(' ', ' '), url.group(1), 2, thumb.group(1), 1) else: addDir( title.group(1).replace(' ', ' '), url.group(1), 2, None, 1) else: addLink("[COLOR red]Chyba načítání pořadů[/COLOR]", "#", None, "") else: addLink("[COLOR red]Chyba načítání kategorie[/COLOR]", "#", None, "")
def VIDEOLINK(url,name): req = urllib2.Request(url) req.add_header('User-Agent', _UserAgent_) response = urllib2.urlopen(req) httpdata = response.read() response.close() video_link = re.compile('file: "(.+?)"').findall(httpdata) addLink(name,video_link[0],icon,name)
def VIDEOLINK(url): doc = read_page(url) name = re.compile('<title>(.+?)</title>').findall(str(doc)) thumb = re.compile('<link rel="image_src" href="(.+?)"').findall(str(doc)) low_hq = re.compile("'file','(.+?)'").findall(str(doc)) high_hq = re.compile("'hd.file','(.+?)'").findall(str(doc)) if __settings__.get_setting('kvalita_sel'): addLink('LQ '+name[0],low_hq[1],thumb[0],name[0]) if __settings__.get_setting('kvalita_sel'): addLink('HQ '+name[0],high_hq[0],thumb[0],name[0])
def VIDEOLINK(url, name): data = getJsonDataFromUrl(url) name = data[u'name'] thumb = makeImageUrl(data[u'image']) popis = data[u'detail'] for item in data[u'video_qualities']: try: for fmt in item[u'formats']: if fmt[u'type'] == 'video/mp4': stream_url = fmt[u'source'] quality = fmt[u'quality'] addLink(quality + ' ' + name, stream_url, thumb, popis) except: continue
def VIDEOLINK(url,name): #print 'VIDEOLINK *********************************' + str(url) doc = read_page(url) # zjisteni nazvu a popisu aktualniho dilu article = doc.find('article', 'b-article b-article-main') name = article.find('h3').getText(" ").encode('utf-8') desc = article.find('div', 'e-description').getText(" ").encode('utf-8') main = doc.find('main') url = main.find('iframe')['src'] req = urllib2.Request(url) req.add_header('User-Agent', _UserAgent_) response = urllib2.urlopen(req) httpdata = response.read() response.close() httpdata = httpdata.replace("\r","").replace("\n","").replace("\t","") thumb = re.compile('<meta property="og:image" content="(.+?)">').findall(httpdata) if (len(thumb) > 0): thumb = thumb[0] else: thumb = '' renditions = re.compile('renditions: \[(.+?)\]').findall(httpdata) if (len(renditions) > 0): renditions = re.compile('\'(.+?)\'').findall(renditions[0]) bitrates = re.compile('src = {(.+?)\[(.+?)\]').findall(httpdata); if (len(bitrates) > 0): urls = re.compile('\'(.+?)\'').findall(bitrates[0][1]) for num, url in enumerate(urls): if num < len(renditions): addLink(renditions[num] + ' - ' + name, url, thumb, desc) else: addLink(name, url, thumb, desc) else: xbmcgui.Dialog().ok('Chyba', 'Video nelze přehrát', '', '') # dalsi dily poradu for article in doc.findAll('article', 'b-article b-article-no-labels'): url = article.a['href'].encode('utf-8') title = article.a['title'].encode('utf-8') thumb = article.a.div.img['data-original'].encode('utf-8') addDir(title, url, 3, thumb, 1)
def INDEX(url): doc = read_page(url) items = doc.find('table', 'norm') items = doc.find('tbody') for item in items.findAll('tr'): name = re.compile('<a href=".+?">(.+?)</a><br />').findall(str(item)) link = 'http://www.b-tv.cz'+str(item.a['href']) thumb = str(item.img['src']) try: popis = item.find('p') popis = popis.getText(" ").encode('utf-8') except: popis = name[0] doc = read_page(link) video_url = re.compile('file=(.+?)&').findall(str(doc)) addLink(name[0],'http://www.b-tv.cz'+video_url[0],'http://www.b-tv.cz'+thumb,popis)
def HOMEPAGE(url, page): # new by MN html = get_url(url) # carousel sections = re.search( "<section class=\"b-main-section\">.*?<div class=\"b-carousel\">.*?<a href=\"(.*?)\" title=\"(.*?)\">.*?<img.*?data-original=\"(.*?)\"", html, re.S) if sections != None: addDir( sections.group(2).replace(' ', ' '), sections.group(1), 3, sections.group(3), 1) # articles sections = re.findall( "<h3 class=\"e-articles-title\">(.*?)</h3>(.*?)</section>", html, re.S) if sections != None: for section in sections: category = re.sub(r'<[^>]*?>', '', section[0]).replace( ' ', ' ').replace(' ', '').replace('\n', '') articles = re.findall("<article(.*?)</article>", section[1], re.S) if category == "TOP POŘADY": Hmode = 2 else: Hmode = 3 if articles != None: for article in articles: url = re.search("<a href=\"(.*?)\"", article, re.S) or "" title = re.search("<a.*?title=\"(.*?)\"", article, re.S) or "" thumb = re.search("<img.*?data-original=\"(.*?)\"", article, re.S) or "" if url != "" and title != "": if thumb != "": addDir( category + " - " + title.group(1).replace(' ', ' '), url.group(1), Hmode, thumb.group(1), 1) else: addDir( category + " - " + title.group(1).replace(' ', ' '), url.group(1), Hmode, None, 1) else: addLink("[COLOR red]Chyba načítání pořadů[/COLOR]", "#", None, "") else: addLink("[COLOR red]Chyba načítání kategorie[/COLOR]", "#", None, "")
def VIDEOLINK(url,name): req = urllib2.Request(url) req.add_header('User-Agent', _UserAgent_) response = urllib2.urlopen(req) httpdata = response.read() response.close() thumb = re.compile('<meta property="og:image" content="(.+?)" />').findall(httpdata) popis = re.compile('<meta property="og:description" content="(.+?)" />').findall(httpdata) config = re.compile('config.php?(.+?)["\'],').findall(httpdata) config = 'http://tn.nova.cz/bin/player/flowplayer/config.php'+config[0] try: desc = popis[0] except: desc = name req = urllib2.Request(config) req.add_header('User-Agent', _UserAgent_) response = urllib2.urlopen(req) httpdata = response.read() response.close() match = re.compile("'(.+?)';").findall(httpdata) key = 'EaDUutg4ppGYXwNMFdRJsadenFSnI6gJ' aes_decrypt = aes.decrypt(match[0],key,128).encode('utf-8') aes_decrypt = aes_decrypt.replace('\/','/') secret_token = re.compile('secret":"(.+?)"', re.S).findall(aes_decrypt) mediaid = re.compile('"mediaId":(.+?),').findall(aes_decrypt) datum = datetime.datetime.now() timestamp = datum.strftime('%Y%m%d%H%M%S') videoid = urllib.quote(nova_app_id + '|' + mediaid[0]) md5hash = nova_app_id + '|' + mediaid[0] + '|' + timestamp + '|' + secret_token[0] try: md5hash = hashlib.md5(md5hash) except: md5hash = md5.new(md5hash) signature = urllib.quote(base64.b64encode(md5hash.digest())) config = nova_service_url + '?t=' + timestamp + '&d=1&tm=nova&h=0&c='+videoid+ '&s='+signature req = urllib2.Request(config) req.add_header('User-Agent', _UserAgent_) response = urllib2.urlopen(req) httpdata = response.read() response.close() baseurl = re.compile('<baseUrl>(.+?)</baseUrl>').findall(httpdata) streamurl = re.compile('<media>\s<quality>(.+?)</quality>.\s<url>(.+?)</url>\s</media>').findall(httpdata) swfurl = 'http://voyo.nova.cz/static/shared/app/flowplayer/13-flowplayer.commercial-3.1.5-19-003.swf' for kvalita,odkaz in streamurl: rtmp_url = baseurl[0]+'/'+odkaz addLink(name,rtmp_url,thumb[0],desc)
def LIVE(url, relogin=False): if not (settings['username'] and settings['password']): addLink("[COLOR red]Nastavte prosím moja.markiza.sk konto[/COLOR]","#",None,"") return # xbmcgui.Dialog().ok('Chyba', 'Nastavte prosím moja.markiza.sk konto', '', '') # xbmcplugin.setResolvedUrl(int(sys.argv[1]), False, xbmcgui.ListItem()) # raise RuntimeError cj = MozillaCookieJar() opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(cj)) if not relogin: try: cj.load(cookiepath) except IOError: relogin=True if relogin: response = opener.open(loginurl).read() token = re.search(r'name=\"_token_\" value=\"(\S+?)\">',response).group(1) logindata = urllib.urlencode({'email': settings['username'], 'password': settings['password'], '_token_': token, '_do': 'content1-loginForm-form-submit' }) + '&login=Prihl%C3%A1si%C5%A5+sa' opener.open(loginurl, logindata) log('Saving cookies') cj.save(cookiepath) response = opener.open(url).read() link = re.search(r'<iframe src=\"(\S+?)\"',response).group(1) #https://videoarchiv.markiza.sk/api/v1/user/live try: response = opener.open(link).read() except urllib2.HTTPError: #handle expired cookies if relogin: addLink("[COLOR red]Skontrolujte prihlasovacie údaje[/COLOR]","#",None,"") return # xbmcgui.Dialog().ok('Chyba', 'Skontrolujte prihlasovacie údaje', '', '') # raise RuntimeError # loop protection else: LIVE(url, relogin=True) return opener.addheaders = [('Referer',link)] link = re.search(r'<iframe src=\"(\S+?)\"',response).group(1) #https://media.cms.markiza.sk/embed/ response = opener.open(link).read() link = re.search(r'\"hls\": \"(\S+?)\"',response).group(1) #https://h1-s6.c.markiza.sk/hls/markiza-sd-master.m3u8 response = opener.open(link).read() cookies='|Cookie=' for cookie in cj: cookies+=cookie.name+'='+cookie.value+';' cookies=cookies[:-2]
def VIDEOLINK(url,name): #print 'VIDEOLINK *********************************' + str(url) doc = read_page(url) main = doc.find('main') url = main.find('iframe')['src'] req = urllib2.Request(url) req.add_header('User-Agent', _UserAgent_) response = urllib2.urlopen(req) httpdata = response.read() response.close() httpdata = httpdata.replace("\r","").replace("\n","").replace("\t","") thumb = re.compile('<meta property="og:image" content="(.+?)">').findall(httpdata) if (len(thumb) > 0): thumb = thumb[0] else: thumb = '' desc = re.compile('<meta name="description" content="(.+?)">').findall(httpdata) if (len(desc) > 0): desc = desc[0] else: desc = '' name = re.compile('<meta property="og:title" content="(.+?)">').findall(httpdata) if (len(name) > 0): name = name[0] else: name = '?' renditions = re.compile('renditions: \[(.+?)\]').findall(httpdata) if (len(renditions) > 0): renditions = re.compile('\'(.+?)\'').findall(renditions[0]) bitrates = re.compile('src = {(.+?)\[(.+?)\]').findall(httpdata); if (len(bitrates) > 0): urls = re.compile('\'(.+?)\'').findall(bitrates[0][1]) for num, url in enumerate(urls): addLink(renditions[num],url,thumb,desc) else: xbmcgui.Dialog().ok('Chyba', 'Video nelze přehrát', '', '')
def VIDEOLINK(url): # print 'VIDEOLINK *********************************' + str(url) doc = read_page(url) main = doc.find('main') if (not main.find('iframe')): addLink("[COLOR red]Platnost tohoto videa už vypršala[/COLOR]","#",None,"") # xbmcgui.Dialog().ok('Chyba', 'Platnost tohoto videa už vypršala', '', '') return False url = main.find('iframe')['src'] httpdata = fetchUrl(url) httpdata = httpdata.replace("\r","").replace("\n","").replace("\t","") if '<title>Error</title>' in httpdata: error=re.search('<h2 class="e-title">(.*?)</h2>', httpdata).group(1) #Video nie je dostupné vo vašej krajine addLink("[COLOR red]"+error+"[/COLOR]","#",None,"") # xbmcgui.Dialog().ok('Chyba', error, '', '') return False url = re.search('src = {\s*\"hls\": [\'\"](.+?)[\'\"]\s*};', httpdata) if (url): url=url.group(1) thumb = re.search('<meta property="og:image" content="(.+?)">', httpdata) thumb = thumb.group(1) if thumb else '' desc = re.search('<meta name="description" content="(.+?)">', httpdata) desc = desc.group(1) if desc else '' name = re.search('<meta property="og:title" content="(.+?)">', httpdata) name = name.group(1) if name else '?' httpdata = fetchUrl(url) streams = re.compile('RESOLUTION=\d+x(\d+).*\n([^#].+)').findall(httpdata) url = url.rsplit('/', 1)[0] + '/' streams.sort(key=lambda x: int(x[0]),reverse=True) for (bitrate, stream) in streams: bitrate=' [' + bitrate + 'p]' addLink(name + bitrate,url + stream,thumb,desc) else: #televizne noviny url = re.search('relatedLoc: [\'\"](.+?)[\'\"]', httpdata).group(1) url = url.replace("\/","/") httpdata = fetchUrl(url) decoded=json.loads(httpdata) for chapter in decoded["playlist"]: name=chapter["contentTitle"] url=chapter["src"]["hls"] url=url.rsplit('/', 1)[0] + '/' + 'index-f3-v1-a1.m3u8' #auto select 720p quality thumb=chapter.get("thumbnail",'') desc=chapter["contentTitle"] addLink(name,url,thumb,desc)
def VIDEOLINK_LIVE(channel, name): if not islogged_in(): log_in(username, password) r = gen_random_decimal(0, 99999999999999) livestream_params = {'channel':channel, 'r':r} livestream_url = livestream_php_url + '?' + urllib.urlencode(livestream_params) request = urllib2.Request(livestream_url) request.add_header("Referer", 'http://voyo.markiza.sk/zive-vysielanie/') request.add_header("Accept", "application/json, text/javascript, */*") request.add_header("X-Requested-With", "XMLHttpRequest") request.add_header("User-Agent", _UserAgent_) response = urllib2.urlopen(request) data = response.read() response.close() video = re.search(VIDEOLINK_LIVE_RE, data, re.DOTALL) if video is not None: link = video.group('url') + '/' + video.group('playpath') + " pageUrl=" + livestream_php_url + '?' + channel + " live=1" addLink(name, link, None)
def LIVE(url): doc = read_page(url) zapasy = doc.find('events') for zapas in zapasy.findAll('event'): title = str(zapas['title'].encode('utf-8')) nahled = str(zapas['large_image']) cas = str(zapas['starttime']) cas = cas.replace("+01:00", ""); if hasattr(datetime, 'strptime'): #python 2.6 strptime = datetime.strptime else: #python 2.4 equivalent strptime = lambda date_string, format: datetime(*(time.strptime(date_string, format)[0:6])) cas = strptime(cas, '%Y-%m-%dT%H:%M:%S') cas = cas.strftime('%d.%m. %H:%M') archiv = str(zapas['archive']) link = str(zapas['url']) #print title,nahled,cas,archiv,link try: soubory = zapas.find('files') for soubor in soubory.findAll('file'): rtmp_url = str(soubor['url']) kvalita = str(soubor['quality']) rtmp_cesta = str(soubor['path']) #print rtmp_url,kvalita,rtmp_cesta server = re.compile('rtmp://(.+?)/').findall(rtmp_url) tcurl = 'rtmp://'+server[0] swfurl = 'http://c.static.huste.tv/fileadmin/templates/swf/HusteMainPlayer.swf' if archiv == "1": rtmp_url = tcurl+' playpath='+rtmp_cesta+' pageUrl=http://live.huste.tv/ swfurl='+swfurl+' swfVfy=true' name = 'Záznam - ' + cas + ' ' + title else: rtmp_url = tcurl+' playpath='+rtmp_cesta+' pageUrl=http://live.huste.tv/ swfurl='+swfurl+' swfVfy=true live=true' name = 'Live - ' + cas + ' ' + title print name,rtmp_url,nahled addLink(name,rtmp_url,nahled,name) except: name = 'Nedostupné - ' + cas + ' ' + title addLink(name,'',nahled,name) continue
def EPISODES(url): # print 'EPISOD9ES *********************************' + str(url) try: doc = read_page(url) except urllib2.HTTPError: addLink("[COLOR red]Stranka nenalezena: "+url+"[/COLOR]","#",None,"") # xbmcgui.Dialog().ok('Chyba', 'CHYBA 404: STRÁNKA NEBOLA NÁJDENÁ', '', '') return False for article in doc.findAll('article', 'b-article b-article-text b-article-inline'): url = article.a['href'].encode('utf-8') title = article.a.find('div', {'class': 'e-info'}).getText(" ").encode('utf-8').strip() thumb = article.a.div.img['data-original'].encode('utf-8') addDir(title,url,3,thumb) for section in doc.findAll('section', 'b-main-section'): if section.div.h3.getText(" ").encode('utf-8') == 'Celé epizódy': for article in section.findAll('article'): url = article.a['href'].encode('utf-8') if (article.a.find('div', {'class': 'e-date'})): title = 'Celé epizódy - ' + article.a.find('div', {'class': 'e-info'}).getText(" ").encode('utf-8') else: title = 'Celé epizódy - ' + article.a['title'].encode('utf-8') thumb = article.a.div.img['data-original'].encode('utf-8') addDir(title,url,3,thumb) if section.div.h3.getText(" ").encode('utf-8') == 'Mohlo by sa vám páčiť': for article in section.findAll('article'): url = article.a['href'].encode('utf-8') title = 'Mohlo by sa vám páčiť - ' + article.a.find('div', {'class': 'e-info'}).getText(" ").encode('utf-8') thumb = article.a.div.img['data-original'].encode('utf-8') addDir(title,url,3,thumb) if section.div.h3.getText(" ").encode('utf-8') == 'Zo zákulisia': for article in section.findAll('article'): url = article.a['href'].encode('utf-8') title = 'Zo zákulisia - ' + article.a['title'].encode('utf-8') thumb = article.a.div.img['data-original'].encode('utf-8') addDir(title,url,3,thumb)
def VIDEOLINK_TEST(url, name): req = urllib2.Request(url) req.add_header('User-Agent', _UserAgent_) response = urllib2.urlopen(req) httpdata = response.read() response.close() mediaid = re.compile('mainVideo = new mediaData\(.+?, .+?, (.+?),').findall(httpdata) thumb = re.compile('<link rel="image_src" href="(.+?)" />').findall(httpdata) popis = re.compile('<meta name="description" content="(.+?)" />').findall(httpdata) datum = datetime.datetime.now() timestamp = datum.strftime('%Y%m%d%H%M%S') videoid = urllib.quote(nova_app_id + '|' + mediaid[0]) md5hash = nova_app_id + '|' + mediaid[0] + '|' + timestamp + '|' + secret_token try: md5hash = hashlib.md5(md5hash) except: md5hash = md5.new(md5hash) signature = urllib.quote(base64.b64encode(md5hash.digest())) config = nova_service_url + '?t=' + timestamp + '&d=1&tm=nova&h=0&c=' + videoid + '&s=' + signature print config try: desc = popis[0] except: desc = name req = urllib2.Request(config) req.add_header('User-Agent', _UserAgent_) response = urllib2.urlopen(req) httpdata = response.read() response.close() if __settings__.get_setting('test_nastaveni'): print httpdata error_secret_token = re.compile('<errorCode>(.+?)</errorCode>').findall(httpdata) try: chyba = int(error_secret_token[0]) except: chyba = 0 if chyba == 2: print 'Nesprávné tajné heslo' showWarning(u"Doplněk DMD VOYO Nesprávné tajné heslo!") #__settings__.open_settings(session) elif chyba == 1: print 'Špatné časové razítko' showError(u"Doplněk DMD VOYO Pořad lze přehrát pouze na webu Voyo.cz!") #xbmc.executebuiltin("XBMC.Notification('Doplněk DMD VOYO','Pořad lze přehrát pouze na webu Voyo.cz!',30000,"+icon+")") elif chyba == 0: baseurl = re.compile('<baseUrl>(.+?)</baseUrl>').findall(httpdata) streamurl = re.compile('<media>\s<quality>(.+?)</quality>.\s<url>(.+?)</url>\s</media>').findall(httpdata) for kvalita, odkaz in streamurl: #print kvalita,odkaz if re.match('hd', kvalita, re.U): urlhd = odkaz.encode('utf-8') elif re.match('hq', kvalita, re.U): urlhq = odkaz.encode('utf-8') elif re.match('lq', kvalita, re.U): urllq = odkaz.encode('utf-8') print urlhq, urllq swfurl = 'http://voyo.nova.cz/static/shared/app/flowplayer/13-flowplayer.commercial-3.1.5-19-003.swf' if __settings__.get_setting('test_nastaveni'): rtmp_url_lq = baseurl[0] + ' playpath=' + urllq + ' pageUrl=' + url + ' swfUrl=' + swfurl + ' swfVfy=true token=' + rtmp_token rtmp_url_hq = baseurl[0] + ' playpath=' + urlhq + ' pageUrl=' + url + ' swfUrl=' + swfurl + ' swfVfy=true token=' + rtmp_token try: rtmp_url_hd = baseurl[0] + ' playpath=' + urlhd + ' pageUrl=' + url + ' swfUrl=' + swfurl + ' swfVfy=true token=' + rtmp_token except: rtmp_url_hd = 0 else: rtmp_url_lq = baseurl[0] + ' playpath=' + urllq rtmp_url_hq = baseurl[0] + ' playpath=' + urlhq try: rtmp_url_hd = baseurl[0] + ' playpath=' + urlhd except: rtmp_url_hd = 0 if __settings__.get_setting('kvalita_sel') == "HQ": addLink("HQ " + name, rtmp_url_hq, icon, desc) elif __settings__.get_setting('kvalita_sel') == "LQ": addLink("LQ " + name, rtmp_url_lq, icon, desc) elif __settings__.get_setting('kvalita_sel') == "HD": if rtmp_url_hd == 0: addLink("HQ " + name, rtmp_url_hq, icon, desc) else: addLink("HD " + name, rtmp_url_hd, icon, desc) else: addLink("HQ " + name, rtmp_url_hq, icon, desc)
def VIDEOLINK(url, name, live=False): def gen_dev_hash(): r = gen_random_decimal(0, 99999999999999) device_params = {'x':'device', 'a':'generateNewHash', 'userId':urllib.quote(username), 'r':r} devicehash_url = wallet_php_url + '?' + urllib.urlencode(device_params) print 'generating new devicehash' request = create_req(devicehash_url) response = urllib2.urlopen(request) data = json.load(response) response.close() return data[u'hash'] def add_dev(hash): r = gen_random_decimal(0, 99999999999999) client_details = '{"b":"FF","bv":"18.0","ua":"Mozilla/5.0 (Windows NT 6.1; WOW64; rv:18.0) Gecko/20100101 Firefox/18.0"}' adddevice_params = {'x':'device', 'a':'add', 'deviceCode':'PC', 'deviceHash':hash, 'client':client_details, 'r':r} adddevice_url = wallet_php_url + '?' + urllib.urlencode(adddevice_params) print 'trying to add new device' request = create_req(adddevice_url) response = urllib2.urlopen(request) data = json.load(response) response.close() succ = data[u'ok'] dev_hash = data[u'hash'] if not succ: print 'device cannot be added, exception or "Maximum of free devices already reached"' showError(data[u'msg']) else: print 'device was successfully added' return dev_hash if not islogged_in(): log_in(username, password) if dev_hash == "": new_devhash = gen_dev_hash() add_dev(new_devhash) __settings__.setSetting('devhash', new_devhash) # to remove device # http://voyo.nova.cz/profil?sect=subscription request = urllib2.Request(url) request.add_header('User-Agent', _UserAgent_) request.add_header("Referer", url) response = urllib2.urlopen(request) httpdata = response.read() response.close() media_data = re.search('mainVideo = new mediaData\((.+?), (.+?), (.+?),', httpdata) prod = media_data.group(1) unit = media_data.group(2) media = media_data.group(3) site = re.search('siteId: ([0-9]+)', httpdata).group(1) section = re.search('sectionId: ([0-9]+)', httpdata).group(1) subsite = re.search('subsite: \'(.+?)\',', httpdata).group(1) width = re.search('width: ([0-9]+)', httpdata).group(1) height = re.search('height: ([0-9]+)', httpdata).group(1) thumb = re.search('<link rel="image_src" href="(.+?)" />', httpdata) desc = re.search('<meta name="description" content="(.+?)" />', httpdata) desc = (desc and desc.group(1)) or name thumb = thumb and thumb.group(1) r = gen_random_decimal(0, 99999999999999) player_params = { 'x':'playerFlash', 'prod':prod, 'unit':unit, 'media':media, 'site':site, 'section':section, 'subsite':subsite, 'embed':0, 'realSite':site, 'width':width, 'height':height, 'hdEnabled':1, 'hash':'', 'finish':'finishedPlayer', 'dev':dev_hash, 'sts':'undefined', 'r': r, } player_url = player_php_url + '?' + urllib.urlencode(player_params) request = create_req(player_url) response = urllib2.urlopen(request) data = json.load(response) response.close() if data[u'error']: showError(data[u'msg']) elif data[u'html'].find('silverlight') != -1: showError("Požadované video je možné prehrať len na webe VOYO CZ") else: html = data[u'html'] req = urllib2.Request(voyo.get_config_url(html)) req.add_header('User-Agent', _UserAgent_) response = urllib2.urlopen(req) httpdata = response.read() response.close() baseurl = re.compile('<baseUrl>(.+?)</baseUrl>').findall(httpdata) streamurl = re.compile('<media>\s<quality>(.+?)</quality>.\s<url>(.+?)</url>\s</media>').findall(httpdata) for kvalita, odkaz in streamurl: if re.match('hd', kvalita, re.U): urlhd = odkaz.encode('utf-8') elif re.match('hq', kvalita, re.U): urlhq = odkaz.encode('utf-8') elif re.match('lq', kvalita, re.U): urllq = odkaz.encode('utf-8') swfurl = 'http://voyo.nova.cz/static/shared/app/flowplayer/13-flowplayer.commercial-3.1.5-19-003.swf' if live: rtmp_url_lq = baseurl[0] + '/' + urllq + ' live=true' rtmp_url_hq = baseurl[0] + '/' + urllq + ' live=true' else: rtmp_url_lq = baseurl[0] + ' playpath=' + urllq rtmp_url_hq = baseurl[0] + ' playpath=' + urlhq try: if live: rtmp_url_hd = baseurl[0] + '/' + urlhd + ' live=true' else: rtmp_url_hd = baseurl[0] + ' playpath=' + urlhd except: rtmp_url_hd = 0 if __settings__.get_setting('kvalita_sel') == "HQ": addLink("HQ " + name, rtmp_url_hq, icon, desc) elif __settings__.get_setting('kvalita_sel') == "LQ": addLink("LQ " + name, rtmp_url_lq, icon, desc) elif __settings__.get_setting('kvalita_sel') == "HD": if rtmp_url_hd == 0: addLink("HQ " + name, rtmp_url_hq, icon, desc) else: addLink("HD " + name, rtmp_url_hd, icon, desc) else: addLink("HQ " + name, rtmp_url_hq, icon, desc)
def VIDEOLINK(url,name, live): if name.find('pořad se ještě nevysílá')!=-1: return ### Log URL url_path = url.replace('http://www.ceskatelevize.cz', '') print '====> URL: '+ url print '====> URL Path: '+ url_path ### HTTP Connection to www.ceskatekevize.cz conn = httplib.HTTPConnection('www.ceskatelevize.cz') ### Load main page headers = { 'User-Agent': _UserAgent_ } conn.request('GET', url_path, '', headers) res = conn.getresponse() httpdata = res.read(); #print '====> MAIN PAGE START: ' + url #print httpdata #print '====> MAIN PAGE END: ' + url ### Extract Info from main page info = re.compile('<title>(.+?)</title>').findall(httpdata) info = info[0] if (name == ''): name = info print '====> Title: ' + info ### Extract Playlist ID form main page playlist = re.search('getPlaylistUrl.+?type":"(.+?)","id":"(.+?)"', httpdata, re.DOTALL) playlist_type = playlist.group(1) playlist_id = playlist.group(2) print '====> Playlist ID: ' + playlist_id ### Get Playlist link headers = { 'Connection': 'keep-alive', 'x-addr': '127.0.0.1', 'User-Agent': _UserAgent_, 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8', 'Accept': '*/*', 'X-Requested-With': 'XMLHttpRequest', 'Referer': url, 'Origin': 'http://www.ceskatelevize.cz' } data = { 'playlist[0][type]' : playlist_type, 'playlist[0][id]' : playlist_id, 'requestUrl' : url_path, 'requestSource' : 'iVysilani' } conn.request('POST', '/ivysilani/ajax/get-playlist-url', urllib.urlencode(data), headers ) res = conn.getresponse() httpdata = res.read() conn.close() #print '====> PLAYLIST LINK PAGE START' #print httpdata #print '====> PLAYLIST LINK PAGE END' ### Extract Playlist URL jsondata = json.loads(httpdata); playlist_url = urllib.unquote(jsondata['url']) print '====> Playlist ULR: ' + playlist_url urlobj = urlparse(playlist_url) urlhost = urlobj.netloc urlpath = urlunparse(('', '', urlobj.path, urlobj.params, urlobj.query, urlobj.fragment)) print '===> Playlist Host= ' + urlhost + ' Path=' + urlpath ### Get Playlists conn = httplib.HTTPConnection(urlhost) headers = { 'Connection': 'keep-alive', #'Referer': 'http://imgct.ceskatelevize.cz/global/swf/player/player.swf?version=1.45.15a', 'User-Agent': 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/32.0.1700.107 Safari/537.36', 'Accept-Encoding': 'identity', #'Accept-Encoding': 'gzip,deflate,sdch', 'Accept-Language': 'en-US,en;q=0.8,cs;q=0.6' } conn.request('GET', urlpath, '', headers) res = conn.getresponse() httpdata = res.read() conn.close() #print '====> PLAYLIST PAGE START' #print httpdata #print '====> PLAYLIST PAGE END' ### Read links XML page httpdata = urllib2.unquote(httpdata) root = ET.fromstring(httpdata) for item in root.findall('.//body/switchItem'): if ('id' in item.attrib) and ('base' in item.attrib): id = item.attrib['id'] base = item.attrib['base'] if re.search('AD', id, re.U): continue base = re.sub('&','&', base) print '==> SwitchItem id=' + id + ', base=' + base for videoNode in item.findall('./video'): if ('src' in videoNode.attrib) and ('label' in videoNode.attrib): src = videoNode.attrib['src'] label = videoNode.attrib['label'] if live: rtmp_url = base+'/'+src else: app = base[base.find('/', base.find('://') + 3) + 1:] rtmp_url = base + ' app=' + app + ' playpath=' + src print 'RTMP label=' + label + ', name=' + name + ', url=' + rtmp_url addLink(label+' '+name, rtmp_url, icon, info)
def VIDEONET_LINK(url, name): try: videourl = videonet.getURL(url) addLink(name + " - 24video.net", videourl, '', '') except: print "24VIDEO.NET URL: " + url
def VKCOM_LINK(url, name): try: videourl = vk.getURL(url) addLink(name + " - vk.com", videourl, '', '') except: print "VK.COM URL: " + url
def VIDEOLINK(url, name): def gen_dev_hash(): r = gen_random_decimal(0, 99999999999999) device_params = {'x':'device', 'a':'generateNewHash', 'userId':urllib.quote(username), 'r':r} devicehash_url = wallet_php_url + '?' + urllib.urlencode(device_params) print 'generating new devicehash' request = create_req(devicehash_url) response = urllib2.urlopen(request) data = json.load(response) response.close() return data[u'hash'] def add_dev(hash): r = gen_random_decimal(0, 99999999999999) client_details = '{"b":"FF","bv":"18.0","ua":"Mozilla/5.0 (Windows NT 6.1; WOW64; rv:18.0) Gecko/20100101 Firefox/18.0"}' adddevice_params = {'x':'device', 'a':'add', 'deviceCode':'PC', 'deviceHash':hash, 'client':client_details, 'r':r} adddevice_url = wallet_php_url + '?' + urllib.urlencode(adddevice_params) print 'trying to add new device' request = create_req(adddevice_url) response = urllib2.urlopen(request) data = json.load(response) response.close() succ = data[u'ok'] dev_hash = data[u'hash'] if not succ: print 'device cannot be added, exception or "Maximum of free devices already reached"' showError(data[u'msg']) else: print 'device was successfully added' return dev_hash if not islogged_in(): log_in(username, password) global dev_hash if dev_hash == "": new_devhash = gen_dev_hash() add_dev(new_devhash) dev_hash = new_devhash __settings__.setSetting('devhash', new_devhash) # to remove device # http://voyo.markiza.sk/profil?sect=subscription request = urllib2.Request(url) request.add_header('User-Agent', _UserAgent_) request.add_header("Referer", url) response = urllib2.urlopen(request) httpdata = response.read() response.close() media_data = re.search('mainVideo = new mediaData\((.+?), (.+?), (.+?),', httpdata) prod = media_data.group(1) unit = media_data.group(2) media = media_data.group(3) site = re.search('siteId: ([0-9]+)', httpdata).group(1) section = re.search('sectionId: ([0-9]+)', httpdata).group(1) subsite = re.search('subsite: \'(.+?)\',', httpdata).group(1) width = re.search('width: ([0-9]+)', httpdata).group(1) height = re.search('height: ([0-9]+)', httpdata).group(1) r = gen_random_decimal(0, 99999999999999) player_params = { 'x':'playerFlash', 'prod':prod, 'unit':unit, 'media':media, 'site':site, 'section':section, 'subsite':subsite, 'embed':0, 'realSite':site, 'width':width, 'height':height, 'hdEnabled':1, 'hash':'', 'finish':'finishedPlayer', 'dev':dev_hash, 'sts':'undefined', 'r': r, } player_url = player_php_url + '?' + urllib.urlencode(player_params) request = create_req(player_url) response = urllib2.urlopen(request) data = json.load(response) response.close() if data[u'error']: showError(data[u'msg']) else: html = data[u'html'] exec(base64.decodestring("Y29uZmlnX2FlcyA9IHJlLnNlYXJjaCgndmFyIHZveW9QbHVzQ29uZmlnLipbXiJdKyIoLis/KSI7\nJywgaHRtbCwgcmUuRE9UQUxMKS5ncm91cCgxKTtjb25maWcgPSBhZXMuZGVjcnlwdChjb25maWdf\nYWVzLCAnRWFEVXV0ZzRwcEdZWHdOTUZkUkpzYWRlbkZTbkk2Z0onLCAxMjgpLnJlcGxhY2UoJ1wv\nJywnLycpO3NlY3JldCA9IHJlLnNlYXJjaChyJyJzZWNyZXQiOiIoLis/KSInLCBjb25maWcpLmdy\nb3VwKDEpO2FwcF9pZCA9IHJlLnNlYXJjaChyJyJhcHBJZCI6IiguKz8pIicsIGNvbmZpZykuZ3Jv\ndXAoMSk7c2VydmljZV91cmwgPSByZS5zZWFyY2gocicic2VydmljZVVybCI6IiguKz8pIicsIGNv\nbmZpZykuZ3JvdXAoMSk7dGltZV9zZXJ2aWNlX3VybCA9IHJlLnNlYXJjaChyJyJ0aW1lU2Vydmlj\nZVVybCI6IiguKz8pIicsIGNvbmZpZykuZ3JvdXAoMSk7dGltZXN0YW1wID0gbWFya2l6YV9yZWFk\nKHRpbWVfc2VydmljZV91cmwpWzoxNF07c2lnbmF0dXJlID0gYmFzZTY0LmI2NGVuY29kZShoYXNo\nbGliLm1kNSgiezB9fHsxfXx7Mn18ezN9Ii5mb3JtYXQoYXBwX2lkLCBtZWRpYSwgdGltZXN0YW1w\nLCBzZWNyZXQpKS5kaWdlc3QoKSk7c2VydmljZV91cmwgPSAiezB9P3Q9ezF9JmQ9MSZjPXsyfXx7\nM30maD0wJnRtPW5vdmEmcz17NH0iLmZvcm1hdChzZXJ2aWNlX3VybCx0aW1lc3RhbXAsYXBwX2lk\nLG1lZGlhLHVybGxpYi5xdW90ZShzaWduYXR1cmUpKQ==\n")) in globals(),locals() service_xml = markiza_read(service_url) baseurl = re.compile('<baseUrl>(.+?)</baseUrl>').findall(service_xml) baseurl = re.sub(r'<!\[CDATA\[([^\]]+)\]\]>',r'\1',baseurl[0]) streamurl = re.compile('<media>\s*<quality>(.+?)</quality>\s*<url>(.+?)</url>\s*</media>').findall(service_xml) for quality, playpath in streamurl: quality = re.sub(r'<!\[CDATA\[([^\]]+)\]\]>',r'\1', quality) playpath = re.sub(r'<!\[CDATA\[([^\]]+)\]\]>',r'\1', playpath) url = "%s playpath=%s" % (baseurl, playpath) if quality == 'hq': continue addLink(name, url, None)
def VIDEOLINK_TEST(url, name): req = urllib2.Request(url) req.add_header('User-Agent', _UserAgent_) response = urllib2.urlopen(req) httpdata = response.read() response.close() mediaid = re.compile( 'mainVideo = new mediaData\(.+?, .+?, (.+?),').findall(httpdata) thumb = re.compile('<link rel="image_src" href="(.+?)" />').findall( httpdata) popis = re.compile('<meta name="description" content="(.+?)" />').findall( httpdata) datum = datetime.datetime.now() timestamp = datum.strftime('%Y%m%d%H%M%S') videoid = urllib.quote(nova_app_id + '|' + mediaid[0]) md5hash = nova_app_id + '|' + mediaid[ 0] + '|' + timestamp + '|' + secret_token try: md5hash = hashlib.md5(md5hash) except: md5hash = md5.new(md5hash) signature = urllib.quote(base64.b64encode(md5hash.digest())) config = nova_service_url + '?t=' + timestamp + '&d=1&tm=nova&h=0&c=' + videoid + '&s=' + signature print config try: desc = popis[0] except: desc = name req = urllib2.Request(config) req.add_header('User-Agent', _UserAgent_) response = urllib2.urlopen(req) httpdata = response.read() response.close() if __settings__.get_setting('test_nastaveni'): print httpdata error_secret_token = re.compile('<errorCode>(.+?)</errorCode>').findall( httpdata) try: chyba = int(error_secret_token[0]) except: chyba = 0 if chyba == 2: print 'Nesprávné tajné heslo' showWarning(u"Doplněk DMD VOYO Nesprávné tajné heslo!") #__settings__.open_settings(session) elif chyba == 1: print 'Špatné časové razítko' showError(u"Doplněk DMD VOYO Pořad lze přehrát pouze na webu Voyo.cz!") #xbmc.executebuiltin("XBMC.Notification('Doplněk DMD VOYO','Pořad lze přehrát pouze na webu Voyo.cz!',30000,"+icon+")") elif chyba == 0: baseurl = re.compile('<baseUrl>(.+?)</baseUrl>').findall(httpdata) streamurl = re.compile( '<media>\s<quality>(.+?)</quality>.\s<url>(.+?)</url>\s</media>' ).findall(httpdata) for kvalita, odkaz in streamurl: #print kvalita,odkaz if re.match('hd', kvalita, re.U): urlhd = odkaz.encode('utf-8') elif re.match('hq', kvalita, re.U): urlhq = odkaz.encode('utf-8') elif re.match('lq', kvalita, re.U): urllq = odkaz.encode('utf-8') print urlhq, urllq swfurl = 'http://voyo.nova.cz/static/shared/app/flowplayer/13-flowplayer.commercial-3.1.5-19-003.swf' if __settings__.get_setting('test_nastaveni'): rtmp_url_lq = baseurl[ 0] + ' playpath=' + urllq + ' pageUrl=' + url + ' swfUrl=' + swfurl + ' swfVfy=true token=' + rtmp_token rtmp_url_hq = baseurl[ 0] + ' playpath=' + urlhq + ' pageUrl=' + url + ' swfUrl=' + swfurl + ' swfVfy=true token=' + rtmp_token try: rtmp_url_hd = baseurl[ 0] + ' playpath=' + urlhd + ' pageUrl=' + url + ' swfUrl=' + swfurl + ' swfVfy=true token=' + rtmp_token except: rtmp_url_hd = 0 else: rtmp_url_lq = baseurl[0] + ' playpath=' + urllq rtmp_url_hq = baseurl[0] + ' playpath=' + urlhq try: rtmp_url_hd = baseurl[0] + ' playpath=' + urlhd except: rtmp_url_hd = 0 if __settings__.get_setting('kvalita_sel') == "HQ": addLink("HQ " + name, rtmp_url_hq, icon, desc) elif __settings__.get_setting('kvalita_sel') == "LQ": addLink("LQ " + name, rtmp_url_lq, icon, desc) elif __settings__.get_setting('kvalita_sel') == "HD": if rtmp_url_hd == 0: addLink("HQ " + name, rtmp_url_hq, icon, desc) else: addLink("HD " + name, rtmp_url_hd, icon, desc) else: addLink("HQ " + name, rtmp_url_hq, icon, desc)
def VIDEOMAIL_LINK(url,name): try: videourl=videomail.getURL(url) addLink(name+" - videomail.ru",videourl,'','') except: print "VIDEOMAIL.RU URL: "+url
def VIDEOLINK(url, name, live=False): def gen_dev_hash(): r = gen_random_decimal(0, 99999999999999) device_params = { 'x': 'device', 'a': 'generateNewHash', 'userId': urllib.quote(username), 'r': r } devicehash_url = wallet_php_url + '?' + urllib.urlencode(device_params) print 'generating new devicehash' request = create_req(devicehash_url) response = urllib2.urlopen(request) data = json.load(response) response.close() return data[u'hash'] def add_dev(hash): r = gen_random_decimal(0, 99999999999999) client_details = '{"b":"FF","bv":"18.0","ua":"Mozilla/5.0 (Windows NT 6.1; WOW64; rv:18.0) Gecko/20100101 Firefox/18.0"}' adddevice_params = { 'x': 'device', 'a': 'add', 'deviceCode': 'PC', 'deviceHash': hash, 'client': client_details, 'r': r } adddevice_url = wallet_php_url + '?' + urllib.urlencode( adddevice_params) print 'trying to add new device' request = create_req(adddevice_url) response = urllib2.urlopen(request) data = json.load(response) response.close() succ = data[u'ok'] dev_hash = data[u'hash'] if not succ: print 'device cannot be added, exception or "Maximum of free devices already reached"' showError(data[u'msg']) else: print 'device was successfully added' return dev_hash if not islogged_in(): log_in(username, password) if dev_hash == "": new_devhash = gen_dev_hash() add_dev(new_devhash) __settings__.setSetting('devhash', new_devhash) # to remove device # http://voyo.nova.cz/profil?sect=subscription request = urllib2.Request(url) request.add_header('User-Agent', _UserAgent_) request.add_header("Referer", url) response = urllib2.urlopen(request) httpdata = response.read() response.close() media_data = re.search('mainVideo = new mediaData\((.+?), (.+?), (.+?),', httpdata) prod = media_data.group(1) unit = media_data.group(2) media = media_data.group(3) site = re.search('siteId: ([0-9]+)', httpdata).group(1) section = re.search('sectionId: ([0-9]+)', httpdata).group(1) subsite = re.search('subsite: \'(.+?)\',', httpdata).group(1) width = re.search('width: ([0-9]+)', httpdata).group(1) height = re.search('height: ([0-9]+)', httpdata).group(1) thumb = re.search('<link rel="image_src" href="(.+?)" />', httpdata) desc = re.search('<meta name="description" content="(.+?)" />', httpdata) desc = (desc and desc.group(1)) or name thumb = thumb and thumb.group(1) r = gen_random_decimal(0, 99999999999999) player_params = { 'x': 'playerFlash', 'prod': prod, 'unit': unit, 'media': media, 'site': site, 'section': section, 'subsite': subsite, 'embed': 0, 'realSite': site, 'width': width, 'height': height, 'hdEnabled': 1, 'hash': '', 'finish': 'finishedPlayer', 'dev': dev_hash, 'sts': 'undefined', 'r': r, } player_url = player_php_url + '?' + urllib.urlencode(player_params) request = create_req(player_url) response = urllib2.urlopen(request) data = json.load(response) response.close() if data[u'error']: showError(data[u'msg']) elif data[u'html'].find('silverlight') != -1: showError("Požadované video je možné prehrať len na webe VOYO CZ") else: html = data[u'html'] req = urllib2.Request(voyo.get_config_url(html)) req.add_header('User-Agent', _UserAgent_) response = urllib2.urlopen(req) httpdata = response.read() response.close() baseurl = re.compile('<baseUrl>(.+?)</baseUrl>').findall(httpdata) streamurl = re.compile( '<media>\s<quality>(.+?)</quality>.\s<url>(.+?)</url>\s</media>' ).findall(httpdata) for kvalita, odkaz in streamurl: if re.match('hd', kvalita, re.U): urlhd = odkaz.encode('utf-8') elif re.match('hq', kvalita, re.U): urlhq = odkaz.encode('utf-8') elif re.match('lq', kvalita, re.U): urllq = odkaz.encode('utf-8') swfurl = 'http://voyo.nova.cz/static/shared/app/flowplayer/13-flowplayer.commercial-3.1.5-19-003.swf' if live: rtmp_url_lq = baseurl[0] + '/' + urllq + ' live=true' rtmp_url_hq = baseurl[0] + '/' + urllq + ' live=true' else: rtmp_url_lq = baseurl[0] + ' playpath=' + urllq rtmp_url_hq = baseurl[0] + ' playpath=' + urlhq try: if live: rtmp_url_hd = baseurl[0] + '/' + urlhd + ' live=true' else: rtmp_url_hd = baseurl[0] + ' playpath=' + urlhd except: rtmp_url_hd = 0 if __settings__.get_setting('kvalita_sel') == "HQ": addLink("HQ " + name, rtmp_url_hq, icon, desc) elif __settings__.get_setting('kvalita_sel') == "LQ": addLink("LQ " + name, rtmp_url_lq, icon, desc) elif __settings__.get_setting('kvalita_sel') == "HD": if rtmp_url_hd == 0: addLink("HQ " + name, rtmp_url_hq, icon, desc) else: addLink("HD " + name, rtmp_url_hd, icon, desc) else: addLink("HQ " + name, rtmp_url_hq, icon, desc)
def YOUTUBE_LINK(url, name): try: videourl = ytube.getURL(url) addLink(name + " - youtube.com", videourl, '', '') except: print "YOUTUBE.COM URL: " + url
def VIDEOBB_LINK(url, name): try: videourl = videobb.getURL(url) addLink(name + " - videobb.com", videourl, '', '') except: print "VIDEOBB URL: " + url
def VIDEOLINK(url, name): # rewrite by MN html = get_url(url) # nalezeni hlavniho article aarticle = re.search("<div class=\"b-article b-article-main\">(.*?)", html, re.S) # pokud hlavni article neexistuje, jsme na specialni strance se seznamem dilu a hledame odkaz if aarticle is None and html.find( 'property="og:url" content="http://voyo.nova.cz/') != -1: addLink( "[COLOR red]Chyba: Video lze přehrát jen na voyo.nova.cz[/COLOR]", "#", None, "") return # pokud stale hlavni article neexistuje, chyba if aarticle is None: article = None print "Na stránce nenalezena sekce s videi. Program nebude fungovat správně." + url addLink( "[COLOR red]Na stránce nenalezena sekce s videi: " + url + "[/COLOR]", "#", None, "") #xbmcgui.Dialog().ok("Nova Plus TV Archiv", "Na stránce nenalezena sekce s videi. Program nebude fungovat správně.", url) return else: article = aarticle.group(1) # nazev aname = re.search("<h2 class=\"subtitle\">(.*?)</h2>", html, re.S) if aname is None: name = "Jméno pořadu nenalezeno" else: name = aname.group(1) # popis (nemusi byt vzdy uveden) adesc = re.search("<div class=\"e-description\">(.*?)</div>", article, re.S) if adesc is None: desc = "" else: desc = adesc.group(1).re.sub(r'<[^>]*?>', '', value).replace(' ', ' ') # nalezeni iframe iframe = re.search("<div class=\"video-holder\">.*?iframe src=\"(.*?)\"", html, re.S) if iframe != None: url = iframe.group(1) else: url = None print ' - iframe src ' + url # nacteni a zpracovani iframe req = urllib2.Request(url) req.add_header('User-Agent', _UserAgent_) response = urllib2.urlopen(req) httpdata = response.read() response.close() httpdata = httpdata.replace("\r", "").replace("\n", "").replace("\t", "") thumb = re.compile('<meta property="og:image" content="(.+?)">').findall( httpdata) thumb = thumb[0] if len(thumb) > 0 else '' re_src = re.compile('var src = \{(.*?)\}').findall(httpdata) if len(re_src) > 0: urls = re.compile('\"(.*?)\"\:\"(.*?)\"\,?').findall(re_src[0].replace( " ", "")) for num, url in enumerate(urls): addLink('[B]' + name.replace(' ', ' ') + '[/B]', url[1], thumb, desc.replace(' ', ' ')) else: # jeste zkusim najit mpd (MN) urls = re.search("\"src\":\"(.*?)\.m3u8\"", httpdata, re.M) if urls != None: addLink('[B] DRM! - ' + name.replace(' ', ' ') + '[/B]', urls.group(1).replace("\\", "") + ".m3u8", thumb, desc.replace(' ', ' ')) else: print 'Chyba: Video nelze přehrát' addLink("[COLOR red]Chyba: Video nelze přehrát[/COLOR]", "#", None, "") #xbmcgui.Dialog().ok('Chyba', 'Video nelze přehrát', '', '') # dalsi dily poradu # for article in doc.findAll('article', 'b-article b-article-text b-article-inline'): # url = article.a['href'].encode('utf-8') # title = article.a['title'].encode('utf-8') # thumb = article.a.div.img['data-original'].encode('utf-8') # addDir(title,url,3,thumb,1) # stranka poradu section = re.search("<h1 class=\"title\"><a href=\"(.*?)\">(.*?)</a>", html, re.S) if section != None: url = section.group(1) title = section.group(2) + ' - stránka pořadu' thumb = None addDir(title.replace(' ', ' '), url, 2, thumb, 1)
def VIDEOLINK(url,name): request = urllib2.Request(url) con = urllib2.urlopen(request) data = con.read() con.close() print url stream_video = re.compile('cdnID=([0-9]+)').findall(data) if len(stream_video) > 0: print 'LQ '+__cdn_url__+name,stream_video[0],icon,'' addLink('LQ '+name,__cdn_url__+stream_video[0],icon,'') else: try: hd_stream = re.compile('"hd_id":"(.+?)"').findall(data) hd_stream = hd_stream[0] except: hd_stream = 'Null' hq_stream = re.compile('"hq_id":"(.+?)"').findall(data) lq_stream = re.compile('"lq_id":"(.+?)"').findall(data) geo_zone = re.compile('"zoneGEO":(.+?),').findall(data) try: thumb = re.compile("'thumbnail': '(.+?)'").findall(data) nahled = thumb[0] except: nahled = icon key = 'http://embed.livebox.cz/iprimaplay/player-embed-v2.js?__tok'+str(gen_random_decimal(1073741824))+'__='+str(gen_random_decimal(1073741824)) req = urllib2.Request(key) req.add_header('User-Agent', _UserAgent_) req.add_header('Referer', url) response = urllib2.urlopen(req) keydata = response.read() response.close() keydata = re.compile("_any_(.*?)'").findall(keydata) #keydata = re.compile("auth='(.*?)'").findall(keydata) print keydata if geo_zone[0] == "1": #hd_url = 'rtmp://bcastgw.livebox.cz:80/iprima_token?auth=_any_'+keydata[1]+'/mp4:hq/'+hd_stream[0] hd_url = 'rtmp://bcastmw.livebox.cz:80/iprima_token_'+geo_zone[0]+'?auth=_any_'+keydata[1]+' playpath=mp4:hq/'+hd_stream+ ' live=true' hq_url = 'rtmp://bcastmw.livebox.cz:80/iprima_token_'+geo_zone[0]+'?auth=_any_'+keydata[1]+'/mp4:'+hq_stream[0] lq_url = 'rtmp://bcastmw.livebox.cz:80/iprima_token_'+geo_zone[0]+'?auth=_any_'+keydata[1]+'/mp4:'+lq_stream[0] if __settings__.get_setting('proxy_use'): proxy_ip = __settings__.get_setting('proxy_ip') proxy_port = str(__settings__.get_setting('proxy_port')) hd_url = hd_url + ' socks=' + proxy_ip+':'+proxy_port hq_url = hq_url + ' socks=' + proxy_ip+':'+proxy_port lq_url = lq_url + ' socks=' + proxy_ip+':'+proxy_port else: if re.match('Prima', hq_stream[0], re.U): #hd_url = 'rtmp://bcastgw.livebox.cz:80/iprima_token?auth=_any_'+keydata[1]+'/mp4:hq/'+hd_stream[0] hd_url = 'rtmp://bcastmw.livebox.cz:80/iprima_token?auth=_any_'+keydata[1]+' playpath=mp4:hq/'+hd_stream+ ' live=true' hq_url = 'rtmp://bcastmw.livebox.cz:80/iprima_token?auth=_any_'+keydata[1]+'/mp4:'+hq_stream[0] lq_url = 'rtmp://bcastmw.livebox.cz:80/iprima_token?auth=_any_'+keydata[1]+'/mp4:'+lq_stream[0] else: hd_url = 'rtmp://bcastmw.livebox.cz:80/iprima_token?auth=_any_'+keydata[1]+'/'+hd_stream hq_url = 'rtmp://bcastmw.livebox.cz:80/iprima_token?auth=_any_'+keydata[1]+'/'+hq_stream[0] lq_url = 'rtmp://bcastmw.livebox.cz:80/iprima_token?auth=_any_'+keydata[1]+'/'+lq_stream[0] #print nahled, hq_url, lq_url if kvalita == "HD": print 'HD '+name,hq_url,nahled,name if hd_stream != 'Null': addLink('HD '+name,hd_url,nahled,name) addLink('HQ '+name,hq_url,nahled,name) elif kvalita == "HQ": print 'HQ '+name,lq_url,nahled,name addLink('HQ '+name,hq_url,nahled,name) addLink('LQ '+name,lq_url,nahled,name) else: print 'LQ '+name,lq_url,nahled,name addLink('LQ '+name,lq_url,nahled,name) try: epizody = re.compile('<a href="(.+?)" class="videocategory-link">Celé epizody').findall(data) print 'epizody' print epizody[0] addDir('[B]Další nabídka: [/B]','','','','','') addDir('Další epizody pořadu',__baseurl__+epizody[0],5,'',0,'Další epizody pořadu') except: print 'Další epizody nenalezeny'
def NOVAMOV_LINK(url, name): try: videourl = novamov.getURL(url) addLink(name + " - novamov.com", videourl, '', '') except: print "NOVAMOV.COM URL: " + url