示例#1
0
def get_Stream(url):
    if xbmcaddon.Addon().getSetting('quality') == 'true':
        return url
    result = client.request(url)
    from resources.lib import m3u8_parser
    playlist = m3u8_parser.parse(result)['playlists']

    if not playlist:
        return url
    
    try: playlist = sorted(playlist, key=lambda tup: tup['stream_info']['bandwidth'], reverse=True)
    except: pass

    qkey = 'resolution' if 'resolution' in playlist[0]['stream_info'] else 'bandwidth'
    qualities = []
    urls = []

    for item in playlist:

        quality = str(item['stream_info'][qkey])
        uri = item['uri']
        uri = urlparse.urljoin(url, uri)
        qualities.append(quality)
        urls.append(uri)
    
    dialog = xbmcgui.Dialog()
    q = dialog.select('Minőség', qualities)
    if q <= len(qualities) and not q == -1:
        return(urls[q])
    else:
        return None
def get_liveTv():
    from resources.lib import m3u8_parser
    
    title = name.split('-')[0].strip()
    
    if not title.lower() == 'm3':
        r = client.request(url)
        streamid = re.search('"streamId"\s*:\s*"([^"]+)', r).group(1)

        drm_info = client.request('https://player.mediaklikk.hu/playernew/public/stream/%s.json' % streamid)
        drm_info = json.loads(drm_info)
        drm_info = drm_info['drm']

        if drm_info == True:
            control.infoDialog(u'Lej\u00E1tsz\u00E1s sikertelen. Az \u00E9l\u0151 ad\u00E1s DRM v\u00E9delemmel van ell\u00E1tva.', icon='')
            return

        r = client.request('https://player.mediaklikk.hu/playernew/player.php?video=%s' % streamid)
        r = r.replace('\\', '').replace('\n', '')
        direct_url = re.findall('"file"\s*:\s*"([^"]+)', r)
        direct_url = [i for i in direct_url if not 'FWC2018' in i][0]

        direct_url = direct_url.replace('\\', '')
        if not direct_url.startswith('http'): direct_url = 'http:' + direct_url
        result = client.request(direct_url)
        url_list = m3u8_parser.parse(result)['playlists']
        url_list = [(i['stream_info']['resolution'].split('x')[1], i['uri']) for i in url_list]
        url_list = sorted(url_list, key=lambda tup: int(tup[0]), reverse=True)
        q_list = [x[0] + 'p' for x in url_list]
        
        auto_pick = control.setting('autopick') == '1'

        if len(url_list) == 1 or auto_pick == True:
            stream = url_list[0][1]
        else:
            q = xbmcgui.Dialog().select(u'Min\u0151s\u00E9g', q_list)
            if q == -1:
                return
            else:
                stream = url_list[q][1]
        
        stream = direct_url.split('index.m3u8')[0] + stream
    
    else:
        m3_cookie = client.request(url, output = 'cookie')
        m3_token = re.search('Token=([a-zA-Z0-9]+)', m3_cookie).group(1)
        m3_streamUrl = client.request('https://archivum.mtva.hu/m3/stream?target=live')
        m3_streamUrl = json.loads(m3_streamUrl).get('live')
        stream = m3_streamUrl.replace('[sessid]', m3_token)
        
        '''direct_url = 'https://stream.nava.hu:443/m3_live_drm/smil:m3.smil/playlist.m3u8'''
 
    play_url(stream, iconimage, title)
示例#3
0
def playVideo():
    from resources.lib import m3u8_parser
    try:
        r = client.request("%s/search/%s" % (api_url, param))
        data = json.loads(r)
        playerId = data["playerId"]
        title = data["title"]
        thumb = "%s/%s" % (
            base_url, data["imageUrl"]
        ) if "https://" not in data["imageUrl"] else data["imageUrl"]
        r = client.request("%s/streaming-url?playerId=%s" %
                           (api_url, playerId))
        data = json.loads(r)
        r = client.request(data["url"])
        json_data = json.loads(r)
        m3u_url = json_data['bitrates']['hls']
        m3u_url = json_url = re.sub('^//', 'https://', m3u_url)
        r = client.request(m3u_url)

        root = os.path.dirname(m3u_url)
        sources = m3u8_parser.parse(r)
        try:
            sources.sort(key=lambda x: int(x['resolution'].split('x')[0]),
                         reverse=True)
        except:
            pass

        auto_pick = control.setting('autopick') == '1'

        if len(sources) == 1 or auto_pick == True:
            source = sources[0]['uri']
        else:
            result = xbmcgui.Dialog().select(u'Min\u0151s\u00E9g', [
                str(source['resolution'])
                if 'resolution' in source else 'Unknown' for source in sources
            ])
            if result == -1:
                source = sources[0]['uri']
            else:
                source = sources[result]['uri']
        stream_url = root + '/' + source
        item = control.item(path=stream_url)
        item.setArt({'icon': thumb, 'thumb': thumb})
        item.setInfo(type='Video', infoLabels={'Title': title})
        control.resolve(int(sys.argv[1]), True, item)
    except:
        xbmcgui.Dialog().notification(
            "TV2 Play", "Hiba a forrás elérésekor! Nem található?",
            xbmcgui.NOTIFICATION_ERROR)
        return
示例#4
0
def playVideo():
    from resources.lib import m3u8_parser
    try:
        splittedParam = param.split("/")
        splittedParam[-1] = quote_plus(splittedParam[-1])
        joinedParam = "/".join(splittedParam)
        r = client.request("%s%s/search/%s" % (api_url, "/premium" if ispremium else "", joinedParam), cookie="jwt=%s" % jwtToken if jwtToken else None)
        data = json.loads(r)
        playerId = data["playerId"]
        title = data["title"]
        plot = data["lead"] if "lead" in data else ""
        thumb = "%s/%s" % (base_url, data["imageUrl"]) if "https://" not in data["imageUrl"] else data["imageUrl"]
        r = client.request("%s%s/streaming-url?playerId=%s&stream=undefined" % (api_url, "/premium" if ispremium else "", playerId), cookie="jwt=%s" % jwtToken if jwtToken else None)
        data = json.loads(r)
        if (data["geoBlocked"] != False):
            xbmcgui.Dialog().notification("TV2 Play", "A tartalom a tartózkodási helyedről sajnos nem elérhető!", xbmcgui.NOTIFICATION_ERROR)
            return
        r = client.request(data["url"])
        json_data = json.loads(r)
        m3u_url = json_data['bitrates']['hls']
        m3u_url = json_url = re.sub('^//', 'https://', m3u_url)
        r = client.request(m3u_url)

        root = os.path.dirname(m3u_url)
        sources = m3u8_parser.parse(r)
        try: 
            sources.sort(key=lambda x: int(x['resolution'].split('x')[0]), reverse=True)
        except: 
            pass

        auto_pick = control.setting('autopick') == '1'

        if len(sources) == 1 or auto_pick == True:
            source = sources[0]['uri']
        else:
            result = xbmcgui.Dialog().select(u'Min\u0151s\u00E9g', [str(source['resolution']) if 'resolution' in source else 'Unknown' for source in sources])
            if result == -1:
                source = sources[0]['uri']
            else:
                source = sources[result]['uri']
        stream_url = root + '/' + source
        item = control.item(path=stream_url)
        item.setArt({'icon': thumb, 'thumb': thumb})
        item.setInfo(type='Video', infoLabels = {'Title': title, 'Plot': plot})
        control.resolve(int(sys.argv[1]), True, item)
    except:
        xbmcgui.Dialog().notification("TV2 Play", "Hiba a forrás elérésekor! Nem található?", xbmcgui.NOTIFICATION_ERROR)
示例#5
0
def getVideo():
    from resources.lib import m3u8_parser
    r = client.request(url)
    try:
        try:
            json_url = re.search('jsonUrl\s*=\s*[\'"]([^\'"]+)', r).group(1)
            json_url = re.sub('^//', 'https://', json_url)
        except:
            json_url = re.findall(r'&q;originalUrl&q;:&q;([^}]*)&q;', r)
            json_url = json_url[len(json_url) - 1].replace("&a;", "&")
        r = client.request(json_url)
        json_data = json.loads(r)
        m3u_url = json_data['bitrates']['hls']
        m3u_url = json_url = re.sub('^//', 'https://', m3u_url)
        r = client.request(m3u_url)

        root = os.path.dirname(m3u_url)
        sources = m3u8_parser.parse(r)
        try:
            sources.sort(key=lambda x: int(x['resolution'].split('x')[0]),
                         reverse=True)
        except:
            pass

        auto_pick = control.setting('autopick') == '1'

        if len(sources) == 1 or auto_pick == True:
            source = sources[0]['uri']
        else:
            result = xbmcgui.Dialog().select(u'Min\u0151s\u00E9g', [
                str(source['resolution'])
                if 'resolution' in source else 'Unknown' for source in sources
            ])
            if result == -1:
                source = sources[0]['uri']
            else:
                source = sources[result]['uri']
        stream_url = root + '/' + source

        item = control.item(path=stream_url)
        item.setArt({'icon': iconimage, 'thumb': iconimage})
        item.setInfo(type='Video', infoLabels={'Title': name})
        control.resolve(int(sys.argv[1]), True, item)
    except:
        return