def resolve(self, url, headers): if "vidnext" in url: page = net.http(url, headers=headers) tree = htmlement.fromstring(page) iframe = tree.find(".//iframe[@id='embedvideo_main']") if iframe is not None: headers["referer"] = url url = iframe.get("src") else: up = parse.urlparse(url) jsq = dict(parse.parse_qsl(up.query)) jsurl = "https://%s/ajax.php" % up.netloc js = json.loads( net.http(jsurl, params=jsq, referer=url, headers={"x-requested-with": "XMLHttpRequest"})) for k in ["source", "source_bk"]: for vid in js.get(k, []): yield net.tokodiurl(vid["file"], headers={"referer": url}) up = parse.urlparse(url) if "movcloud.net" in url: vid = up.path.split("/")[-1] jsurl = "https://api.%s/stream/%s" % (up.netloc, vid) js = json.loads(net.http(jsurl, referer=url)) for vid in sorted(js["data"]["sources"], key=itemgetter("height"), reverse=True): yield net.tokodiurl(vid["file"], headers={"referer": url}) else: raise Exception("unknown url:%s" % url)
def add(self, m3file, headers, useproxy): if len(m3file.playlists): for playlist in sorted(m3file.playlists, key=self.sorter, reverse=True): if useproxy: self.headcheck(playlist, headers, useproxy) if self.playlists.qsize(): break else: playlist.uri = net.tokodiurl(playlist.absolute_uri, headers=headers) self.playlists.put(playlist) elif len(m3file.segments): if not useproxy: m3file.full_uri = net.tokodiurl(m3file.full_uri, headers=headers) else: m3file.full_uri = encodeurl(url=m3file.full_uri, headers=headers) self.index += 1 playlist = model.Playlist(m3file.full_uri, {"bandwidth": self.index}, None, m3file.base_uri) self.playlists.put(playlist)
def resolve(self, url, headers): if url.endswith(".m3u8"): yield net.tokodiurl(url, headers=headers) else: url = url.replace("/streaming.php", "/ajax.php") url = url.replace("/load.php", "/ajax.php") headers = {"x-requested-with": "XMLHttpRequest"} jpage = net.http(url, headers=headers, referer=self.domain) js = json.loads(jpage) for src in js["source"]: yield net.tokodiurl(src["file"], headers={"referer": self.domain})
def epilink(self, episode): if "link" in episode: return True, episode["link"] elif "videoFile" in episode: links = [] suburl = episode["videoFile"]["path"] if suburl.startswith("http://") or suburl.startswith("https://"): links.append( tokodiurl(suburl, headers={"Referer": self.domain})) else: url = "%s/%s/playlist.m3u8" % (episode["videoBaseUrl"], suburl) links.append(tokodiurl(url, headers={"Referer": self.domain})) url = "%s/%s/playlist.m3u8" % (episode["videoBaseUrlUnsecure"], suburl) links.append(tokodiurl(url, headers={"Referer": self.domain})) return False, links
def resolve(self, url, headers): page = net.http(url, headers=headers) if packer.detect(page): page = packer.unpack(page) for vid in re.findall("file\s*?\:\s*?(?:'|\")(.+?)(?:'|\")", page): if vid.endswith(".m3u8") or vid.endswith(".mp4"): headers = {"referer": url} yield net.tokodiurl(vid, headers=headers)
def geturls(self, streamid): url = surl % streamid page = self.download(url, referer=referer) m3 = re.search(rgx, page).group(1) yield net.tokodiurl(m3, headers={ "Referer": sdom, "User-Agent": const.USERAGENT })
def geturls(self, url): eurl = self.domain + url epipage = self.download(eurl) cid = re.findall('\["contentid", "(.*?)"\]', epipage)[0] js = self.download("%s/action/media/%s" % (self.domain, cid)) js = json.loads(js) # js["Media"]["Link"].get("ServiceUrl") m3u8 = "%s%s" % ("https://soledge7.dogannet.tv/", js["Media"]["Link"]["SecurePath"]) yield net.tokodiurl(m3u8, headers={"referer": eurl})
def headcheck(self, playlist, headers, useproxy): error = self.base.healthcheck(playlist.absolute_uri, headers) if error is None: if not useproxy: playlist.uri = net.tokodiurl(playlist.absolute_uri, headers=headers) else: playlist.uri = encodeurl(url=playlist.absolute_uri, headers=headers) self.playlists.put(playlist)
def image(self, label, src, height, width=None, mode=2, onclick=None): if not onclick: onclick = self.__null from tinyxbmc.net import tokodiurl src = tokodiurl(src, None, {"User-agent": self.__useragent}) elem = xbmcgui.ControlImage(0, 0, 0, 0, src, mode) self.__eid += 1 self.__elems[self.__eid] = ("image", label, onclick, width, height, elem) return self.__eid
def geturls(self, url): resolve, url = url if not resolve: for u in url: yield u if resolve: url = self.domain + url tree = htmlement.fromstring(self.download(url)) video = tree.find(".//video/source") if video is not None: yield tokodiurl(video.get("src"), headers={"Referer": url})
def _art(self, d, headers=None): if not headers: headers = {} if "user-agent" not in [x.lower() for x in headers.keys()]: headers["user-agent"] = self._container.useragent for k, v in d.iteritems(): try: d[k] = net.tokodiurl(v, headers=headers) except Exception: pass return d
def resolve(self, url, headers): if "vidlink.org" in url: postid = re.search("postID\s?\=\s?(?:\'|\")(.+?)(?:\'|\")", net.http(url, headers=headers)) up = urlparse(url) jsurl = "https://%s/embed/info?postID=%s" % (up.netloc, postid.group(1)) js = json.loads(net.http(jsurl, referer=url)) url = js["embed_urls"] if "ronemo.com" in url: up = urlparse(url) jsurl = "https://%s/api/video/get-link?idVid=%s" % (up.netloc, up.path.split("/")[-1]) js = json.loads(net.http(jsurl, referer=url)) yield net.tokodiurl("https://hls.ronemo.com/%s" % js["link"], headers={"referer": url})
def stream(self, url, li): u, headers = net.fromkodiurl(url) if headers is None: headers = {"User-agent": const.USERAGENT} elif "user-agent" not in [x.lower() for x in headers.keys()]: headers["User-agent"] = const.USERAGENT u = net.tokodiurl(u, headers=headers) if self.dlg.iscanceled(): return if self.canresolve: xbmcplugin.setResolvedUrl(int(sys.argv[1]), True, li) else: if not self.fallbackinfo == {}: li.setInfo("video", self.fallbackinfo) if not self.fallbackart == {}: gui.setArt(li, self.fallbackart) self.play(u, li) return self.waitplayback(u)
def resolve(self, url, headers): iframe = htmlement.fromstring(net.http( url, headers=headers)).find(".//iframe").get("src") url2 = self.domain + iframe page = net.http(url2, referer=url) vidpage = re.search('var\s*?query\s*?=\s*?(?:\'|")(.+?)(?:\'|")\;', page).group(1) resp = net.http(self.domain + "/watching" + vidpage, referer=url2, text=False) url3 = resp.url.replace("/v/", "/api/source/") headers = {"X-Requested-With": "XMLHttpRequest", "referer": resp.url} data = {"d": parse.urlparse(url3).netloc, "r": url2} js = json.loads( net.http(url3, headers=headers, data=data, method="POST")) if not js["success"]: print("VIDSRC ERROR: %s, %s" % (js["data"], url)) yield for vid in js["data"]: yield net.tokodiurl(vid["file"], headers={"referer": resp.url})
def do_GET(self): kwargs = hls.decodeurl(self.path) qurl = kwargs.get("url") qheaders = kwargs.get("headers", {}) qplaylist = kwargs.get("playlist") qepg = kwargs.get("epg") if qurl: rng = self.headers.get("Range") if rng: qheaders["Range"] = rng resp = self.base.proxy_get(qurl, qheaders) if isinstance(resp, Exception) or resp is None: self.send_response(500, str(resp)) self.end_headers() else: m3file = self.render_m3(resp, qurl, qheaders) if isinstance(m3file, Exception): self.send_response(500, str(m3file)) return self.send_response(resp.status_code) self.end_headers() if m3file: self.wfile.write(m3file.dumps().encode()) else: decryptor = hls.DecryptPayload(**kwargs.get("encryption", {})) for chunk in resp.iter_content(decryptor.chunksize, False): data = decryptor.decrypt(chunk) self.wfile.write(data) self.wfile.write(decryptor.flush()) elif qplaylist: chan = self.base.loadchannel(qplaylist) if not chan: return self.send_response(200) self.end_headers() pgen = hls.PlaylistGenerator(self.base) forceproxy = kwargs.get("forceproxy", 0) for url in tools.safeiter(chan.get()): if isinstance(url, net.mpdurl) and url.inputstream: pass # skip mpds for now else: if isinstance(url, net.hlsurl): headers = url.headers u = url.url else: u, headers = net.fromkodiurl(url) if not headers: headers = {} resp = self.base.proxy_get(u, headers) if resp is not None and not isinstance(resp, Exception): content = resp.content.decode() if content[:7] == "#EXTM3U": m3file = m3u8.loads(content, uri=u) m3file.full_uri = u pgen.add(m3file, headers, forceproxy or chan.usehlsproxy) if pgen.playlists.qsize(): break self.wfile.write(pgen.m3file.dumps().encode()) elif qepg: # epg response self.send_response(200) self.end_headers() epg.write(self.base).start() self.writeline(common.epath) else: # main channel list self.send_response(200) # self.send_header("Content-Type", "application/vnd.apple.mpegurl;charset=utf-8") self.end_headers() self.writeline('#EXTM3U') playlists = self.base.config.playlists for icon, title, index, cats, url in self.base.config.channels: pnames = [] for playlistname, indexes in self.base.config.iterplaylists(playlists): if index in indexes: pnames.append(playlistname) playlisturl = None if url: if url.inputstream: self.writeline("#KODIPROP:inputstreamaddon=inputstream.adaptive") self.writeline("#KODIPROP:inputstreamclass=inputstream.adaptive") self.writeline("#KODIPROP:inputstream.adaptive.manifest_type=%s" % url.manifest) if isinstance(url, net.mpdurl): if url.lurl: self.writeline('#KODIPROP:inputstream.adaptive.license_type=%s' % url.license) url.lurl, url.lheaders = net.fromkodiurl(net.tokodiurl(url.lurl, headers=url.lheaders, pushua=const.USERAGENT, pushverify="false")) self.writeline('#KODIPROP:inputstream.adaptive.license_key=%s' % url.kodilurl) playlisturl = net.tokodiurl(url.url, headers=url.headers, pushverify="false", pushua=const.USERAGENT) self.writeline("#KODIPROP:inputstream.adaptive.stream_headers=%s" % const.USERAGENT) self.writeline('#EXTINF:0 tvg-logo="%s" tvg-id="%s" group-title="%s",%s' % (icon, index, ";".join(cats + pnames), title)) self.writeline(playlisturl or hls.encodeurl(playlist=index))
def geturls(self, url, headers=None): yield net.tokodiurl(url, headers=headers)
def resolve(self, url, headers): for vid in re.finditer("file\s?\:\s?(?:\'|\")(.+?)(?:\'|\")", net.http(url, headers=headers)): yield net.tokodiurl(vid.group(1), headers={"referer": url})