Пример #1
0
def duktape_execute(cmd_params):
    ret = {'sts': False, 'code': -12, 'data': ''}
    noDuk = False
    cmd = GetDukPath()
    if cmd != '':
        cmd += ' ' + cmd_params + ' 2> /dev/null'
        printDBG("duktape_execute cmd[%s]" % cmd)
        ret = iptv_execute()(cmd)

        if ret['code'] == 127:
            noDuk = True
    else:
        noDuk = True
        ret['code'] = 127

    if noDuk:
        messages = [
            _('The %s utility is necessary here but it was not detected.') %
            ('duktape')
        ]
        messages.append(
            _('Please consider restarting your Engima2 and agree to install the %s utlity when %s asks.'
              ) % ('duktape', 'E2iStream'))
        GetIPTVNotify().push('\n'.join(messages), 'error', 40, 'no_duktape',
                             40)

    printDBG('duktape_execute cmd ret[%s]' % ret)
    return ret
Пример #2
0
    def getResolvedVideoLink(self, videoUrl):
        printDBG("BilaSportPwApi.getResolvedVideoLink [%s]" % videoUrl)
        urlsTab = []

        meta = strwithmeta(videoUrl).meta

        baseUrl = self.cm.getBaseUrl(videoUrl.meta.get('Referer', ''))
        scriptUrl = videoUrl.meta.get('priv_script_url', '')
        if scriptUrl:
            sts, data = self.getPage(scriptUrl)
            if not sts:
                return []
            hash = '/tmp/%s' % hexlify(md5(data).digest())
            data = 'btoa=function(t){return Duktape.enc("base64",t)},XMLHttpRequest=function(){},XMLHttpRequest.prototype.open=function(t,e,n,o,p){print(str(e))};' + data + 'tmp = new XMLHttpRequest();'
            try:
                with open(hash + '.js', 'w') as f:
                    f.write(data)
            except Exception:
                printExc()
                return []
            duktape_execute('-c "%s.byte" "%s.js" ' % (hash, hash))
            rm(hash + '.js')
            scriptUrl = hash

        sts, data = self.getPage(videoUrl)
        if not sts or '#EXTM3U' not in data:
            return urlsTab

        keyUrl = set(
            re.compile('''#EXT\-X\-KEY.*?URI=['"](https?://[^"]+?)['"]''').
            findall(data))
        if len(keyUrl):
            keyUrl = keyUrl.pop()
            proto = keyUrl.split('://', 1)[0]
            pyCmd = GetPyScriptCmd(
                'livesports') + ' "%s" "%s" "%s" "%s" "%s" "%s" "%s" ' % (
                    config.plugins.iptvplayer.bilasportpw_port.value, videoUrl,
                    baseUrl, scriptUrl, self.HTTP_HEADER['User-Agent'],
                    self.COOKIE_FILE, GetDukPath())
            meta = {'iptv_proto': 'em3u8'}
            meta['iptv_m3u8_key_uri_replace_old'] = '%s://' % proto
            meta[
                'iptv_m3u8_key_uri_replace_new'] = 'http://127.0.0.1:{0}/{1}/'.format(
                    config.plugins.iptvplayer.bilasportpw_port.value, proto)
            meta['iptv_refresh_cmd'] = pyCmd
            videoUrl = urlparser.decorateUrl("ext://url/" + videoUrl, meta)
        else:
            videoUrl = urlparser.decorateUrl(videoUrl, meta)
        return [{'name': 'direct', 'url': videoUrl}]