def start(self, url, filePath, params = {}, info_from=None, retries=0):
        '''
            Owervrite start from BaseDownloader
        '''
        self.url              = url
        self.filePath         = filePath
        self.downloaderParams = params
        self.fileExtension    = '' # should be implemented in future
        
        self.outData = ''
        self.contentType = 'unknown'
        if None == info_from:
            info_from = WgetDownloader.INFO.FROM_FILE
        self.infoFrom    = info_from
        
        if self.infoFrom == WgetDownloader.INFO.FROM_DOTS:
            info = "--progress=dot:default"
        else: info = ""
        
        # remove file if exists
        if fileExists(self.filePath):
            rm(self.filePath)
        
        self.downloadCmd = DMHelper.getBaseWgetCmd(self.downloaderParams) + (' %s -t %d ' % (info, retries)) + '"' + self.url + '" -O "' + self.filePath + '" > /dev/null'
        printDBG("Download cmd[%s]" % self.downloadCmd)
        
        if self.downloaderParams.get('iptv_wget_continue', False):
            self.maxContinueRetry = 3
        
        self.console = eConsoleAppContainer()
        self.console_appClosed_conn  = eConnectCallback(self.console.appClosed, self._cmdFinished)
        self.console_stderrAvail_conn = eConnectCallback(self.console.stderrAvail, self._dataAvail)
        self.console.execute( E2PrioFix( self.downloadCmd ) )

        self.wgetStatus = self.WGET_STS.CONNECTING
        self.status     = DMHelper.STS.DOWNLOADING
        
        self.onStart()
        return BaseDownloader.CODE_OK
Exemplo n.º 2
0
    def tryTologin(self):
        printDBG('tryTologin start')
        self.defUrl = self.getFullUrl('/watch/russiatoday')
        if None == self.loggedIn or self.login != config.plugins.iptvplayer.tvplayercom_login.value or\
            self.password != config.plugins.iptvplayer.tvplayercom_password.value:

            self.login = config.plugins.iptvplayer.tvplayercom_login.value
            self.password = config.plugins.iptvplayer.tvplayercom_password.value

            rm(self.COOKIE_FILE)

            self.loggedIn = False

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

            url = self.getFullUrl('/account/login')

            sts, data = self.getPage(url)
            if not sts:
                return False

            sts, data = self.cm.ph.getDataBeetwenNodes(data,
                                                       ('<form', '>', 'login'),
                                                       ('</form', '>'))
            if not sts:
                return False
            actionUrl = self.getFullUrl(
                self.cm.ph.getSearchGroups(data,
                                           '''action=['"]([^'^"]+?)['"]''')[0])
            data = self.cm.ph.getAllItemsBeetwenMarkers(data, '<input', '>')
            post_data = {}
            for item in data:
                name = self.cm.ph.getSearchGroups(
                    item, '''name=['"]([^'^"]+?)['"]''')[0]
                value = self.cm.ph.getSearchGroups(
                    item, '''value=['"]([^'^"]+?)['"]''')[0]
                post_data[name] = value

            post_data.update({
                'email': self.login,
                'password': self.password,
                'remember_me': 1
            })

            httpParams = dict(self.defaultParams)
            httpParams['header'] = dict(httpParams['header'])
            httpParams['header'][
                'Content-Type'] = 'application/x-www-form-urlencoded'
            httpParams['header']['Referer'] = url
            sts, data = self.cm.getPage(actionUrl, httpParams, post_data)
            if sts and '/account/channels' in data:
                printDBG('tryTologin OK')
                self.loggedIn = True
            else:
                self.sessionEx.open(MessageBox,
                                    _('Login failed.'),
                                    type=MessageBox.TYPE_ERROR,
                                    timeout=10)
                printDBG('tryTologin failed')
        return self.loggedIn
Exemplo n.º 3
0
 def getSweetCaptchaRespond(self, data):
     printDBG("FiliserTv.getSweetCaptchaRespond")
     
     def _getFullUrl(url):
         urlPrefix = 'http:'
         if url.startswith('//'): url = urlPrefix + url
         return url
     
     def n(e, n):
         a = ""
         n = urllib.unquote(n)
         for r in range(len(n)-1, -1, -1):
             t = n[r]
             if (t >= "a" and "z" >= t) or (t >= "A" and "Z" >= t):
                 a += chr(65 + e.find(t) % 26)
             else:
                 a += t
         return a.lower()
     
     retData = {}
     
     printDBG(data)
     url = _getFullUrl(self.cm.ph.getSearchGroups(data, '''['"]([^'^"]*?/captcha/[^'^"]*?)['"]''')[0])
     url += 'mobile=1&_=' + str(int(time() * 1000))
     
     sts, data = self.getPage(url)
     if not sts: return retData
     
     printDBG(data)
     thumbFileTab = []
     try:
         data = json_loads(data)
         imgUrlTab = []
         for item in data["a"]:
             imgUrlTab.append(_getFullUrl(n(data['simple_key'], item['src'])))
         imgUrlTab.append(_getFullUrl(n(data['simple_key'], data['q'])))
         printDBG(imgUrlTab)
         
         errorOccurred = False
         params = {'maintype': 'image', 'subtypes':['png'], 'check_first_bytes':['\x89\x50\x4E\x47']}
         for idx in range(len(imgUrlTab)):
             imgUrl   = imgUrlTab[idx]
             filePath = GetTmpDir('.iptvplayer_captcha_%s.png' % idx)
             ret = self.cm.saveWebFile(filePath, imgUrl, params)
             if not ret.get('sts'):
                 SetIPTVPlayerLastHostError(_('Fail to get "%s".') % imgUrl)
                 errorOccurred = True
                 break
             thumbFileTab.append(filePath)
         if not errorOccurred:
             verify = data['drag']['verify']
             challenge = data['drag']['challenge']
             printDBG(thumbFileTab)
             printDBG("OK")
             printDBG(verify)
             printDBG(challenge)
             
             retArg = self.sessionEx.waitForFinishOpen(UnCaptchaSweetCaptchaWidget, params={'icon_list':thumbFileTab, 'title':verify, 'challenge':challenge})
             printDBG('>>>>>>>> Captcha response %r' % (retArg))
             if retArg is not None and len(retArg) and retArg[0]:
                 answer = retArg[0]['resp_idx']
                 printDBG('>>>>>>>> Captcha answer[%s]' % (answer))
                 retData = {'sckey':data['k'], 'scvalue':data['a'][answer]['hash'][5:15], 'scvalue2':0}
             else:
                 retData = None
     except Exception:
         printExc()
     
     for file in thumbFileTab:
         rm(file)
     
     return retData
 def _cleanUp(self):
     for item in self.multi['files']:
         rm(item)
Exemplo n.º 5
0
 def __cleanFiles(all=False):
     if all: rm(fileName)
     rm(tmpFile)
     rm(tmpFileZip)
Exemplo n.º 6
0
    def handleService(self, index, refresh=0, searchPattern='', searchType=''):
        printDBG('handleService start')

        CBaseHostClass.handleService(self, index, refresh, searchPattern,
                                     searchType)

        name = self.currItem.get("name", '')
        category = self.currItem.get("category", '')
        mode = self.currItem.get("mode", '')

        printDBG("handleService: |||| name[%s], category[%s] " %
                 (name, category))
        self.cacheLinks = {}
        self.currList = []

        #MAIN MENU
        if name == None and category == '':
            rm(self.COOKIE_FILE)
            self.listMainMenu({'name': 'category'})
        elif category == 'topvideos':
            self.listTopMenu(self.currItem, 'sub_items')
        elif category == 'sub_items':
            self.listSubItems(self.currItem, 'top_items')
        elif category == 'top_items':
            self.listTopItems(self.currItem, 'list_items')

        elif category == 'cats':
            self.listCats(self.currItem, 'cat_items', 'sort')
        elif category == 'cat_items':
            self.listCatItems(self.currItem, 'sort')

        elif category == 'sort':
            self.listSort(self.currItem, 'list_items')
        elif category == 'list_items':
            self.listItems(self.currItem, 'sort')
        elif category == 'years':
            self.listYears(self.currItem, 'sort')

        elif category == 'series':
            self.listSeries(self.currItem)
        elif category == 'a_z':
            self.listAZ(self.currItem, 'list_by_letter')
        elif category == 'list_by_letter':
            self.listByLetter(self.currItem, 'sort')

    #SECTIONS
        elif category == 'sections':
            self.listSections(self.currItem, 'list_sub_items', 'explore_item')
            if 1 == len(self.currList): self.listSubItems(self.currList[0])
        elif category == 'list_sub_items':
            self.listSubItems(self.currItem)
    #MOVIES
        elif category == 'movies':
            self.listMovies(self.currItem, 'list_filters')
        elif category == 'list_filters':
            self.listFilters(self.currItem, 'list_items')
        elif category == 'list_items':
            self.listItems(self.currItem, 'explore_item')
    #SERIES

    #RAITING
        elif category == 'raiting':
            self.listRaitingItems(self.currItem, 'explore_item')

        elif category == 'explore_item':
            self.exploreItem(self.currItem, 'list_sub_items')
    #SEARCH
        elif category in ["search", "search_next_page"]:
            cItem = dict(self.currItem)
            cItem.update({'search_item': False, 'name': 'category'})
            self.listSearchResult(cItem, searchPattern, searchType)

    #HISTORIA SEARCH
        elif category == "search_history":
            self.listsHistory({
                'name': 'history',
                'category': 'search'
            }, 'desc', _("Type: "))
        else:
            printExc()

        CBaseHostClass.endHandleService(self, index, refresh)
Exemplo n.º 7
0
 def initSubProvider(self):
     printDBG("PrijevodiOnline.initSubProvider")
     self.logedIn = False
     rm(self.COOKIE_FILE)
Exemplo n.º 8
0
    def getLinksForVideo(self, cItem):
        printDBG("Laola1TV.getLinksForVideo [%s]" % cItem)
        urlTab = []

        sts, data = self.cm.getPage(cItem['url'])
        if not sts: return []
        baseUrl = self.cm.meta['url']

        data = self.cm.ph.getDataBeetwenMarkers(data,
                                                '<div class="videoplayer"',
                                                '</script>')[1]
        printDBG(data)
        getParams = {}
        getParams['videoid'] = self.cm.ph.getSearchGroups(
            data, '\svideoid\s*:\s*"([0-9]*?)"')[0]
        getParams['partnerid'] = self.cm.ph.getSearchGroups(
            data, '\spartnerid\s*:\s*"([0-9]*?)"')[0]
        getParams['language'] = self.cm.ph.getSearchGroups(
            data, '\slanguage\s*:\s*"([a-z]*?)"')[0]
        getParams['portal'] = self.cm.ph.getSearchGroups(
            data, '\portalid\s*:\s*"([a-z]*?)"')[0]
        getParams['format'] = 'iphone'
        vidUrl = self.cm.ph.getSearchGroups(data,
                                            '\configUrl\s*:\s*"([^"]*?)"')[0]
        if vidUrl.startswith('//'):
            vidUrl = 'http:' + vidUrl
        vidUrl += '?' + urllib.urlencode(getParams)
        vidUrl = self._getFullUrl(vidUrl, baseUrl)

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

        try:
            data = byteify(json.loads(data))
            url = data['video']['streamAccess']
            req_abo = []
            for item in data['video']['abo']['required']:
                req_abo.append(str(item))
        except Exception:
            return []
            printExc()

        ######################################################
        streamaccessTab = []
        post_data = {}
        for idx in range(len(req_abo)):
            post_data[idx] = req_abo[idx]
        sts, data = self.getPage(url, {}, post_data)
        try:
            data = byteify(json.loads(data))
            for item in data['data']['stream-access']:
                streamaccessTab.append(item)
        except Exception:
            printExc()

        comment = ''
        for streamaccess in streamaccessTab:
            for myip in [
                    '', config.plugins.iptvplayer.laola1tv_myip1.value,
                    config.plugins.iptvplayer.laola1tv_myip2.value
            ]:
                if '' != myip: header = {'X-Forwarded-For': myip}
                else: header = {}
                sts, data = self.getPage(streamaccess, {'header': header})
                if not sts: return urlTab
                data = self.cm.ph.getDataBeetwenMarkers(
                    data, '<data>', '</data>', False)[1]
                printDBG(data)
                comment = self.cm.ph.getSearchGroups(data,
                                                     'comment="([^"]+?)"')[0]
                auth = self.cm.ph.getSearchGroups(data, 'auth="([^"]+?)"')[0]
                if auth in ['restricted', 'blocked']: continue
                url = self.cm.ph.getSearchGroups(data, 'url="([^"]+?)"')[0]
                url = url + '?hdnea=' + auth

                if myip != '':
                    url = strwithmeta(url, {'X-Forwarded-For': myip})

                COOKIE_FILE = GetCookieDir('m3u8_laola1.tv')
                rm(COOKIE_FILE)
                cookieParams = {
                    'use_cookie': True,
                    'load_cookie': True,
                    'save_cookie': True,
                    'cookiefile': COOKIE_FILE
                }
                tmp = getDirectM3U8Playlist(url,
                                            checkExt=False,
                                            cookieParams=cookieParams,
                                            checkContent=True)
                if len(tmp):
                    urlMeta = {
                        'iptv_proto': 'm3u8',
                        'Origin': self.up.getDomain(baseUrl, False),
                        'Cookie': self.cm.getCookieHeader(COOKIE_FILE),
                        'User-Agent': self.cm.HOST,
                        'Referer': baseUrl
                    }
                for idx in range(len(tmp)):
                    tmp[idx]['need_resolve'] = 0
                    tmp[idx]['url'] = strwithmeta(tmp[idx]['url'], urlMeta)
                    urlTab.append(tmp[idx])
                break
            if 0 < len(urlTab):
                break

        if 0 < len(urlTab):
            max_bitrate = int(
                config.plugins.iptvplayer.laola1tv_defquality.value)

            def __getLinkQuality(itemLink):
                try:
                    value = itemLink['bitrate']
                    return int(value)
                except Exception:
                    printExc()
                    return 0

            urlTab = CSelOneLink(urlTab, __getLinkQuality,
                                 max_bitrate).getSortedLinks()
            if config.plugins.iptvplayer.laola1tv_onelink.value:
                urlTab = [urlTab[0]]
        else:
            SetIPTVPlayerLastHostError(comment)

        return urlTab
Exemplo n.º 9
0
    def downloadSubtitleFile(self, cItem):
        printDBG("NapiProjektProvider.downloadSubtitleFile")
        retData = {}
        title = cItem['title']
        lang = cItem.get('lang', 'pl')
        subId = cItem['sub_id']
        imdbid = cItem['imdbid']
        fps = cItem.get('fps', 0)

        post_data = {
            "mode": "32770",
            "client": "pynapi",
            "client_ver": "0.1",
            "VideoFileInfoID": subId
        }

        url = self.getFullUrl('api/api-napiprojekt3.php')
        sts, data = self.cm.getPage(url, self.defaultParams, post_data)
        if not sts:
            return retData

        fps = self.cm.ph.getDataBeetwenMarkers(data, '<fps>', '</fps>',
                                               False)[1]
        try:
            fps = float(fps.strip())
        except Exception:
            fps = 0

        post_data = {
            "downloaded_subtitles_id": subId,
            "mode": "1",
            "client": "pynapi",
            "client_ver": "0.1",
            "downloaded_subtitles_lang": lang.upper(),
            "downloaded_subtitles_txt": "1"
        }

        url = self.getFullUrl('api/api-napiprojekt3.php')
        sts, data = self.cm.getPage(url, self.defaultParams, post_data)
        if not sts:
            return retData

        data = self.cm.ph.getDataBeetwenMarkers(data, '<content><![CDATA[',
                                                ']]></content>', False)[1]
        try:
            data = base64.b64decode(data)
            if IsSubtitlesParserExtensionCanBeUsed():
                from Plugins.Extensions.IPTVPlayer.libs.iptvsubparser import _subparser as subparser
                subsObj = subparser.parse(data, 0, False, False)
                typeExtMap = {
                    'microdvd': 'sub',
                    'subrip': 'srt',
                    'subviewer': 'sub',
                    'ssa1': 'ssa',
                    'ssa2-4': 'ssa',
                    'ass': 'ssa',
                    'vplayer': 'txt',
                    'sami': 'smi',
                    'mpl2': 'mpl',
                    'aqt': 'aqt',
                    'pjs': 'pjs',
                    'mpsub': 'sub',
                    'jacosub': 'jss',
                    'psb': 'psb',
                    'realtext': 'rt',
                    'dks': 'dks',
                    'subviewer1': 'sub',
                    'text/vtt': 'vtt',
                    'sbv': 'sbv'
                }
                ext = typeExtMap.get(subsObj['type'], '')
                if ext == '':
                    SetIPTVPlayerLastHostError(
                        _('Unknown subtitle parser for format "%s".') %
                        subsObj['type'])
                    return retData
                tmpFile = GetTmpDir(self.TMP_FILE_NAME)
                if not self.writeFile(tmpFile, data):
                    return retData
                fileName = self._getFileName(title, lang, subId, imdbid, fps,
                                             ext)
                fileName = GetSubtitlesDir(fileName)
                if not self.converFileToUtf8(tmpFile, fileName):
                    rm(tmpFile)
                    return retData
                retData = {
                    'title': title,
                    'path': fileName,
                    'lang': lang,
                    'imdbid': imdbid,
                    'sub_id': subId
                }
        except Exception:
            printExc()
            return retData

        return retData
Exemplo n.º 10
0
    def tryTologin(self):
        printDBG('tryTologin start')

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

            self.login = config.plugins.iptvplayer.firstonetv_login.value
            self.password = config.plugins.iptvplayer.firstonetv_password.value

            sts, data = self.cm.getPage(self.getFullUrl('/Account/Settings'),
                                        self.http_params)
            if sts:
                self.setMainUrl(self.cm.meta['url'])
                data = ph.find(data, ('<imput', '>', 'email'))[1]
                email = ph.getattr(data, 'value')

                if email and (not self.login.strip()
                              or not self.password.strip()):
                    self.loggedIn = False
                    rm(self.COOKIE_FILE)

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

                if email.lower() == self.login.lower():
                    self.loggedIn = True
                    return true

            rm(self.COOKIE_FILE)
            params = MergeDicts(self.http_params, {'use_new_session': True})
            sts, data = self.cm.getPage(self.getFullUrl('/Register-Login'),
                                        params)
            if sts: self.setMainUrl(self.cm.meta['url'])

            if sts:
                params = dict(self.http_params)
                params['header'] = MergeDicts(self.HTTP_HEADER,
                                              {'Referer': self.cm.meta['url']})

                post_data = {
                    'usrmail': self.login,
                    'password': self.password,
                    'login': ''
                }
                sts, data = self.cm.getPage(self.getFullUrl('/Register-Login'),
                                            params, post_data)

            if sts and '/Logout' in data:
                printDBG('tryTologin OK')
                self.loggedIn = True
            else:
                msgTab = [_('Login failed.')]
                if sts:
                    msgTab.append(
                        self.cleanHtmlStr(
                            self.cm.ph.getDataBeetwenNodes(
                                data, ('<div', '>', 'data-abide-error'),
                                ('</div', '>'), False)[1]))
                self.sessionEx.waitForFinishOpen(MessageBox,
                                                 '\n'.join(msgTab),
                                                 type=MessageBox.TYPE_ERROR,
                                                 timeout=10)
                printDBG('tryTologin failed')
        return self.loggedIn
Exemplo n.º 11
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
Exemplo n.º 12
0
    def tryTologin(self):
        printDBG('EuroSportPlayer.tryTologin start')
        errorMsg = _('Error communicating with the server.')

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

            self.login = config.plugins.iptvplayer.eurosportplayer_login.value
            self.password = config.plugins.iptvplayer.eurosportplayer_password.value

            rm(self.COOKIE_FILE)

            self.loggedIn = False
            self.loginMessage = ''

            if '' == self.login.strip() or '' == self.password.strip():
                msg = _(
                    'The host %s requires subscription.\nPlease fill your login and password in the host configuration - available under blue button.'
                ) % self.getMainUrl()
                GetIPTVNotify().push(msg, 'info', 10)
                return False

            try:
                # get token
                tokenUrl = self.TOKEN_URL

                sts, data = self.getPage(tokenUrl)
                printDBG(data)

                # get config (also with catpcha site-key)
                sts, data = self.getPage(self.CONFIG_URL)
                printDBG(data)

                # solve captcha to login
                (token, errorMsgTab) = CaptchaHelper().processCaptcha(
                    self.recaptcha_sitekey, self.LOGIN_URL)

                if not token:
                    printDBG(str(errorMsgTab))
                    return

                printDBG('Captcha token :%s' % token)

                # try to login
                header = {
                    'User-Agent': self.USER_AGENT,
                    'Referer': self.LOGIN_URL,
                    'x-disco-client': 'WEB:x86_64:WEB_AUTH:1.1.0',
                    'x-disco-recaptcha-token': token,
                    'content-type': 'application/json'
                }

                postData = {
                    'credentials': {
                        'username': self.login,
                        'password': self.password
                    }
                }
                url = "https://eu3-prod-direct.eurosportplayer.com/login"

                httpParams = {
                    'header': header,
                    'with_metadata': True,
                    'use_cookie': True,
                    'load_cookie': True,
                    'save_cookie': True,
                    'cookiefile': self.COOKIE_FILE,
                    'raw_post_data': True
                }

                sts, data = self.getPage(url,
                                         httpParams,
                                         post_data=json_dumps(postData))
                ''' good login
                {
                  "data" : {
                    "attributes" : {
                      "lastLoginTime" : "2019-11-01T21:45:15Z",
                      "realm" : "eurosport",
                      "token" : "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJzdWIiOiJVU0VSSUQ6ZXVyb3Nwb3J0OmI4OGQ0YTBhLWQwZDctNDdkZi1iMzI5LWJjNmM5ZDNiOTRjYyIsImp0aSI6InRva2VuLThkOWYxMDgwLWUwNGEtNDMyZi04NDY1LWUwYTgyNDljMjEwMyIsImFub255bW91cyI6ZmFsc2UsImlhdCI6MTU3MjY4NDk3MX0.DtSAY9kAVfwcJKhPXczRlPW3CACd6ZmZwZvJilIrlv8"
                    },
                    "id" : "token-8d9f1080-e04a-432f-8465-e0a8249c2103",
                    "type" : "token"
                  },
                  "meta" : {
                    "site" : {
                      "attributes" : {
                        "brand" : "eurosport",
                        "websiteHostName" : "it.eurosportplayer.com"
                      },
                      "id" : "IT",
                      "type" : "site"
                    }
                  }
                }                
                '''
                ''' example: wrong password
                {
                  "errors" : [ {
                    "status" : "401",
                    "code" : "unauthorized",
                    "id" : "ATwRg09NZG",
                    "detail" : ""
                  } ]
                }
                '''

                if not sts and '401' in str(data):
                    msg = _('Login failed. Invalid email or password.')
                    GetIPTVNotify().push(msg, 'error', 10)
                    return False
                else:
                    data = json_loads(data)
                    printDBG(str(data))
                    self.loggedIn = True

            except Exception:
                printExc()

            printDBG('EuroSportPlayer.tryTologin end loggedIn[%s]' %
                     self.loggedIn)
            return self.loggedIn
Exemplo n.º 13
0
    def getLinksForVideo(self, cItem):
        urlsTab = []

        rm(self.COOKIE_FILE)
        sts, data = self.getPage(cItem['url'])
        if not sts:
            return []

        tmp = ph.find(data, ('<glomex-player', '>'))[1]
        if tmp:
            player_id = ph.getattr(tmp, 'data-player-id')
            playlist_id = ph.getattr(tmp, 'data-playlist-id')
            url = 'https://integration-cloudfront-eu-west-1.mes.glomex.cloud/?integration_id=%s&playlist_id=%s&current_url=' % (
                player_id, playlist_id)
            sts, data = self.getPage(url)
            if not sts:
                return []
            try:
                data = json_loads(data)['videos'][0]['source']
                if data.get('hls'):
                    hlsUrl = self.cm.getFullUrl(data['hls'],
                                                self.cm.meta['url'])
                    urlsTab = getDirectM3U8Playlist(
                        hlsUrl,
                        checkContent=True,
                        sortWithMaxBitrate=999999999,
                        mergeAltAudio=True)
                    if len(urlsTab):
                        urlsTab.append({
                            'name': 'Variable M3U8/HLS',
                            'url': hlsUrl,
                            'need_resolve': 0
                        })

                # progressive links seem do not work why?
                if False and data.get('progressive'):
                    mp4Url = self.cm.getFullUrl(data['progressive'],
                                                self.cm.meta['url'])
                    urlsTab.append({
                        'name': 'progressive mp4',
                        'url': mp4Url,
                        'need_resolve': 0
                    })
            except Exception:
                printExc()
        else:
            urlParams = dict(self.defaultParams)
            urlParams['header'] = MergeDicts(urlParams['header'],
                                             {'Referer': self.cm.meta['url']})
            urlParams['raw_post_data'] = True
            urlParams['use_new_session'] = True

            playerData = ph.find(data, 'getPlayer(', ');',
                                 flags=0)[1].split(',')
            printDBG("playerData <<< %s" % playerData)
            if len(playerData) == 6:
                url = self.cm.getFullUrl(
                    '/videoplayer/playerhls.php?play=%s&key=%d&identifier=web&v5partner=%s&autoplay=true&event'
                    % (playerData[1].strip(), int(
                        time.time() * 1000), playerData[3].strip()),
                    self.cm.meta['url'])
                sts, data = self.getPage(url, urlParams)
                urlParams['header'] = MergeDicts(
                    urlParams['header'], {'Referer': self.cm.meta['url']})

                url = self.cm.getFullUrl(
                    '/server/videoConfig.php?videoid=%s&partnerid=%s&language=%s&format=iphone'
                    % (playerData[1].strip(), playerData[3].strip(),
                       playerData[5].strip()[1:-1]), self.cm.meta['url'])
                sts, data = self.getPage(url, urlParams)
                try:
                    url = json_loads(data)['video']['streamAccess']
                    url = self.cm.getFullUrl(url, self.cm.meta['url'])
                    sts, data = self.getPage(url, urlParams, '[""]')
                    try:
                        printDBG("++++")
                        printDBG(data)
                        printDBG("++++")
                        data = json_loads(data)['data']['stream-access']
                        for url in data:
                            sts, streamData = self.getPage(
                                self.cm.getFullUrl(url, self.cm.meta['url']),
                                urlParams)
                            if not sts:
                                continue
                            printDBG("?----?")
                            printDBG(data)
                            printDBG("?----?")
                            token = ph.getattr(streamData, 'auth')
                            hlsUrl = self.cm.getFullUrl(
                                ph.getattr(streamData, 'url'),
                                self.cm.meta['url']) + '?hdnea=' + token
                            urlsTab = getDirectM3U8Playlist(
                                hlsUrl,
                                checkContent=True,
                                sortWithMaxBitrate=999999999,
                                mergeAltAudio=True)
                            break
                    except Exception:
                        printExc()
                except Exception:
                    printExc()
        return urlsTab
Exemplo n.º 14
0
    def tryTologin(self):
        printDBG('tryTologin start')

        config.plugins.iptvplayer.zalukajtv_login
        config.plugins.iptvplayer.zalukajtv_password

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

            self.login = config.plugins.iptvplayer.zalukajtv_login.value
            self.password = config.plugins.iptvplayer.zalukajtv_password.value

            rm(self.COOKIE_FILE)

            self.loggedIn = False
            self.msg = ''

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

            rm(self.COOKIE_FILE)
            sts, msg = False, 'Problem z zalogowaniem użytkownika \n"%s".' % self.login
            post_data = {'login': self.login, 'password': self.password}
            sts, data = self._getPage(ZalukajCOM.LOGIN_URL,
                                      params=post_data,
                                      loggedIn=True)
            if sts:
                printDBG('Host getInitList: chyba zalogowano do premium...')
                sts, data = self._getPage(
                    url=self.getFullUrl('/libs/ajax/login.php?login=1'),
                    loggedIn=True)

                if sts:
                    sts, data2 = self._getPage(
                        self.getFullUrl('/libs/ajax/login.php?login=1'),
                        loggedIn=True)

                if sts:
                    printDBG(data)
                    sts, tmp = self.cm.ph.getDataBeetwenMarkers(
                        data, '<p>Typ Konta:', '</p>', False)
                    if sts:
                        tmp = tmp.replace('(kliknij by oglądać bez limitów)',
                                          '')
                        msg = 'Zostałeś poprawnie zalogowany.' + '\nTyp Konta: ' + self.cleanHtmlStr(
                            tmp)
                        tmp = self.cm.ph.getDataBeetwenMarkers(
                            data, '<p>Zebrane Punkty:', '</p>',
                            False)[1].replace('&raquo; Wymień na VIP &laquo;',
                                              '')
                        if '' != tmp:
                            msg += '\nZebrane Punkty: ' + self.cleanHtmlStr(
                                tmp)
                        self.loggedIn = True

            if not self.loggedIn:
                self.sessionEx.open(MessageBox,
                                    msg,
                                    type=MessageBox.TYPE_INFO,
                                    timeout=10)
            else:
                self.msg = msg.replace('\n', '[/br]')

        return self.loggedIn
Exemplo n.º 15
0
    def getList(self, cItem):
        printDBG("KarwanTvApi.getChannelsList")
        channelsTab = []

        try:
            initList = cItem.get('init_list', True)
            if initList:
                rm(self.COOKIE_FILE)
                for item in [
                    {
                        'title': 'TV',
                        'priv_cat': 'tv'
                    }, {
                        'url': self.getFullUrl('radio.html'),
                        'title': 'Radio',
                        'priv_cat': 'radio'
                    }
                ]:  #{'url':self.getMainUrl24(), 'title':'Karwan24.com', 'priv_cat':'karwan24_tv'}
                    params = dict(cItem)
                    params.update(item)
                    params['init_list'] = False
                    channelsTab.append(params)
            else:
                category = cItem.get('priv_cat', '')
                sts, data = self.cm.getPage(cItem['url'])
                if not sts:
                    return []

                if category in ['radio', 'tv']:
                    data = self.cm.ph.getAllItemsBeetwenMarkers(
                        data, '<div class="bt-inner">', '</div>')
                    for item in data:
                        icon = self.getFullUrl(
                            self.cm.ph.getSearchGroups(
                                item, '''src=['"]([^"^']+?)['"]''')[0])
                        url = self.getFullUrl(
                            self.cm.ph.getSearchGroups(
                                item, '''href=['"]([^'^"]+?)['"]''')[0])
                        title = self.cleanHtmlStr(item)
                        params = {
                            'name': 'karwan.tv',
                            'title': title,
                            'url': url,
                            'icon': icon
                        }
                        if category == 'radio':
                            params['type'] = 'audio'
                        else:
                            params['type'] = 'video'
                        channelsTab.append(params)
                elif category == 'karwan24_tv':
                    m1 = '<div class=column'
                    if m1 not in data:
                        m1 = '<div class="column"'
                    data = self.cm.ph.getAllItemsBeetwenMarkers(
                        data, m1, '</a>')
                    for item in data:
                        icon = self.getFullUrl24(
                            self.cm.ph.getSearchGroups(
                                item, '''src=['"]([^"^']+?)['"]''')[0])
                        url = self.getFullUrl24(
                            self.cm.ph.getSearchGroups(
                                item, '''href=['"]([^'^"]+?)['"]''')[0])
                        title = self.cleanHtmlStr(
                            self.cm.ph.getSearchGroups(
                                item, '''title=['"]([^'^"]+?)['"]''')[0])
                        desc = self.cleanHtmlStr(item)
                        params = {
                            'name': 'karwan.tv',
                            'title': title,
                            'url': url,
                            'desc': desc,
                            'icon': icon
                        }
                        if category == 'radio':
                            params['type'] = 'audio'
                        else:
                            params['type'] = 'video'
                        channelsTab.append(params)
        except Exception:
            printExc()
        return channelsTab
Exemplo n.º 16
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
Exemplo n.º 17
0
    def handleService(self, index, refresh=0, searchPattern='', searchType=''):
        printDBG('handleService start')

        if self.MAIN_URL == None:
            self.selectDomain()

        if (self.login != config.plugins.iptvplayer.mrpiracy_login.value or
             self.password != config.plugins.iptvplayer.mrpiracy_password.value) and \
            '' != config.plugins.iptvplayer.mrpiracy_login.value.strip() and \
            '' != config.plugins.iptvplayer.mrpiracy_password.value.strip():

            self.loggedIn, msg = self.tryTologin()
            if not self.loggedIn:
                userName = config.plugins.iptvplayer.mrpiracy_login.value
                self.sessionEx.open(MessageBox,
                                    'Login failed for user "%s".' % userName,
                                    type=MessageBox.TYPE_INFO,
                                    timeout=10)
            else:
                self.loogin = config.plugins.iptvplayer.mrpiracy_login.value
                self.password = config.plugins.iptvplayer.mrpiracy_password.value
        elif ('' == config.plugins.iptvplayer.mrpiracy_login.value.strip() or
              '' == config.plugins.iptvplayer.mrpiracy_password.value.strip()):
            self.sessionEx.open(
                MessageBox,
                'Access to this service requires login.\nPlease register on the site \"%s\". Then log in and then put your login data in the host configuration under blue button.'
                % self.getMainUrl(),
                type=MessageBox.TYPE_INFO,
                timeout=20)

        CBaseHostClass.handleService(self, index, refresh, searchPattern,
                                     searchType)

        name = self.currItem.get("name", '')
        category = self.currItem.get("category", '')
        mode = self.currItem.get("mode", '')

        printDBG(
            "handleService: |||||||||||||||||||||||||||||||||||| name[%s], category[%s] "
            % (name, category))
        self.currList = []

        #MAIN MENU
        if name == None:
            if (config.plugins.iptvplayer.mrpiracy_login.value == '' or
                    config.plugins.iptvplayer.mrpiracy_password.value == ''):
                rm(self.COOKIE_FILE)
            self.cacheLinks = {}
            self.listsTab(self.MAIN_CAT_TAB, {'name': 'category'})
        elif category == 'list_filters':
            self.listFilters(self.currItem, 'list_items')
        elif category == 'list_items':
            self.listItems(self.currItem, 'list_seasons')
        elif category == 'list_seasons':
            self.listSeasons(self.currItem)
        elif category == 'list_episodes':
            self.listEpisodes(self.currItem)
    #SEARCH
        elif category in ["search", "search_next_page"]:
            cItem = dict(self.currItem)
            cItem.update({'search_item': False, 'name': 'category'})
            self.listSearchResult(cItem, searchPattern, searchType)

    #HISTORIA SEARCH
        elif category == "search_history":
            self.listsHistory({
                'name': 'history',
                'category': 'search'
            }, 'desc', _("Type: "))
        else:
            printExc()

        CBaseHostClass.endHandleService(self, index, refresh)
Exemplo n.º 18
0
    def tryTologin(self):
        printDBG('tryTologin start')
        
        self.USER_AGENT = 'Mozilla/5.0 (Windows NT 6.1; WOW64; rv:40.0) Gecko/20100101 Firefox/40.0'
        self.HTTP_HEADER = {'User-Agent': self.USER_AGENT, 'DNT':'1', 'Accept': 'application/json, text/javascript, */*; q=0.01', 'Accept-Encoding':'gzip, deflate', 'Referer':'https://zalukaj.com/', 'Origin':'https://zalukaj.com/'}
        self.defaultParams = {'header':self.HTTP_HEADER, 'with_metadata':True, 'use_cookie': True, 'load_cookie': True, 'save_cookie': True, 'cookiefile': self.COOKIE_FILE}
        httpParams = dict(self.defaultParams)
        httpParams['header'] = dict(httpParams['header'])
        httpParams['header']['Referer'] = 'https://zalukaj.com/'
        
        if None == self.loggedIn or self.login != config.plugins.iptvplayer.zalukajtv_login.value or\
            self.password != config.plugins.iptvplayer.zalukajtv_password.value:
        
            self.login = config.plugins.iptvplayer.zalukajtv_login.value
            self.password = config.plugins.iptvplayer.zalukajtv_password.value
            
            rm(self.COOKIE_FILE)
            
            self.loggedIn = False
            self.msg = ''
            
            if '' == self.login.strip() or '' == self.password.strip():
                return False
            
            rm(self.COOKIE_FILE)

            sts, msg = False, 'Problem z zalogowaniem użytkownika \n"%s".' % self.login
            post_data = None
            sts, data  = self._getPage('https://zalukaj.com/rejestracja', params=post_data, loggedIn=True)
            if self.cm.meta['url'] == 'https://zalukaj.com/limit': 
                httpParams['header']['Referer'] = 'https://zalukaj.com/limit'
                post_data = {'captcha': self.captcha()}
                sts, data = self.cm.getPage('https://zalukaj.com/limit', httpParams, post_data)
            if sts:
                #printDBG(data)
                hash = self.cm.ph.getSearchGroups(data, '''name="hash" value=['"]([^'^"]+?)['"]''')[0].strip()
                expires = self.cm.ph.getSearchGroups(data, '''"expires" value=['"]([^'^"]+?)['"]''')[0].strip()
                post_data = {'expires': expires, 'hash': hash, 'username': self.login,'password': self.password} 
                sts, data = self.cm.getPage('https://zalukaj.com/ajax/login', httpParams, post_data)
                printDBG(data)
                if '"error":[1' in data:
                    post_data['captcha'] = self.captcha()
                    sts, data = self.cm.getPage('https://zalukaj.com/ajax/login', httpParams, post_data)
                    printDBG(data)
                if '"succes' in data:
                    cookies = []
                    cj = self.cm.getCookie(self.COOKIE_FILE)
                    for cookie in cj:
                        if cookie.name == '__PHPSESSIDS':
                            cookies.append('%s=%s;' % (cookie.name, cookie.value))
                            printDBG(">> \t%s \t%s \t%s \t%s" % (cookie.domain, cookie.path, cookie.name, cookie.value) )

                sts, data = self._getPage(url=self.getFullUrl('/libs/ajax/login.php?login=1'), loggedIn=True)
                if sts:
                    printDBG(data)
                    sts,tmp = self.cm.ph.getDataBeetwenMarkers(data, '<p>Typ Konta:', '</p>', False)
                    if sts: 
                        tmp = tmp.replace('(kliknij by oglądać bez limitów)', '')
                        msg = 'Zostałeś poprawnie zalogowany.' + '\nTyp Konta: '+self.cleanHtmlStr(tmp)
                        tmp = self.cm.ph.getDataBeetwenMarkers(data, '<p>Zebrane Punkty:', '</p>', False)[1].replace('&raquo; Wymień na VIP &laquo;', '')
                        if '' != tmp: msg += '\nZebrane Punkty: '+self.cleanHtmlStr(tmp)
                        self.loggedIn = True
            
            if not self.loggedIn: self.sessionEx.open(MessageBox, msg, type = MessageBox.TYPE_INFO, timeout = 10 )
            else: self.msg = msg.replace('\n', '[/br]')
        
        return self.loggedIn
Exemplo n.º 19
0
    def getVideoLink(self, cItem):
        printDBG("VideoStarApi.getVideoLink")
        urlsTab = []

        idx = cItem.get('priv_idx', -1)
        if idx < 0 or idx >= len(self.cacheChannelList):
            return urlsTab

        vidItem = self.cacheChannelList[idx]
        formatId = config.plugins.iptvplayer.videostar_streamprotocol.value
        tries = 0
        while True:
            tries += 1
            try:
                if self.loggedIn:
                    url = 'v1/channel/%s?format_id=%s&device_type=android_tv' % (
                        vidItem['id'], formatId)
                else:
                    url = 'v1/guest/channel/%s?format_id=%s&device_type=android_tv' % (
                        vidItem['id'], formatId)
                url = self.getFullUrl(url, 'api')
                sts, data = self.cm.getPage(url, self.defaultParams)
                printDBG(data)
                if not sts and not self.loggedIn and tries == 1:
                    rm(self.COOKIE_FILE)
                    #                    self.doLogin('guest', 'guest')
                    sts, data = self.cm.getPage(
                        self.getFullUrl('/static/guest/channels/list/web.json',
                                        'static'), self.defaultParams)
                    if sts:
                        continue

                if not sts:
                    break
                data = json_loads(data)
                if data['data'] != None:
                    for item in data['data']['stream_channel']['streams']:
                        if formatId == '2':
                            if 'hls' in item['type']:
                                hslUrl = item['url'][0]  # add here random
                                urlsTab.extend(
                                    getDirectM3U8Playlist(
                                        hslUrl,
                                        checkExt=False,
                                        cookieParams=self.defaultParams,
                                        checkContent=True))
                        elif formatId in ['3', '4']:
                            if 'dash' in item['type']:
                                dashUrl = item['url'][0]  # add here random
                                urlsTab.extend(
                                    getMPDLinksWithMeta(
                                        dashUrl,
                                        checkExt=False,
                                        cookieParams=self.defaultParams))
                elif data['_meta'] != None:
                    info = data['_meta']['error']['info']
                    message = []
                    message.append(
                        'Oglądasz już kanał %s na urządeniu %s o adresie: %s.'
                        % (info['channel_name'], info['device'],
                           info['user_ip']))
                    message.append(
                        'W WP Pilocie nie możesz oglądać większej liczby kanałów jednocześnie.'
                    )
                    message.append('Czy chcesz kontynować tutaj?')
                    arg1 = self.sessionEx.waitForFinishOpen(
                        MessageBox,
                        '\n'.join(message),
                        type=MessageBox.TYPE_YESNO)
                    if arg1:
                        url = self.getFullUrl('v1/channels/close', 'api')
                        paramsUrl = dict(self.defaultParams)
                        paramsUrl['header'] = dict(paramsUrl['header'])
                        paramsUrl['header']['Referer'] = self.getFullUrl('tv')
                        paramsUrl['header']['Origin'] = self.MAIN_URL[:-1]
                        paramsUrl['header'][
                            'content-type'] = 'application/json;charset=UTF-8'
                        paramsUrl['raw_post_data'] = True
                        sts, data = self.cm.getPage(
                            url, paramsUrl, '{"channelId":"%s","t":"%s"}' %
                            (info['channel_id'], self.userToken))
                        printDBG("==================== token1[%s] token2[%s]" %
                                 (self.userToken, info['stream_token']))
                        printDBG(data)
                        printDBG("====================")
                        continue

            except Exception:
                printExc()
            break

        if len(urlsTab):
            cookieHeader = self.cm.getCookieHeader(self.COOKIE_FILE)
            for idx in range(len(urlsTab)):
                urlsTab[idx]['url'] = strwithmeta(urlsTab[idx]['url'], {
                    'Cookie': cookieHeader,
                    'User-Agent': self.USER_AGENT
                })

        if len(urlsTab):
            maxBitrate = int(
                config.plugins.iptvplayer.videostar_defquality.value) * 1.3

            def __getLinkQuality(itemLink):
                try:
                    if 'bitrate' in itemLink:
                        return int(itemLink['bitrate'])
                    elif 'bandwidth' in itemLink:
                        return int(itemLink['bandwidth'])
                except Exception:
                    printExc()
                return 0

            oneLink = CSelOneLink(urlsTab, __getLinkQuality, maxBitrate)
            urlsTab = oneLink.getSortedLinks()
            if config.plugins.iptvplayer.videostar_use_defquality.value:
                urlsTab = [urlsTab[0]]

        return urlsTab
Exemplo n.º 20
0
    def getVideoLinks(self, videoUrl):
        printDBG("EFilmyTv.getVideoLinks [%s]" % videoUrl)
        self.tryTologin()

        videoUrl = strwithmeta(videoUrl)
        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

        paramsUrl = dict(self.defaultParams)
        paramsUrl['header'] = dict(paramsUrl['header'])
        paramsUrl['header']['Referer'] = videoUrl.meta.get(
            'Referer', self.getMainUrl())
        sts, data = self.getPage(videoUrl, paramsUrl)
        if not sts: return urlTab
        cUrl = data.meta['url']

        ##############################################################################################
        while sts and 'generate_captcha' in data:
            captchaTitle = self.cm.ph.getAllItemsBeetwenMarkers(
                data, '<p', '</p>')

            if len(captchaTitle):
                captchaTitle = self.cleanHtmlStr(captchaTitle[-1])

            # parse form data
            data = self.cm.ph.getDataBeetwenMarkers(data, '<form',
                                                    '</form>')[1]
            imgUrl = self.getFullUrl(
                '/mirrory.php?cmd=generate_captcha&time=%s' % time.time(),
                cUrl)
            actionUrl = self.getFullUrl(
                self.cm.ph.getSearchGroups(data, 'action="([^"]+?)"')[0], cUrl)
            tmp = re.compile('''<input[^>]+?>''').findall(data)
            printDBG(tmp)
            captcha_post_data = {}
            for it in tmp:
                val = self.cm.ph.getSearchGroups(
                    it, '''\svalue=['"]?([^'^"^\s]+?)['"\s]''')[0].strip()
                name = self.cm.ph.getSearchGroups(
                    it, '''\sname=['"]([^'^"]+?)['"]''')[0]
                captcha_post_data[name] = val

            header = dict(self.HTTP_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 urlTab
            params = deepcopy(IPTVMultipleInputBox.DEF_PARAMS)
            params['accep_label'] = _('Send')
            params['title'] = _('Captcha')
            params['status_text'] = captchaTitle
            params['with_accept_button'] = True
            params['list'] = []
            item = deepcopy(IPTVMultipleInputBox.DEF_INPUT_PARAMS)
            item['label_size'] = (160, 75)
            item['input_size'] = (480, 25)
            item['icon_path'] = filePath
            item['title'] = _('Answer')
            item['input']['text'] = ''
            params['list'].append(item)

            ret = 0
            retArg = self.sessionEx.waitForFinishOpen(IPTVMultipleInputBox,
                                                      params)
            printDBG(retArg)
            if retArg and len(retArg) and retArg[0]:
                printDBG(retArg[0])
                captcha_post_data['captcha'] = retArg[0][0]
                paramsUrl['header']['Referer'] = cUrl
                sts, data = self.cm.getPage(actionUrl, paramsUrl,
                                            captcha_post_data)
                if sts: cUrl = data.meta['url']
                else: return urlTab
            else:
                return urlTab
        ##############################################################################################

        jscode = []
        tmp = self.cm.ph.getAllItemsBeetwenNodes(data, ('<script', '>'),
                                                 ('</script', '>'), False)
        for item in tmp:
            if 'eval(' in item:
                jscode.append(item)

        if len(jscode) > 0:
            jscode.insert(
                0,
                'var document={write:function(e){print(e)}};Base64={},Base64.decode=function(e){e.length%4==3&&(e+="="),e.length%4==2&&(e+="=="),e=Duktape.dec("base64",e),decText="";for(var t=0;t<e.byteLength;t++)decText+=String.fromCharCode(e[t]);return decText};'
            )
            ret = js_execute('\n'.join(jscode))
            if ret['sts'] and 0 == ret['code']:
                data = ret['data'].strip()
        if 'premium' in videoUrl.meta['f_type']:
            printDBG(data)
            errorMessage = self.cleanHtmlStr(
                self.cm.ph.getDataBeetwenNodes(data, ('<div', '>', 'toomany'),
                                               ('</div', '>'))[1].replace(
                                                   '<br>', '\n'))
            SetIPTVPlayerLastHostError(errorMessage)
            data = self.cm.ph.getDataBeetwenMarkers(data, 'clip:', '}')[1]
            videoUrl = self.cm.ph.getSearchGroups(
                data, '''\surl\s*?:\s*?['"](https?://[^'^"]+?)['"]''', 1,
                True)[0]
            if videoUrl != '':
                urlTab.append({
                    'name': 'direct_link',
                    'url': strwithmeta(videoUrl, {'Referer': cUrl})
                })
        else:
            videoUrl = self.getFullUrl(
                self.cm.ph.getSearchGroups(data, '''href=['"]([^'^"]+?)['"]''',
                                           1, True)[0], cUrl)
            if 'clipwatching' in videoUrl:
                videoUrl = self.getFullUrl(
                    self.cm.ph.getSearchGroups(
                        data, '''<iframe[^>]+?src=['"]([^"^']+?)['"]''', 1,
                        True)[0], cUrl)
            urlTab = self.up.getVideoLinkExt(
                strwithmeta(videoUrl, {'Referer': cUrl}))

        return urlTab
Exemplo n.º 21
0
    def getPage(self, url, params={}, post_data=None):
        mainParamsUrl = params
        if mainParamsUrl == {}: mainParamsUrl = dict(self.defaultParams)

        while True:
            sts, data = self.cm.getPage(url, mainParamsUrl, post_data)
            if sts and data.meta.get('status_code', 0) in [410, 404]:
                tmp = re.sub("<!--[\s\S]*?-->", "", data)
                if 'sitekey' in tmp:
                    errorMsg = [_('Link protected with google recaptcha v2.')]
                    errorMsg.append(
                        _("Please visit \"%s\" and confirm that you are human."
                          % self.getMainUrl()))
                    if not self.loggedIn:
                        errorMsg.append(
                            _('Please register and set login and password in the host configuration, to solve this problems permanently.'
                              ))
                    errorMsg = '\n'.join(errorMsg)
                    GetIPTVNotify().push(errorMsg, 'info', 10)
                    SetIPTVPlayerLastHostError(errorMsg)
                    break
                elif 'captcha' in tmp:

                    paramsUrl = dict(self.defaultParams)
                    paramsUrl['header'] = dict(paramsUrl['header'])

                    cUrl = self.cm.meta['url']
                    tmp = ph.find(tmp, ('<div', '>', 'footer-404'),
                                  '</form>')[1]

                    captchaTitle = self.cleanHtmlStr(tmp.split('<form', 1)[0])

                    sendLabel = self.cleanHtmlStr(
                        ph.getattr(
                            ph.find(tmp, ('<input', '>', 'Button'),
                                    flags=(ph.IGNORECASE | ph.START_E))[1],
                            'value'))
                    captchaLabel = self.cleanHtmlStr(
                        ph.getattr(tmp, 'placeholder'))
                    captchaLabel = '%s %s' % (sendLabel, captchaLabel)

                    if captchaLabel.strip() == '': captchaLabel = _('Captcha')
                    if captchaTitle == '': captchaTitle = captchaLabel
                    else:
                        captchaTitle = '%s\n\n%s' % (captchaTitle,
                                                     captchaLabel)
                    sendLabel = _('Send')

                    imgUrl = self.getFullIconUrl(
                        ph.search(tmp, ph.IMAGE_SRC_URI_RE)[1], cUrl)

                    actionUrl = self.getFullUrl(ph.getattr(tmp, 'action'),
                                                cUrl)
                    if actionUrl == '': actionUrl = cUrl
                    raw_post = ph.findall(tmp,
                                          '<input',
                                          '>',
                                          flags=ph.IGNORECASE)
                    printDBG(tmp)
                    captcha_post_data = {}
                    for it in raw_post:
                        val = ph.getattr(it, 'value').strip()
                        name = ph.getattr(it, 'name')
                        if name == '': continue
                        captcha_post_data[name] = val

                    header = dict(self.HTTP_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'):
                        errorMsg = _('Fail to get "%s".') % imgUrl
                        SetIPTVPlayerLastHostError(errorMsg)
                        GetIPTVNotify().push(errorMsg, 'error', 10)
                        break
                    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])
                        captcha_post_data['captcha'] = retArg[0][0]
                        paramsUrl['header']['Referer'] = cUrl
                        sts, tmp = self.cm.getPage(actionUrl, paramsUrl,
                                                   captcha_post_data)
                        printDBG(tmp)
                    else:
                        break
            break

        return sts, data
Exemplo n.º 22
0
    def handleService(self, index, refresh=0, searchPattern='', searchType=''):
        printDBG('BBCiPlayer.handleService - start')

        CBaseHostClass.handleService(self, index, refresh, searchPattern,
                                     searchType)

        self.informAboutGeoBlockingIfNeeded('GB')

        name = self.currItem.get("name", '')
        category = self.currItem.get("category", '')
        mode = self.currItem.get("mode", '')

        printDBG(
            "handleService: |||||||||||||||||||||||||||||||||||| name[%s], category[%s] "
            % (name, category))
        self.currList = []

        #MAIN MENU
        if name == None:
            rm(self.COOKIE_FILE)
            self.listMainMenu({
                'name': 'category',
                'url': self.MAIN_URL
            }, 'list_items')
        elif 'live_streams' == category:
            self.listLive(self.currItem)
        elif 'list_channels' == category:
            self.listChannels(self.currItem, 'list_channel')
        elif 'list_channel' == category:
            self.listChannelMenu(self.currItem, 'list_items')
        elif 'list_az_menu' == category:
            self.listAZMenu(self.currItem, 'list_az')
        elif 'list_az' == category:
            self.listAZ(self.currItem, 'list_episodes_view_all')
        elif 'list_categories' == category:
            self.listCategories(self.currItem, 'list_cat_filters')
        elif category in 'list_cat_filters':
            self.listCatFilters(self.currItem, 'list_category')
        elif 'list_category' == category:
            self.listCategory(self.currItem)
        elif 'list_items' == category:
            self.listItems(self.currItem, 'list_episodes')
        elif 'list_items2' == category:
            self.listItems2(self.currItem, 'list_episodes')
        elif 'list_items3' == category:
            self.listItems3(self.currItem, 'list_episodes')
        elif 'list_episodes' == category:
            self.listItems(self.currItem, 'video')
        elif 'list_episodes_view_all' == category:
            self.listItemsViewAll(self.currItem, 'video')

    #SEARCH
        elif category in ["search", "search_next_page"]:
            cItem = dict(self.currItem)
            cItem.update({'search_item': False, 'name': 'category'})
            self.listSearchResult(cItem, searchPattern, searchType)

    #HISTORIA SEARCH
        elif category == "search_history":
            self.listsHistory({
                'name': 'history',
                'category': 'search'
            }, 'desc', _("Type: "))
        else:
            printExc()

        CBaseHostClass.endHandleService(self, index, refresh)
Exemplo n.º 23
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
Exemplo n.º 24
0
    def getLinksForVideo(self, cItem):
        printDBG("StreamComplet.getLinksForVideo [%s]" % cItem)
        urlTab = []

        rm(self.COOKIE_FILE)

        params = dict(self.defaultParams)
        header = dict(self.HEADER)
        header['Referer'] = cItem['url']
        params['header'] = header

        frameUrlsTab = [cItem['url']]

        for idx in range(3):
            newFrameUrlsTab = []
            for frameUrl in frameUrlsTab:
                sts, data = self.cm.getPage(frameUrl, params)
                printDBG(
                    "============================ start ============================"
                )
                printDBG(data)
                printDBG(
                    "============================ end ============================"
                )
                if not sts: continue
                enc1 = self.cm.ph.getDataBeetwenMarkers(
                    data, 'enc1|', '|', False)[1].strip()
                data = self._decodeData(data)
                printDBG(
                    "============================ start ============================"
                )
                printDBG(data)
                printDBG(
                    "============================ end ============================"
                )
                tryLinksTab = re.compile(
                    '<iframe[^>]+?src="([^"]+?)"').findall(data)
                tryLinksTab.extend(
                    re.compile('\s(https?:[^\s]+?)\s').findall(data))
                try:
                    if enc1 != '':
                        tryLinksTab.append(
                            'http://hqq.tv/player/embed_player.php?vid=' +
                            base64.b64decode(enc1))
                except Exception:
                    printExc()

                for item in tryLinksTab:
                    item = item.replace('\\/', '/')
                    if '' == item.strip(): continue
                    if 'facebook' in item: continue
                    if 'wp-content' in item: continue
                    if not self.cm.isValidUrl(item):
                        if item.startswith('../'):
                            item = self.up.getDomain(
                                frameUrl, False) + item.replace('../', '')
                        elif item.startswith('//'):
                            item = 'http://' + item
                        elif item.startswith('/'):
                            item = self.up.getDomain(frameUrl,
                                                     False) + item[1:]
                        else:
                            item = self.up.getDomain(frameUrl,
                                                     False) + item[1:]
                    if 1 == self.up.checkHostSupport(item):
                        urlTab.append({
                            'name': self.up.getHostName(item),
                            'url': item,
                            'need_resolve': 1
                        })
                    else:
                        newFrameUrlsTab.append(item)
            frameUrlsTab = newFrameUrlsTab

        return urlTab
Exemplo n.º 25
0
    def getLinksForVideo(self, cItem):
        printDBG("NaszeKinoTv.getLinksForVideo [%s]" % cItem)
        self.tryTologin()

        if 1 == self.up.checkHostSupport(cItem.get('url', '')):
            videoUrl = cItem['url'].replace('youtu.be/',
                                            'youtube.com/watch?v=')
            return self.up.getVideoLinkExt(videoUrl)

        cacheKey = cItem['url']
        cacheTab = self.cacheLinks.get(cacheKey, [])
        if len(cacheTab): return cacheTab

        self.cacheLinks = {}

        sts, data = self.getPage(cItem['url'])
        if not sts: return

        cUrl = data.meta['url']
        self.setMainUrl(cUrl)

        paramsUrl = dict(self.defaultParams)
        paramsUrl['header'] = dict(paramsUrl['header'])

        ##############################################################################################
        while sts and 'captcha-info' in data:
            # parse form data
            data = self.cm.ph.getDataBeetwenMarkers(data, 'captcha-info',
                                                    '</form>')[1]

            captchaTitle = self.cm.ph.getAllItemsBeetwenMarkers(
                data, '<p', '</p>')
            if len(captchaTitle):
                captchaTitle = self.cleanHtmlStr(captchaTitle[-1])
            else:
                captchaTitle = ''

            sendLabel = self.cleanHtmlStr(
                self.cm.ph.getDataBeetwenMarkers(data, '<button',
                                                 '</button>')[1])
            captchaLabel = self.cleanHtmlStr(
                self.cm.ph.getSearchGroups(
                    data, '''\splaceholder=['"]([^'^"]+?)['"]''')[0])
            captchaLabel = '%s %s' % (sendLabel, captchaLabel)

            if captchaLabel.strip() == '': captchaLabel = _('Captcha')
            if captchaTitle == '': captchaTitle = captchaLabel
            sendLabel = _('Send')

            imgUrl = self.getFullIconUrl(
                self.cm.ph.getSearchGroups(
                    data,
                    '<img[^>]+?src="([^"]+?\.(:?jpe?g|png)(:?\?[^"]+?)?)"')[0],
                cUrl)

            actionUrl = self.getFullUrl(
                self.cm.ph.getSearchGroups(data, 'action="([^"]+?)"')[0], cUrl)
            if actionUrl == '': actionUrl = cUrl
            tmp = re.compile('''<input[^>]+?>''').findall(data)
            printDBG(tmp)
            captcha_post_data = {}
            for it in tmp:
                val = self.cm.ph.getSearchGroups(
                    it, '''\svalue=['"]?([^'^"^\s]+?)['"\s]''')[0].strip()
                name = self.cm.ph.getSearchGroups(
                    it, '''\sname=['"]([^'^"]+?)['"]''')[0]
                captcha_post_data[name] = val

            header = dict(self.HTTP_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])
                captcha_post_data['captcha'] = retArg[0][0]
                paramsUrl['header']['Referer'] = cUrl
                sts, data = self.cm.getPage(actionUrl, paramsUrl,
                                            captcha_post_data)
                if sts: cUrl = data.meta['url']
                else: return []
            else:
                return []
        ##############################################################################################

        msg = self.cm.ph.getDataBeetwenNodes(data, ('', '>', 'alert-info'),
                                             ('</div', '>'), False)[1]
        SetIPTVPlayerLastHostError(msg)

        retTab = []

        data = self.cm.ph.getDataBeetwenNodes(data, ('<tbody', '>'),
                                              ('</tbody', '>'), False)[1]
        data = self.cm.ph.getAllItemsBeetwenMarkers(data, '<tr', '</tr>',
                                                    False)
        for item in data:
            url = ''
            tmp = ph.getattr(item, 'data-iframe')
            try:
                tmp = json_loads(base64.b64decode(tmp))['src']
                url = self.getFullUrl(tmp)
            except Exception:
                printExc()
                url = self.getFullUrl(
                    self.cm.ph.getSearchGroups(item,
                                               '''href=['"]([^"^']+?)['"]''',
                                               1, True)[0])
            if url == '': continue
            item = self.cm.ph.getAllItemsBeetwenMarkers(item, '<td', '</td>')
            name = []
            for t in item:
                t = self.cleanHtmlStr(t)
                if t != '': name.append(t)
            name = ' | '.join(name)
            retTab.append({
                'name': name,
                'url': strwithmeta(url, {'Referer': cUrl}),
                'need_resolve': 1
            })

        if len(retTab):
            self.cacheLinks[cacheKey] = retTab
        return retTab
Exemplo n.º 26
0
    def tryTologin(self):
        printDBG('tryTologin start')
        if None == self.loggedIn or self.login != config.plugins.iptvplayer.orthobulletscom_login.value or\
            self.password != config.plugins.iptvplayer.orthobulletscom_password.value:

            self.login = config.plugins.iptvplayer.orthobulletscom_login.value
            self.password = config.plugins.iptvplayer.orthobulletscom_password.value

            rm(self.COOKIE_FILE)

            self.loggedIn = False

            if '' == self.login.strip() or '' == self.password.strip():
                self.sessionEx.open(MessageBox, _('The host %s requires registration. \nPlease fill your login and password in the host configuration. Available under blue button.' % self.getMainUrl()), type=MessageBox.TYPE_ERROR, timeout=10)
                return False

            sts, data = self.getPage(self.getFullUrl('/login'))
            if not sts:
                return False
            cUrl = self.cm.meta['url']

            sts, data = self.cm.ph.getDataBeetwenNodes(data, ('<form', '>'), ('</form', '>'))
            if not sts:
                return False
            actionUrl = self.cm.getFullUrl(self.cm.ph.getSearchGroups(data, '''action=['"]([^'^"]+?)['"]''')[0], self.cm.getBaseUrl(cUrl))
            if actionUrl == '':
                actionUrl = cUrl

            post_data = {}
            inputData = self.cm.ph.getAllItemsBeetwenMarkers(data, '<input', '>')
            inputData.extend(self.cm.ph.getAllItemsBeetwenMarkers(data, '<button', '>'))
            for item in inputData:
                name = self.cm.ph.getSearchGroups(item, '''name=['"]([^'^"]+?)['"]''')[0]
                value = self.cm.ph.getSearchGroups(item, '''value=['"]([^'^"]+?)['"]''')[0].replace('&amp;', '&')
                post_data[name] = value

            post_data.update({'Username': self.login, 'Password': self.password})

            httpParams = dict(self.defaultParams)
            httpParams['header'] = dict(httpParams['header'])
            httpParams['header']['Referer'] = cUrl
            sts, data = self.cm.getPage(actionUrl, httpParams, post_data)
            if sts:
                cUrl = self.cm.meta['url']
                sts, data = self.cm.ph.getDataBeetwenNodes(data, ('<form', '>'), ('</form', '>'))
                if not sts:
                    return False
                actionUrl = self.cm.getFullUrl(self.cm.ph.getSearchGroups(data, '''action=['"]([^'^"]+?)['"]''')[0], self.cm.getBaseUrl(cUrl))
                if actionUrl == '':
                    actionUrl = cUrl

                post_data = {}
                inputData = self.cm.ph.getAllItemsBeetwenMarkers(data, '<input', '>')
                inputData.extend(self.cm.ph.getAllItemsBeetwenMarkers(data, '<button', '>'))
                for item in inputData:
                    name = self.cm.ph.getSearchGroups(item, '''name=['"]([^'^"]+?)['"]''')[0]
                    value = self.cm.ph.getSearchGroups(item, '''value=['"]([^'^"]+?)['"]''')[0].replace('&amp;', '&')
                    post_data[name] = value

                httpParams['header']['Referer'] = cUrl
                sts, data = self.cm.getPage(actionUrl, httpParams, post_data)
                if sts and '/logout' in data and self.cm.getBaseUrl(self.getMainUrl(), True) in self.cm.getBaseUrl(self.cm.meta['url'], True):
                    printDBG('tryTologin OK')
                    self.loggedIn = True

            if not self.loggedIn:
                self.sessionEx.open(MessageBox, _('Login failed.'), type=MessageBox.TYPE_ERROR, timeout=10)
                printDBG('tryTologin failed')

        return self.loggedIn
Exemplo n.º 27
0
    def tryTologin(self):
        printDBG('tryTologin start')

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

            self.login = config.plugins.iptvplayer.naszekinotv_login.value
            self.password = config.plugins.iptvplayer.naszekinotv_password.value

            sts, data = self.getPage(self.getFullUrl('/profil'))
            if not sts: return False

            login = self.cm.ph.getSearchGroups(
                data, '''alogowany jako:([^<]+?)<''')[0].strip()

            self.loggedIn = False
            if '' == self.login.strip() or '' == self.password.strip():
                if login != '':
                    rm(self.COOKIE_FILE)
                return False
            elif self.login.strip() == login:
                self.loggedIn = True
                return True

            rm(self.COOKIE_FILE)

            url = self.getFullUrl('/logowanie')
            sts, data = self.getPage(url)
            if not sts: return False

            sts, data = self.cm.ph.getDataBeetwenNodes(data,
                                                       ('<form', '>', 'post'),
                                                       ('</form', '>'))
            if not sts: return False

            actionUrl = self.getFullUrl(
                self.cm.ph.getSearchGroups(data,
                                           '''action=['"]([^'^"]+?)['"]''')[0])
            if actionUrl == '': actionUrl = url

            post_data = {}
            tmp = self.cm.ph.getAllItemsBeetwenMarkers(data, '<input', '>')
            tmp.extend(
                self.cm.ph.getAllItemsBeetwenMarkers(data, '<button', '>'))
            for item in tmp:
                name = self.cm.ph.getSearchGroups(
                    item, '''name=['"]([^'^"]+?)['"]''')[0]
                value = self.cm.ph.getSearchGroups(
                    item, '''value=['"]([^'^"]+?)['"]''')[0]
                post_data[name] = value

            post_data.update({
                'login': self.login,
                'password': self.password,
                'remember': 'on'
            })

            httpParams = dict(self.defaultParams)
            httpParams['header'] = dict(httpParams['header'])
            httpParams['header']['Referer'] = url
            sts, data = self.cm.getPage(actionUrl, httpParams, post_data)
            printDBG(data)
            if sts and '/wylogowanie' in data:
                printDBG('tryTologin OK')
                self.loggedIn = True
            else:
                if sts:
                    errMsg = []
                    tmp = self.cm.ph.getAllItemsBeetwenNodes(
                        data, ('<div', '>', 'alert-danger'), ('</div', '>'),
                        False)
                    for it in tmp:
                        errMsg.append(self.cleanHtmlStr(it))
                else:
                    errMsg = [_('Connection error.')]
                self.sessionEx.open(MessageBox,
                                    _('Login failed.') + '\n' +
                                    '\n'.join(errMsg),
                                    type=MessageBox.TYPE_ERROR,
                                    timeout=10)
                printDBG('tryTologin failed')
        return self.loggedIn
Exemplo n.º 28
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
Exemplo n.º 29
0
    def start(self, url, filePath, params={}):
        '''
            Owervrite start from BaseDownloader
        '''
        self.url = url
        self.filePath = filePath
        self.downloaderParams = params
        self.fileExtension = ''  # should be implemented in future
        self.outData = ''
        self.contentType = 'unknown'

        cmdTab = [DMHelper.GET_FFMPEG_PATH(), '-y']
        tmpUri = strwithmeta(url)

        if 'iptv_video_rep_idx' in tmpUri.meta:
            cmdTab.extend(
                ['-video_rep_index',
                 str(tmpUri.meta['iptv_video_rep_idx'])])

        if 'iptv_audio_rep_idx' in tmpUri.meta:
            cmdTab.extend(
                ['-audio_rep_index',
                 str(tmpUri.meta['iptv_audio_rep_idx'])])

        if 'iptv_m3u8_live_start_index' in tmpUri.meta:
            cmdTab.extend([
                '-live_start_index',
                str(tmpUri.meta['iptv_m3u8_live_start_index'])
            ])

        if 'iptv_m3u8_key_uri_replace_old' in tmpUri.meta and 'iptv_m3u8_key_uri_replace_new' in tmpUri.meta:
            cmdTab.extend([
                '-key_uri_old',
                str(tmpUri.meta['iptv_m3u8_key_uri_replace_old']),
                '-key_uri_new',
                str(tmpUri.meta['iptv_m3u8_key_uri_replace_new'])
            ])

        if "://" in self.url:
            url, httpParams = DMHelper.getDownloaderParamFromUrlWithMeta(
                tmpUri, True)
            headers = []
            for key in httpParams:
                if key == 'Range':  #Range is always used by ffmpeg
                    continue
                elif key == 'User-Agent':
                    cmdTab.extend(['-user-agent', httpParams[key]])
                else:
                    headers.append('%s: %s' % (key, httpParams[key]))

            if len(headers):
                cmdTab.extend(['-headers', '\r\n'.join(headers)])

        if self.url.startswith("merge://"):
            try:
                urlsKeys = self.url.split('merge://', 1)[1].split('|')
                for item in urlsKeys:
                    cmdTab.extend(
                        ['-reconnect', '1', '-i', self.url.meta[item]])
            except Exception:
                printExc()
        else:
            cmdTab.extend(['-reconnect', '1', '-i', url])

        cmdTab.extend([
            '-c:v', 'copy', '-c:a', 'copy', '-f',
            tmpUri.meta.get('ff_out_container', self.ffmpegOutputContener),
            self.filePath
        ])

        self.fileCmdPath = self.filePath + '.iptv.cmd'
        rm(self.fileCmdPath)
        WriteTextFile(self.fileCmdPath, '|'.join(cmdTab))

        cmd = GetCmdwrapPath() + (' "%s" "|" %s ' %
                                  (self.fileCmdPath, GetNice() + 2))

        printDBG("FFMPEGDownloader::start cmd[%s]" % cmd)

        self.console = eConsoleAppContainer()
        self.console_appClosed_conn = eConnectCallback(self.console.appClosed,
                                                       self._cmdFinished)
        self.console_stderrAvail_conn = eConnectCallback(
            self.console.stderrAvail, self._dataAvail)
        self.console.execute(cmd)

        self.status = DMHelper.STS.DOWNLOADING

        self.onStart()
        return BaseDownloader.CODE_OK
Exemplo n.º 30
0
    def getPage(self, baseUrl, addParams={}, post_data=None):
        images = []
        errorMessages = []
        if addParams == {}:
            addParams = dict(self.defaultParams)

        baseUrl = self.cm.iriToUri(baseUrl)
        proxy = config.plugins.iptvplayer.kissanime_proxy.value
        printDBG(">> " + proxy)
        if proxy != 'None':
            if proxy == 'proxy_1':
                proxy = config.plugins.iptvplayer.alternative_proxy1.value
            else:
                proxy = config.plugins.iptvplayer.alternative_proxy2.value
            addParams = dict(addParams)
            addParams.update({'http_proxy': proxy})

        addParams['cloudflare_params'] = {
            'domain': self.up.getDomain(baseUrl),
            'cookie_file': self.COOKIE_FILE,
            'User-Agent': self.USER_AGENT,
            'full_url_handle': self.getFullUrl
        }
        while True:
            sts, data = self.cm.getPageCFProtection(baseUrl, addParams,
                                                    post_data)
            if sts and 'areyouhuman' in self.cm.meta['url'].lower():
                errorMessages = []
                formData = ''
                tmp = self.cm.ph.getAllItemsBeetwenMarkers(data,
                                                           '<form',
                                                           '</form>',
                                                           withMarkers=False,
                                                           caseSensitive=False)
                for item in tmp:
                    if 'answerCap' in item:
                        formData = item
                        break

                messages = []
                tmp = self.cm.ph.getAllItemsBeetwenMarkers(
                    formData, '<p', '</p>')
                for item in tmp:
                    item = self.cleanHtmlStr(item)
                    if item != '':
                        messages.append(item)

                if len(messages) < 2:
                    errorMessages.append(
                        _('Unknown captcha form! Data: "%s"') % messages)
                    break

                action = self.cm.ph.getSearchGroups(
                    formData, '''action=['"]([^'^"]+?)['"]''',
                    ignoreCase=True)[0]
                if action == '':
                    action = '/'
                action = self.getFullUrl(action)
                tmp = self.cm.ph.getAllItemsBeetwenMarkers(
                    formData, '<input', '>', False, False)
                post_data2 = {}
                for item in tmp:
                    name = self.cm.ph.getSearchGroups(
                        item, '''name=['"]([^'^"]+?)['"]''',
                        ignoreCase=True)[0]
                    value = self.cm.ph.getSearchGroups(
                        item, '''value=['"]([^'^"]+?)['"]''',
                        ignoreCase=True)[0]
                    if name != '':
                        post_data2[name] = value

                header = dict(self.HTTP_HEADER)
                header['Accept'] = 'image/png,image/*;q=0.8,*/*;q=0.5'
                params = dict(self.defaultParams)
                params.update({
                    'maintype':
                    'image',
                    'subtypes': ['jpeg', 'jpg', 'png'],
                    'check_first_bytes':
                    ['\xFF\xD8', '\xFF\xD9', '\x89\x50\x4E\x47'],
                    'header':
                    header
                })

                prevMeta = self.cm.meta
                images = []
                tmp = self.cm.ph.getAllItemsBeetwenMarkers(
                    formData, '<img', '>', False, False)
                for item in tmp:
                    index = self.cm.ph.getSearchGroups(
                        item,
                        '''indexValue=['"]([^'^"]+?)['"]''',
                        ignoreCase=True)[0]
                    imgUrl = self.getFullIconUrl(
                        self.cm.ph.getSearchGroups(
                            item,
                            '''src=['"]([^'^"]+?)['"]''',
                            ignoreCase=True)[0])
                    if index != '' and imgUrl != '':
                        filePath = GetTmpDir(
                            '.iptvplayer_captcha_picture_%s.jpg' % index)
                        rm(filePath)
                        ret = self.cm.saveWebFile(filePath,
                                                  imgUrl.replace('&amp;', '&'),
                                                  params)
                        if ret.get('sts'):
                            images.append({'path': filePath, 'id': index})
                            continue
                        errorMessages.append(
                            _('Download "%s" in to "%s" failed!') %
                            (imgUrl, filePath))
                    else:
                        errorMessages.append(
                            _('Unknow data in the captcha item!'))
                        errorMessages.append('item: "%s"' % item)
                    break
                self.cm.meta = prevMeta
                if 0 == len(errorMessages):
                    printDBG("++++++++++++++++++++++++++++++++++")
                    printDBG('action:    %s' % action)
                    printDBG('post_data: %s' % post_data2)
                    printDBG('images:    %s' % images)
                    printDBG("++++++++++++++++++++++++++++++++++")
                    message = '\n'.join(messages[1:])
                    if ' TWO ' in message:
                        maxSelItems = 2
                        acceptLabel = None
                    else:
                        maxSelItems = None
                        acceptLabel = _('-- OK --')
                    retArg = self.sessionEx.waitForFinishOpen(
                        IPTVMultipleImageSelectorWidget,
                        title='Captcha',
                        message=message,
                        message_height=100,
                        images=images,
                        image_width=160,
                        image_height=160,
                        accep_label=acceptLabel,
                        max_sel_items=maxSelItems)
                    printDBG(retArg)
                    if retArg and len(retArg) and isinstance(retArg[0], list):
                        printDBG(retArg[0])
                        post_data2['answerCap'] = ','.join(retArg[0]) + ','
                        addParams2 = dict(addParams)
                        addParams2['header'] = dict(addParams2['header'])
                        addParams2['header']['Referer'] = prevMeta['url']
                        sts2, data2 = self.cm.getPageCFProtection(
                            action, addParams, post_data2)
                        #printDBG("++++++++++++++++++++++++++++++++++")
                        #printDBG(data2)
                        #printDBG("++++++++++++++++++++++++++++++++++")
                        if sts2:
                            if 'areyouhuman' in self.cm.meta['url'].lower():
                                printDBG(">>> TRY AGAIN")
                                continue
                            else:
                                sts, data = sts2, data2
                    else:
                        self.cm.meta = prevMeta
            break

        if len(errorMessages):
            GetIPTVNotify().push('\n'.join(errorMessages), 'error', 10)

        #printDBG("++++++++++++++++++++++++++++++++++")
        #printDBG(data)
        #printDBG("++++++++++++++++++++++++++++++++++")

        for item in images:
            rm(item['path'])

        return sts, data
Exemplo n.º 31
0
 def getLinksForVideo(self, cItem):
     printDBG("TvGryPL.getLinksForVideo [%s]" % cItem)
     allLinksTab = []
     urlTab = []
     
     rm(self.COOKIE_FILE)
     
     sts, data = self.getPage(cItem['url'], self.defaultParams) #{'use_cookie':True, 'cookie_items':{'agegate':1}})
     if not sts: return urlTab
     
     ageMarker = '<div class="player-AGEGATE">'
     if ageMarker in data:
         tmp = self.cm.ph.getSearchGroups(config.plugins.iptvplayer.tvgrypl_date_of_birth.value, '''([0-9]{4})[-]?([0-9][0-9]?)[-]?([0-9][0-9]?)''', 3)
         printDBG(">>>>>YEAR[%s] MONTH[%s] DAY[%s]" % (tmp[0], tmp[1], tmp[2]))
         if '' != tmp[0] and '' != tmp[1] and '' != tmp[2]:
             urlParams = dict(self.defaultParams)
             urlParams['header'] = dict(self.AJAX_HEADER)
             urlParams['header']['Referer'] = cItem['url']
             
             sts, data = self.getPage('https://tvgry.pl/ajax/agegate.asp', urlParams, {'day':int(tmp[2]), 'month':int(tmp[1]), 'year':int(tmp[0])})
             if not sts: return []
             
             sts, data = self.getPage(cItem['url'], self.defaultParams)
             if not sts: return urlTab
             
             if ageMarker in data:
                 SetIPTVPlayerLastHostError("Twój wiek nie został poprawnie zweryfikowany przez serwis http://tvgry.pl/.\nSprawdź ustawioną datę urodzenia w konfiguracji hosta.")
         else:
             SetIPTVPlayerLastHostError("Wprowadź datę urodzenia w konfiguracji hosta - wymagane przez serwis http://tvgry.pl/.")
             
     
     url = self.cm.ph.getSearchGroups(data, '''<iframe[^>]+?src=['"]([^"^']+?)['"]''', 1, True)[0]
     if self.cm.isValidUrl(url):
         allLinksTab = self.up.getVideoLinkExt(url)
     
     urlIDS = []
     urlTemplate = ''
     data = self.cm.ph.getDataBeetwenMarkers(data, 'sources:', ']')[1]
     data = self.cm.ph.getAllItemsBeetwenMarkers(data, '{', '}')
     for item in data:
         url = self.cm.ph.getSearchGroups(item, '''['"]?file['"]?\s*:\s*['"]([^'^"]+?)['"]''')[0]
         name = self.cm.ph.getSearchGroups(item, '''['"]?label['"]?\s*:\s*['"]([^'^"]+?)['"]''')[0]
         if self.cm.isValidUrl(url):
             id = self.cm.ph.getSearchGroups(url, '''(/[0-9]+_)[0-9]+''')[0]
             if id != '' and id not in urlIDS:
                 urlIDS.append(id)
                 if urlTemplate == '': urlTemplate = url.replace(id, '{0}')
                 
             q = ""
             if '/500_' in url or "Mobile" in url:
                 q = 'MOB'
             elif '/750_' in url or "SD" in url:
                 q = 'SD'
             elif '/1280_' in url or "720p" in url:
                 q = 'HD'
             if q != '': urlTab.append({'name':name, 'url':strwithmeta(url, {"Range": "bytes=0-"}), 'q':q, 'need_resolve':0})
     
     if urlTemplate != '':
         params = dict(self.defaultParams)
         params['header'] = dict(params['header'])
         params['header']['Range'] = "bytes=0-"
         params['max_data_size'] = 0
         params['header'].pop('Accept', None)
         for item in [('/500_', 'MOB'), ('/750_', 'SD'), ('/1280_', 'HD')]:
             if item[0] in urlIDS: continue
             url = urlTemplate.format(item[0])
             sts = self.cm.getPage(url, params)[0]
             if sts and 'mp4' in self.cm.meta.get('content-type', '').lower():
                 urlTab.append({'name':item[1], 'url':strwithmeta(url, {"Range": "bytes=0-"}), 'q':item[1], 'need_resolve':0})
     
     if 1 < len(urlTab):
         map = {'MOB':0, 'SD':1, 'HD':2, 'FHD':3}
         oneLink = CSelOneLink(urlTab, lambda x: map[x['q']], map[config.plugins.iptvplayer.tvgrypl_default_quality.value])
         if config.plugins.iptvplayer.tvgrypl_use_dq.value: urlTab = oneLink.getOneLink()
         else: urlTab = oneLink.getSortedLinks()
     
     if 0 == len(urlTab):
         return allLinksTab
     
     return urlTab
Exemplo n.º 32
0
 def terminate(self):
     self.cancelRequest()
     self.doInit()  # to eventually break circular references
     for item in self.filesToRemove:
         rm(item)
Exemplo n.º 33
0
 def _cleanUp(self):
     for item in self.multi['files']:
         rm(item)