コード例 #1
0
 def readLoginMarker(self):
     printDBG("PlusDEDE.saveLoginMarker")
     sts, marker = ReadTextFile(self.LOGIN_MARKER_FILE)
     if not sts:
         marker = ''
     printDBG("marker[%s]" % marker)
     return marker
コード例 #2
0
    def listsMainMenu(self, cItem):
        printDBG("LocalMedia.listsMainMenu [%s]" % cItem)
        # list mount points
        predefined = [{
            'title': _('IPTV Recordings'),
            'path': config.plugins.iptvplayer.NaszaSciezka.value
        }, {
            'title': _('rootfs'),
            'path': '/'
        }]
        for item in predefined:
            params = dict(cItem)
            params.update(item)
            self.addDir(params)

        sts, data = ReadTextFile('/proc/mounts')
        if sts:
            # item[0] # device, item[1] # path, item[2] # filesystem
            data = data.split('\n')
            for item in data:
                item = item.split(' ')
                printDBG(item)
                if len(item) < 3: continue
                if '/' != item[1] and item[2] in self.FILE_SYSTEMS:
                    params = dict(cItem)
                    params.update({'title': item[1], 'path': item[1]})
                    self.addDir(params)
コード例 #3
0
ファイル: hostlocalmedia.py プロジェクト: trunca/video
 def listM3u(self, cItem):
     printDBG("LocalMedia.listM3u [%s]" % cItem)
     path = cItem['path']
     sts, data = ReadTextFile(path)
     if not sts: return
     baseUrl = ''
     if '#EXTM3U' not in data:
         baseUrl = data.strip()
         if baseUrl.startswith('http') and '://' in baseUrl:
             baseUrl = self.up.decorateParamsFromUrl(baseUrl) 
             httpParams, postData = self.cm.getParamsFromUrlWithMeta(baseUrl)
             sts, data = self.cm.getPage(baseUrl, httpParams, postData)
             if not sts: return
     
     data = ParseM3u(data)
     for item in data:
         params = dict(cItem)
         need_resolve = 1
         url = item['uri']
         if url.startswith('/'):
             if baseUrl == '':
                 url = 'file://' + url
                 need_resolve = 0
             elif url.startswith('//'):
                 url = 'http:' + url
             else:
                 url = self.cm.getBaseUrl(baseUrl) + url[1:]
         params.update( {'title':item['title'], 'category':'m3u_item', 'url':url, 'need_resolve':need_resolve} )
         self.addVideo(params)
コード例 #4
0
 def tryTologin(self):
     printDBG('tryTologin start')
     loginUrl = self.getFullUrl('?view=perfil')
     if None == self.loggedIn or self.login != config.plugins.iptvplayer.dixmax_login.value or self.password != config.plugins.iptvplayer.dixmax_password.value:
         loginCookie = GetCookieDir('dixmax.com.login')
         self.login = config.plugins.iptvplayer.dixmax_login.value
         self.password = config.plugins.iptvplayer.dixmax_password.value
         sts, data = self.getPage(loginUrl)
         if sts:
             self.setMainUrl(self.cm.meta['url'])
         freshSession = False
         if sts and 'logout.php' in data:
             printDBG('Check hash')
             hash = hexlify(md5('%s@***@%s' % (self.login, self.password)).digest())
             prevHash = ReadTextFile(loginCookie)[1].strip()
             printDBG('$hash[%s] $prevHash[%s]' % (hash, prevHash))
             if hash == prevHash:
                 self.loggedIn = True
                 return
             freshSession = True
         rm(loginCookie)
         rm(self.COOKIE_FILE)
         if freshSession:
             sts, data = self.getPage(self.getMainUrl(), MergeDicts(self.defaultParams, {'use_new_session': True}))
         self.loggedIn = False
         if '' == self.login.strip() or '' == self.password.strip():
             msg = _('The host %s requires registration. \nPlease fill your login and password in the host configuration. Available under blue button.' % self.getMainUrl())
             self.sessionEx.waitForFinishOpen(MessageBox, msg, type=MessageBox.TYPE_INFO, timeout=10)
             return False
         msgTab = [_('Login failed.')]
         if sts:
             actionUrl = self.getFullUrl('/session.php?action=1')
             post_data = {'username': self.login,
              'password': self.password,
              'remember': '1'}
             httpParams = dict(self.defaultParams)
             httpParams['header'] = MergeDicts(httpParams['header'], {'Referer': self.cm.meta['url'],
              'Accept': '*/*'})
             sts, data = self.getPage(actionUrl, httpParams, post_data)
             printDBG(data)
             if sts:
                 msgTab.append(ph.clean_html(data))
             sts, data = self.getPage(loginUrl)
         # if sts and 'logout.php' in data:
         if sts and 'local_out' in data:
             printDBG('tryTologin OK')
             self.loggedIn = True
         else:
             printDBG(data)
             self.sessionEx.waitForFinishOpen(MessageBox, '\n'.join(msgTab), type=MessageBox.TYPE_ERROR, timeout=10)
             printDBG('tryTologin failed')
         if self.loggedIn:
             hash = hexlify(md5('%s@***@%s' % (self.login, self.password)).digest())
             WriteTextFile(loginCookie, hash)
     return self.loggedIn
コード例 #5
0
def is_js_cached(name, hash):
    ret = False
    byteFileName = GetJSCacheDir(name + '.byte')
    metaFileName = GetJSCacheDir(name + '.meta')
    if fileExists(byteFileName):
        sts, tmp = ReadTextFile(metaFileName)
        if sts:
            tmp = tmp.split('|')
            if DUKTAPE_VER == tmp[0] and hash == tmp[-1].strip():
                ret = True
    return ret
コード例 #6
0
 def listM3u(self, cItem, nextCategory):
     printDBG("LocalMedia.listM3u [%s]" % cItem)
     baseUrl = ''
     data = ''
     if not self.cm.isValidUrl(cItem['path']):
         sts, data = ReadTextFile(cItem['path'])
         if not sts: return
         if '#EXT' not in data:
             baseUrl = data.strip()
     else: 
         baseUrl = cItem['path']
     
     if self.cm.isValidUrl(baseUrl):
         baseUrl = self.up.decorateParamsFromUrl(baseUrl) 
         httpParams, postData = self.cm.getParamsFromUrlWithMeta(baseUrl)
         sts, data = self.cm.getPage(baseUrl, httpParams, postData)
         if not sts: return
     
     data = ParseM3u(data)
     groups = {}
     for item in data:
         params = dict(cItem)
         group = item.get('group-title', '')
         url = item['uri']
         icon = self._getM3uIcon(item, cItem)
         
         if item['f_type'] == 'inf':
             if group == '':
                 need_resolve, url = self._getM3uPlayableUrl(baseUrl, url, item)
                 params.update( {'good_for_fav':True, 'title':item['title'], 'category':'m3u_item', 'url':url, 'desc':item.get('tvg-name', ''), 'icon':icon, 'need_resolve':need_resolve} )
                 self.addVideo(params)
             else:
                 if group not in groups:
                     groupIcon = item.get('group-logo', '')
                     if not self.cm.isValidUrl(groupIcon): groupIcon = item.get('group-art', '')
                     if not self.cm.isValidUrl(groupIcon): groupIcon = icon
                     groups[group] = []
                     params.update( {'good_for_fav':False, 'title':group, 'category':nextCategory, 'f_group':group, 'url':baseUrl, 'desc':'', 'icon':groupIcon} )
                     if 'parent-code' in item: params.update({'pin_locked':True, 'pin_code':item['parent-code']})
                     self.addDir(params)
                 groups[group].append(item)
         elif item['f_type'] == 'import' and self.cm.isValidUrl(url):
             params.update( {'good_for_fav':True, 'title':item['title'], 'path':url, 'desc':'', 'icon':icon} )
             self.addDir(params)
     
     if groups != {}:
         for idx in range(len(self.currList)):
             if 'f_group' in self.currList[idx]:
                 self.currList[idx]['f_group_items'] = groups.get(self.currList[idx]['f_group'], [])
コード例 #7
0
 def listM3u(self, cItem):
     printDBG("LocalMedia.listM3u [%s]" % cItem)
     path = cItem['path']
     sts, data = ReadTextFile(path)
     if not sts: return
     data = ParseM3u(data)
     for item in data:
         params = dict(cItem)
         need_resolve = 1
         url = item['uri']
         if url.startswith('/'):
             url = 'file://' + url
             need_resolve = 0
         params.update({
             'title': item['title'],
             'category': 'm3u_item',
             'url': url,
             'need_resolve': need_resolve
         })
         self.addVideo(params)
コード例 #8
0
    def tryTologin(self):
        printDBG('tryTologin start')
        self.selectDomain()

        if None == self.loggedIn or self.login != config.plugins.iptvplayer.filmixco_login.value or\
            self.password != config.plugins.iptvplayer.filmixco_password.value:

            loginCookie = GetCookieDir('filmix.co.login')
            self.login = config.plugins.iptvplayer.filmixco_login.value
            self.password = config.plugins.iptvplayer.filmixco_password.value

            sts, data = self.getPage(self.getMainUrl())
            if sts: self.setMainUrl(self.cm.meta['url'])

            freshSession = False
            if sts and 'action=logout' in data:
                printDBG("Check hash")
                hash = hexlify(md5('%s@***@%s' % (self.login, self.password)).digest())
                prevHash = ReadTextFile(loginCookie)[1].strip()

                printDBG("$hash[%s] $prevHash[%s]" % (hash, prevHash))
                if hash == prevHash:
                    self.loggedIn = True
                    return
                else:
                    freshSession = True

            rm(loginCookie)
            rm(self.COOKIE_FILE)
            if freshSession:
                sts, data = self.getPage(self.getMainUrl(), MergeDicts(self.defaultParams, {'use_new_session':True}))

            self.loggedIn = False
            if '' == self.login.strip() or '' == self.password.strip():
                return False

            msgTab = [_('Login failed.')]
            if sts:
                actionUrl = self.getFullUrl('/engine/ajax/user_auth.php')
                post_data = {'login_name':self.login, 'login_password':self.password, 'login_not_save':'1', 'login':'******'}

                httpParams = dict(self.defaultParams)
                httpParams['header'] = MergeDicts(httpParams['header'], {'Referer':self.cm.meta['url'], 'Accept':'*/*', 'X-Requested-With':'XMLHttpRequest', 'Content-Type':'application/x-www-form-urlencoded; charset=UTF-8'})

                sts, data = self.getPage(actionUrl, httpParams, post_data)
                printDBG(data)
                if sts: msgTab.append(ph.clean_html(data))
                sts, data = self.getPage(self.getMainUrl())

            if sts and 'action=logout' in data:
                printDBG('tryTologin OK')
                self.loggedIn = True
            else:
                printDBG(data)
                self.sessionEx.waitForFinishOpen(MessageBox, '\n'.join(msgTab), type = MessageBox.TYPE_ERROR, timeout = 10)
                printDBG('tryTologin failed')

            if self.loggedIn:
                hash = hexlify(md5('%s@***@%s' % (self.login, self.password)).digest())
                WriteTextFile(loginCookie, hash)

        return self.loggedIn
コード例 #9
0
    def tryTologin(self):
        printDBG('tryTologin start')

        if None == self.loggedIn or self.login != config.plugins.iptvplayer.serienstreamto_login.value or\
            self.password != config.plugins.iptvplayer.serienstreamto_password.value:

            loginCookie = GetCookieDir('s.to.login')
            self.login = config.plugins.iptvplayer.serienstreamto_login.value
            self.password = config.plugins.iptvplayer.serienstreamto_password.value

            sts, data = self.cm.getPage(self.getMainUrl(), self.defaultParams)
            if sts: self.setMainUrl(self.cm.meta['url'])

            freshSession = False
            if sts and '/home/logout' in data:
                printDBG("Check hash")
                hash = hexlify(
                    md5('%s@***@%s' % (self.login, self.password)).digest())
                prevHash = ReadTextFile(loginCookie)[1].strip()

                printDBG("$hash[%s] $prevHash[%s]" % (hash, prevHash))
                if hash == prevHash:
                    self.loggedIn = True
                    return
                else:
                    freshSession = True

            rm(loginCookie)
            rm(self.COOKIE_FILE)
            if freshSession:
                sts, data = self.cm.getPage(
                    self.getMainUrl(),
                    MergeDicts(self.defaultParams, {'use_new_session': True}))

            self.loggedIn = False
            if '' == self.login.strip() or '' == self.password.strip():
                return False

            actionUrl = self.getFullUrl('/login')
            post_data = {
                'email': self.login,
                'password': self.password,
                'autoLogin': '******'
            }
            tries = 0
            while tries < 3:
                tries += 1
                errorMsg = ''
                httpParams = dict(self.defaultParams)
                httpParams['header'] = dict(httpParams['header'])
                httpParams['header']['Referer'] = actionUrl
                sts, data = self.getPage(actionUrl, httpParams, post_data)
                printDBG(
                    "+++++++++++++++++++++++++++++++++++++++++++++++++++++++")
                printDBG(data)
                printDBG(
                    "+++++++++++++++++++++++++++++++++++++++++++++++++++++++")
                if sts and not data.strip():
                    sts, data = self.getPage(actionUrl)
                if sts and '/home/logout' in data:
                    printDBG('tryTologin OK')
                    self.loggedIn = True
                    break
                elif sts:
                    errorMsg = ph.clean_html(
                        ph.find(data, ('<div', '>', 'messageAlert'),
                                '</div>',
                                flags=0)[1])
                    tmp1 = ph.find(data, ('<div', '>', 'formCaptcha'),
                                   '</div>',
                                   flags=0)[1]
                    imgUrl = self.getFullUrl(
                        ph.search(tmp1, ph.IMAGE_SRC_URI_RE)[1],
                        self.cm.meta['url'])
                    tmp2 = ph.find(data, ('<input', '>', 'captcha'),
                                   flags=0)[1]
                    if imgUrl:
                        captchaLabel = _('Captcha')
                        captchaTitle = errorMsg
                        sendLabel = _('Send')

                        header = dict(httpParams['header'])
                        header['Accept'] = 'image/png,image/*;q=0.8,*/*;q=0.5'
                        params = dict(self.defaultParams)
                        params.update({
                            'maintype':
                            'image',
                            'subtypes': ['jpeg', 'png'],
                            'check_first_bytes':
                            ['\xFF\xD8', '\xFF\xD9', '\x89\x50\x4E\x47'],
                            'header':
                            header
                        })
                        filePath = GetTmpDir('.iptvplayer_captcha.jpg')
                        rm(filePath)
                        ret = self.cm.saveWebFile(filePath,
                                                  imgUrl.replace('&amp;', '&'),
                                                  params)
                        if not ret.get('sts'):
                            SetIPTVPlayerLastHostError(
                                _('Fail to get "%s".') % imgUrl)
                            return
                        params = deepcopy(IPTVMultipleInputBox.DEF_PARAMS)
                        params['accep_label'] = sendLabel
                        params['title'] = captchaLabel
                        params['status_text'] = captchaTitle
                        params['status_text_hight'] = 200
                        params['with_accept_button'] = True
                        params['list'] = []
                        item = deepcopy(IPTVMultipleInputBox.DEF_INPUT_PARAMS)
                        item['label_size'] = (660, 110)
                        item['input_size'] = (680, 25)
                        item['icon_path'] = filePath
                        item['title'] = _('Answer')
                        item['input']['text'] = ''
                        params['list'].append(item)
                        #params['vk_params'] = {'invert_letters_case':True}

                        ret = 0
                        retArg = self.sessionEx.waitForFinishOpen(
                            IPTVMultipleInputBox, params)
                        printDBG(retArg)
                        if retArg and len(retArg) and retArg[0]:
                            printDBG(retArg[0])
                            post_data['captcha'] = retArg[0][0]
                            continue
                        else:
                            break

            if self.loggedIn:
                hash = hexlify(
                    md5('%s@***@%s' % (self.login, self.password)).digest())
                WriteTextFile(loginCookie, hash)
            else:
                self.sessionEx.open(MessageBox,
                                    _('Login failed.') + '\n' + errorMsg,
                                    type=MessageBox.TYPE_ERROR,
                                    timeout=10)

        return self.loggedIn
コード例 #10
0
    def getVideoLinks(self, videoUrl):
        printDBG("BSTO.getVideoLinks [%s]" % videoUrl)
        urlTab = []

        key = strwithmeta(videoUrl).meta.get('links_key', '')
        if key in self.cacheLinks:
            for idx in range(len(self.cacheLinks[key])):
                if self.cacheLinks[key][idx][
                        'url'] == videoUrl and not self.cacheLinks[key][idx][
                            'name'].startswith('*'):
                    self.cacheLinks[key][idx][
                        'name'] = '*' + self.cacheLinks[key][idx]['name']

        sts, data = self.getPage(videoUrl)
        if not sts:
            return []

        errorMsgTab = []

        baseUrl = self.cm.ph.getSearchGroups(
            data, '''href=['"][^'^"]*?(/out/[^'^"]+?)['"]''')[0]
        url = self.getFullUrl(baseUrl)
        prevUrl = url

        linkId = self.cm.ph.getSearchGroups(url, '''/out/([0-9]+)''')[0]
        hostUrl = BSTO.LINKS_CACHE.get(linkId, '')
        if hostUrl == '' and config.plugins.iptvplayer.bsto_linkcache.value:
            hostUrl = ReadTextFile(GetCacheSubDir('bs.to', linkId))[1]

        if hostUrl == '':
            sts, data = self.cm.getPage(prevUrl, self.defaultParams)
            if not sts:
                return []
            url = data.meta['url']

            if url == prevUrl:
                query = {}
                tmp = self.cm.ph.getDataBeetwenNodes(data, ('<form', '>'),
                                                     ('</form', '>'), False)[1]
                tmp = self.cm.ph.getAllItemsBeetwenMarkers(
                    tmp, '<input', '>', False)
                for item in tmp:
                    name = self.cm.ph.getSearchGroups(
                        item, '''name=['"]([^'^"]+?)['"]''')[0]
                    value = self.cm.ph.getSearchGroups(
                        item, '''value=['"]([^'^"]+?)['"]''')[0]
                    if name != '':
                        query[name] = value

                sitekey = self.cm.ph.getSearchGroups(
                    data, '''['"]sitekey['"]\s*?:\s*?['"]([^'^"]+?)['"]''')[0]
                if sitekey != '' and 'bitte das Captcha' in data:
                    token, errorMsgTab = self.processCaptcha(
                        sitekey, self.cm.meta['url'],
                        config.plugins.iptvplayer.bsto_bypassrecaptcha.value)
                    if token != '':
                        sts, data = self.cm.getPage(
                            url + '?t=%s&s=%s' % (token, query.get('s', '')),
                            self.defaultParams)
                        if not sts:
                            return []
                        url = data.meta['url']

            if 1 != self.up.checkHostSupport(url):
                url = baseUrl.replace('/out/', '/watch/')[1:]

                hostUrl = ''
                try:
                    sts, data = self.cm.getPage(self.getFullUrl('/api/' + url),
                                                self.getHeaders(url))
                    if not sts:
                        return []

                    data = byteify(json.loads(data))
                    printDBG(data)

                    hostUrl = data['fullurl']
                except Exception:
                    printExc()
            else:
                hostUrl = url

        if 1 != self.up.checkHostSupport(hostUrl):
            SetIPTVPlayerLastHostError('\n'.join(errorMsgTab))
        elif self.cm.isValidUrl(hostUrl):
            BSTO.LINKS_CACHE[linkId] = hostUrl
            if config.plugins.iptvplayer.bsto_linkcache.value:
                WriteTextFile(GetCacheSubDir('bs.to', linkId), hostUrl)
            urlTab = self.up.getVideoLinkExt(hostUrl)

        return urlTab
コード例 #11
0
    def tryTologin(self):
        printDBG('tryTologin start')

        if None == self.loggedIn or self.login != config.plugins.iptvplayer.vidcorn_login.value or\
            self.password != config.plugins.iptvplayer.vidcorn_password.value:

            loginCookie = GetCookieDir('vidcorn.com.login')
            self.login = config.plugins.iptvplayer.vidcorn_login.value
            self.password = config.plugins.iptvplayer.vidcorn_password.value

            sts, data = self.getPage(self.getMainUrl())
            if sts:
                self.setMainUrl(self.cm.meta['url'])

            freshSession = False
            if sts and '/logout' in data:
                printDBG("Check hash")
                hash = hexlify(
                    md5('%s@***@%s' % (self.login, self.password)).digest())
                prevHash = ReadTextFile(loginCookie)[1].strip()

                printDBG("$hash[%s] $prevHash[%s]" % (hash, prevHash))
                if hash == prevHash:
                    self.loggedIn = True
                    return
                else:
                    freshSession = True

            rm(loginCookie)
            rm(self.COOKIE_FILE)
            if freshSession:
                sts, data = self.getPage(
                    self.getMainUrl(),
                    MergeDicts(self.defaultParams, {'use_new_session': True}))

            self.loggedIn = False
            if '' == self.login.strip() or '' == self.password.strip():
                return False

            if sts:
                data = self.cm.ph.getDataBeetwenNodes(
                    data, ('<form', '>', 'login-form'), ('</form', '>'), True,
                    False)[1]

                actionUrl = self.getFullUrl('/services/login')
                post_data = {'username': self.login, 'password': self.password}

                sitekey = self.cm.ph.getSearchGroups(
                    data, '''sitekey=['"]([^'^"]+?)['"]''')[0]
                if sitekey != '':
                    token, errorMsgTab = self.processCaptcha(
                        sitekey, self.cm.meta['url'])
                    if token == '':
                        return False
                    post_data['g-recaptcha-response'] = token

                httpParams = dict(self.defaultParams)
                httpParams['header'] = MergeDicts(
                    httpParams['header'], {
                        'Referer':
                        self.cm.meta['url'],
                        'X-Requested-With':
                        'XMLHttpRequest',
                        'Content-Type':
                        'application/x-www-form-urlencoded; charset=UTF-8'
                    })

                sts, data = self.getPage(actionUrl, httpParams, post_data)

            if sts and data.strip() == 'success':
                printDBG('tryTologin OK')
                self.loggedIn = True
            else:
                msgTab = [_('Login failed.')]
                if sts:
                    data = self.cm.ph.getAllItemsBeetwenMarkers(
                        data, 'error-modal', ');')
                    for item in data:
                        item = self.cleanHtmlStr(
                            self.cm.ph.getDataBeetwenMarkers(
                                item, '(', ')', False)[1].strip()[1:-1])
                        if item != '':
                            msgTab.append(item)
                self.sessionEx.waitForFinishOpen(MessageBox,
                                                 '\n'.join(msgTab),
                                                 type=MessageBox.TYPE_ERROR,
                                                 timeout=10)
                printDBG('tryTologin failed')

            if self.loggedIn:
                hash = hexlify(
                    md5('%s@***@%s' % (self.login, self.password)).digest())
                WriteTextFile(loginCookie, hash)

        return self.loggedIn
コード例 #12
0
def js_execute_ext(items, params={}):
    fileList = []
    tmpFiles = []

    tid = thread.get_ident()
    uniqueId = 0
    ret = {'sts': False, 'code': -13, 'data': ''}
    try:
        for item in items:
            # we can have source file or source code
            path = item.get('path', '')
            code = item.get('code', '')

            name = item.get('name', '')
            if name:  # cache enabled
                hash = item.get('hash', '')
                if not hash:
                    # we will need to calc hash by our self
                    if path:
                        sts, code = ReadTextFile(path)
                        if not sts:
                            raise Exception('Faile to read file "%s"!' % path)
                    hash = hexlify(md5(code).digest())
                byteFileName = GetJSCacheDir(name + '.byte')
                metaFileName = GetJSCacheDir(name + '.meta')
                if fileExists(byteFileName):
                    sts, tmp = ReadTextFile(metaFileName)
                    if sts:
                        tmp = tmp.split('|')  # DUKTAPE_VER|hash
                        if DUKTAPE_VER != tmp[0] or hash != tmp[-1].strip():
                            sts = False
                    if not sts:
                        rm(byteFileName)
                        rm(metaFileName)
                else:
                    sts = False

                if not sts:
                    # we need compile here
                    if not path:
                        path = '.%s.js' % name
                        sts, path = CreateTmpFile(path, code)
                        if not sts:
                            raise Exception('Faile to create file "%s" "%s"' %
                                            (path, code))
                        tmpFiles.append(path)

                    # remove old meta
                    rm(metaFileName)

                    # compile
                    if 0 != duktape_execute('-c "%s" "%s" ' %
                                            (byteFileName, path))['code']:
                        raise Exception(
                            'Compile to bytecode file "%s" > "%s" failed!' %
                            (path, byteFileName))

                    # update meta
                    if not WriteTextFile(metaFileName, '%s|%s' %
                                         (DUKTAPE_VER, hash)):
                        raise Exception('Faile to write "%s" file!' %
                                        metaFileName)

                fileList.append(byteFileName)
            else:
                if path:
                    fileList.append(path)
                else:
                    path = 'e2i_js_exe_%s_%s.js' % (uniqueId, tid)
                    uniqueId += 1
                    sts, path = CreateTmpFile(path, code)
                    if not sts:
                        raise Exception('Faile to create file "%s"' % path)
                    tmpFiles.append(path)
                    fileList.append(path)
        #ret = duktape_execute('-t %s ' % params.get('timeout_sec', 20) + ' '.join([ '"%s"' % file for file in fileList ]) )
        ret = duktape_execute(' '.join(['"%s"' % file for file in fileList]))
    except Exception:
        printExc()

    # leave last script for debug purpose
    if getDebugMode() == '':
        for file in tmpFiles:
            rm(file)
    return ret
コード例 #13
0
ファイル: hostmrpiracy.py プロジェクト: myarchives/e2iPlayer
    def getVideoLinks(self, videoUrl):
        printDBG("MRPiracyGQ.getVideoLinks [%s]" % videoUrl)
        errorMsgTab = []
        urlTab = []

        # mark requested link as used one
        if len(self.cacheLinks.keys()):
            for key in self.cacheLinks:
                for idx in range(len(self.cacheLinks[key])):
                    if videoUrl in self.cacheLinks[key][idx]['url']:
                        if not self.cacheLinks[key][idx]['name'].startswith(
                                '*'):
                            self.cacheLinks[key][idx][
                                'name'] = '*' + self.cacheLinks[key][idx][
                                    'name']
                        break

        if self.cm.isValidUrl(videoUrl):
            return self.up.getVideoLinkExt(videoUrl)

        playerData = strwithmeta(videoUrl).meta
        linkId = ''
        imdbId = ''
        try:
            tmp = []
            for it in ['playertype', 'episodio', 'id']:
                tmp.append(playerData.get(it, ''))
            imdbId = self.cm.ph.getSearchGroups(playerData['ref_url'],
                                                '''imdb=(tt[0-9]+)''')[0]
            tmp.insert(0, imdbId)
            linkId = '_'.join(tmp)
        except Exception:
            printExc()

        printDBG(">>> linkId[%s]" % linkId)
        hostUrl = MRPiracyGQ.LINKS_CACHE.get(linkId, '')
        if hostUrl == '' and config.plugins.iptvplayer.mrpiracy_linkcache.value:
            hostUrl = ReadTextFile(GetCacheSubDir('mrpiracy', linkId))[1]

        if hostUrl == '':
            try:
                jscode = playerData.pop('jscode', '')
                jscode += '''var iptv_fake_element={hide:function(){},show:function(){},addClass:function(){},removeClass:function(){}};playertype="iptv_player_data";var iptv_player_data=''' + json.dumps(
                    playerData
                ) + ''';$=function(){return 1==arguments.length&&arguments[0].endsWith(playertype)?{data:function(a){return iptv_player_data[a]}}:iptv_fake_element},$.ajax=function(){print(JSON.stringify(arguments[0]))},''' + playerData[
                    'callback'] + '''(iptv_player_data.sitekey);'''
                ret = js_execute(jscode)
                data = ret['data'].strip()
                data = byteify(json.loads(data))

                url = self.getFullUrl(data['url'])
                post_data = data['data']
                urlParams = dict(self.defaultParams)
                urlParams['header'] = dict(self.AJAX_HEADER)
                urlParams['header']['Referer'] = playerData['ref_url']

                if 'sitekey' in playerData:
                    token, errorMsgTab = self.processCaptcha(
                        playerData['sitekey'], playerData['ref_url'], config.
                        plugins.iptvplayer.mrpiracy_bypassrecaptcha.value)
                    printDBG('> token "%s" ' % token)
                    post_data['token'] = token

                sts, data = self.getPage(url, urlParams, post_data)
                printDBG("$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$")
                printDBG(data)
                printDBG("$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$")
                tmp = re.compile('''['"](https?://[^'^"]+?)['"]''').findall(
                    data)
                for item in tmp:
                    if 1 == self.up.checkHostSupport(item):
                        hostUrl = item

                if hostUrl == '':
                    url = self.getFullUrl(
                        self.cm.ph.getSearchGroups(
                            data,
                            '<iframe[^>]+?src="([^"]+?)"',
                            1,
                            ignoreCase=True)[0])
                    if url != '':
                        urlParams = dict(self.defaultParams)
                        urlParams['header'] = dict(urlParams['header'])
                        urlParams['header']['Referer'] = playerData['ref_url']
                        sts, data = self.getPage(url, urlParams)
                        hostUrl = self.cm.ph.getSearchGroups(
                            data, '''location\.href=['"]([^'^"]+?)['"]''')[0]
            except Exception:
                printExc()

        if self.cm.isValidUrl(hostUrl):
            if linkId != '':
                if config.plugins.iptvplayer.mrpiracy_linkcache.value and linkId not in MRPiracyGQ.LINKS_CACHE:
                    WriteTextFile(GetCacheSubDir('mrpiracy', linkId), hostUrl)
                MRPiracyGQ.LINKS_CACHE[linkId] = hostUrl

            urlTab = self.up.getVideoLinkExt(hostUrl)

        if 0 == len(urlTab):
            SetIPTVPlayerLastHostError('\n'.join(errorMsgTab))
        else:
            subUrl = 'https://cdn.mrpiracy.xyz/subs/%s.srt' % imdbId
            sts, data = self.getPage(subUrl)
            if sts and '00:' in data:
                for idx in range(len(urlTab)):
                    urlTab[idx]['url'] = strwithmeta(urlTab[idx]['url'])
                    if 'external_sub_tracks' not in urlTab[idx]['url'].meta:
                        urlTab[idx]['url'].meta['external_sub_tracks'] = []
                    urlTab[idx]['url'].meta['external_sub_tracks'].append({
                        'title':
                        '',
                        'url':
                        subUrl,
                        'lang':
                        'pt',
                        'format':
                        'srt'
                    })
        return urlTab
コード例 #14
0
    def tryTologin(self):
        printDBG('tryTologin start')

        if None == self.loggedIn or self.login != config.plugins.iptvplayer.cda_login.value or\
            self.password != config.plugins.iptvplayer.cda_password.value:

            loginCookie = GetCookieDir('cda.pl.login')
            self.login = config.plugins.iptvplayer.cda_login.value
            self.password = config.plugins.iptvplayer.cda_password.value

            sts, data = self.getPage(self.getMainUrl(), self.defaultParams)
            if sts:
                self.setMainUrl(self.cm.meta['url'])

            freshSession = False
            if sts and '/logout' in data:
                printDBG("Check hash")
                hash = hexlify(
                    md5('%s@***@%s' % (self.login, self.password)).digest())
                prevHash = ReadTextFile(loginCookie)[1].strip()

                printDBG("$hash[%s] $prevHash[%s]" % (hash, prevHash))
                if hash == prevHash:
                    self.loggedIn = True
                    return
                else:
                    freshSession = True

            rm(loginCookie)
            rm(self.COOKIE_FILE)
            if freshSession:
                sts, data = self.getPage(
                    self.getMainUrl(),
                    MergeDicts(self.defaultParams, {'use_new_session': True}))

            self.loggedIn = False
            if '' == self.login.strip() or '' == self.password.strip():
                return False

            actionUrl = 'https://www.cda.pl/login'
            sitekey = ''

            sts, data = self.getPage(actionUrl, self.defaultParams)
            tries = 0
            while tries < 2:
                msgTab = [_('Login failed.')]
                tries += 1
                if sts:
                    r = ph.search(
                        data,
                        '''name=['"]r['"][^>]+?value=['"]([^'^"]+?)['"]''',
                        flags=ph.I)[0]
                    post_data = {
                        "r": r,
                        "username": self.login,
                        "password": self.password,
                        "login": "******"
                    }
                    params = dict(self.defaultParams)
                    HEADER = dict(self.AJAX_HEADER)
                    HEADER['Referer'] = self.MAIN_URL
                    params.update({'header': HEADER})

                    tmp = ph.findall(data, ('<form', '>', '/login'),
                                     '</form>',
                                     flags=ph.I)
                    for item in tmp:
                        if 'data-sitekey' in item:
                            sitekey = ph.search(
                                item,
                                '''data\-sitekey=['"]([^'^"]+?)['"]''')[0]
                            break

                    if sitekey != '':
                        token, errorMsgTab = self.processCaptcha(
                            sitekey, self.cm.meta['url'])
                        if token != '':
                            post_data['g-recaptcha-response'] = token

                    # login
                    sts, data = self.getPage(actionUrl, params, post_data)

                    printDBG(data)
                    if sts:
                        msgTab.append(
                            ph.clean_html(
                                ph.find(data, ('<p', '>', 'error-form'),
                                        '</p>',
                                        flags=0)[1]))

                if sts and '/logout' in data:
                    printDBG('tryTologin OK')
                    self.loggedIn = True
                elif sts and sitekey == '' and 'data-sitekey' in data:
                    continue
                else:
                    #printDBG(data)
                    self.sessionEx.waitForFinishOpen(
                        MessageBox,
                        '\n'.join(msgTab),
                        type=MessageBox.TYPE_ERROR,
                        timeout=10)
                    printDBG('tryTologin failed')
                break

            if self.loggedIn:
                hash = hexlify(
                    md5('%s@***@%s' % (self.login, self.password)).digest())
                WriteTextFile(loginCookie, hash)

        return self.loggedIn
コード例 #15
0
    def tryTologin(self):
        printDBG('tryTologin start')

        if None == self.loggedIn or self.login != config.plugins.iptvplayer.hdfull_login.value or \
            self.password != config.plugins.iptvplayer.hdfull_password.value:

            self.cm.clearCookie(self.COOKIE_FILE, removeNames=['language'])

            loginCookie = GetCookieDir('hdfull.me.login')
            self.login = config.plugins.iptvplayer.hdfull_login.value
            self.password = config.plugins.iptvplayer.hdfull_password.value

            sts, data = self.getPage(self.getMainUrl())
            if sts: self.setMainUrl(self.cm.meta['url'])

            freshSession = False
            if sts and '/logout' in data:
                printDBG("Check hash")
                hash = hexlify(
                    md5('%s@***@%s' % (self.login, self.password)).digest())
                prevHash = ReadTextFile(loginCookie)[1].strip()

                printDBG("$hash[%s] $prevHash[%s]" % (hash, prevHash))
                if hash == prevHash:
                    self.loggedIn = True
                    return
                else:
                    freshSession = True

            rm(loginCookie)
            rm(self.COOKIE_FILE)
            if freshSession:
                sts, data = self.getPage(
                    self.getMainUrl(),
                    MergeDicts(self.defaultParams, {'use_new_session': True}))

            self.loggedIn = False
            if '' == self.login.strip() or '' == self.password.strip():
                return False

            if sts:
                actionUrl = self.cm.meta['url']
                post_data = {}
                data = self.cm.ph.getDataBeetwenNodes(
                    data, ('<form', '>', 'login_form'), ('</form', '>'), True,
                    False)[1]
                data = self.cm.ph.getAllItemsBeetwenMarkers(
                    data, '<input', '>', False)
                for item in data:
                    name = self.cm.ph.getSearchGroups(
                        item, '''name=['"]([^"^']+?)['"]''')[0]
                    value = self.cm.ph.getSearchGroups(
                        item, '''value=['"]([^"^']+?)['"]''')[0]
                    if name != '': post_data[name] = value
                post_data.update({
                    'username': self.login,
                    'password': self.password,
                    'action': 'login'
                })

                httpParams = dict(self.defaultParams)
                httpParams['header'] = MergeDicts(
                    httpParams['header'], {
                        'Referer': self.cm.meta['url'],
                        'Content-Type': 'application/x-www-form-urlencoded'
                    })

                sts, data = self.getPage(actionUrl, httpParams, post_data)

            if sts and '/logout' in data:
                printDBG('tryTologin OK')
                self.loggedIn = True
            else:
                msgTab = [_('Login failed.')]
                self.sessionEx.waitForFinishOpen(MessageBox,
                                                 '\n'.join(msgTab),
                                                 type=MessageBox.TYPE_ERROR,
                                                 timeout=10)
                printDBG('tryTologin failed')

            if self.loggedIn:
                hash = hexlify(
                    md5('%s@***@%s' % (self.login, self.password)).digest())
                WriteTextFile(loginCookie, hash)

        return self.loggedIn
コード例 #16
0
    def tryTologin(self):
        printDBG('tryTologin start')
        if None == self.loggedIn or self.login != config.plugins.iptvplayer.seriesblanco_login.value or self.password != config.plugins.iptvplayer.seriesblanco_password.value:
            self.cm.clearCookie(self.COOKIE_FILE, removeNames=['language'])
            loginCookie = GetCookieDir('seriesblanco.org.login')
            self.login = config.plugins.iptvplayer.seriesblanco_login.value
            self.password = config.plugins.iptvplayer.seriesblanco_password.value
            sts, data = self.getPage(self.getMainUrl())
            if sts:
                self.setMainUrl(self.cm.meta['url'])
            freshSession = False
            if sts and '/login' not in data:
                printDBG('Check hash')
                hash = hexlify(
                    md5('%s@***@%s' % (self.login, self.password)).digest())
                prevHash = ReadTextFile(loginCookie)[1].strip()
                printDBG('$hash[%s] $prevHash[%s]' % (hash, prevHash))
                if hash == prevHash:
                    self.loggedIn = True
                    return True
                freshSession = True
            loginUrl = self.getFullUrl('/login/')
            rm(loginCookie)
            rm(self.COOKIE_FILE)
            if freshSession:
                sts, data = self.getPage(
                    loginUrl,
                    MergeDicts(self.defaultParams, {'use_new_session': True}))
            else:
                sts, data = self.getPage(loginUrl, self.defaultParams)
            self.loggedIn = False
            if '' == self.login.strip() or '' == self.password.strip():
                return False
            errorTab = [_('Problem with user "%s" login.') % self.login]
            loginUrl = self.getFullUrl(
                '/wp-content/themes/ficseriesb/include/login_register/sistemaLogin.php'
            )
            sts, data = self.getPage(loginUrl,
                                     self.getDefaultParams(forAjax=True), {
                                         'usernameya': self.login,
                                         'pwd1': self.password
                                     })
            if sts:
                try:
                    printDBG(data)
                    data = json_loads(data)
                    errorTab.append(ph.clean_html(str(data.get('mensaje',
                                                               ''))))
                    if data.get('err', False):
                        sts, data = self.getPage(self.getFullUrl('/profil'))
                        if sts and '/login' not in data:
                            self.loggedIn = True
                except Exception:
                    printExc()

            if not self.loggedIn:
                self.sessionEx.open(MessageBox,
                                    '\n'.join(errorTab),
                                    type=MessageBox.TYPE_INFO,
                                    timeout=10)
            if self.loggedIn:
                hash = hexlify(
                    md5('%s@***@%s' % (self.login, self.password)).digest())
                WriteTextFile(loginCookie, hash)
        return self.loggedIn