Exemple #1
0
    def exploreItem(self, cItem, nextCategory):
        printDBG("Cinemaxx.exploreItem")
        self.cacheLinks = {}

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

        desc = []
        descObj = self.getArticleContent(cItem, data)[0]
        icon = descObj['images'][0]['url']
        baseTitle = descObj['title']
        for item in descObj['other_info']['custom_items_list']:
            desc.append(item[1])
        desc = ' | '.join(desc) + '[/br]' + descObj['text']

        data = ph.find(data, ('<div', '>', 'dle-content'),
                       ('<div', '>', 'dle_b_iptv'),
                       flags=0)[1]
        trailer = ph.find(data, ('<', '>', '#trailer'), '</div>', flags=0)[1]
        title = self.cleanHtmlStr(trailer)
        trailer = self.getFullUrl(ph.search(trailer, ph.IFRAME_SRC_URI_RE)[1])
        if trailer:
            self.addVideo({
                'good_for_fav': True,
                'prev_url': cUrl,
                'title': '%s %s' % (title, baseTitle),
                'url': trailer,
                'icon': icon,
                'desc': desc
            })

        data = ph.find(data, ('<div', '>', 'full-video'), '</div>', flags=0)[1]
        url = self.getFullUrl(ph.search(data, ph.IFRAME_SRC_URI_RE)[1])
        if url:
            if ('/video/' in url and '/serials/' in url) or 'playlist' in url:
                url = strwithmeta(url, {'Referer': cUrl})
                seasons = self.hdgocc.getSeasonsList(url)
                for item in seasons:
                    self.addDir(
                        MergeDicts(
                            cItem, {
                                'good_for_fav': False,
                                'prev_url': cUrl,
                                'category': nextCategory,
                                'serie_title': baseTitle,
                                'title': 'Staffel %s' % item['title'],
                                'season_id': item['id'],
                                'url': item['url'],
                                'icon': icon,
                                'desc': desc
                            }))

                if 0 != len(seasons):
                    return

                seasonUrl = url
                episodes = self.hdgocc.getEpiodesList(seasonUrl, -1)
                for item in episodes:
                    title = '{0} - {1} - s01e{2} '.format(
                        baseTitle, item['title'],
                        str(item['id']).zfill(2))
                    self.addVideo({
                        'good_for_fav': False,
                        'type': 'video',
                        'prev_url': cUrl,
                        'title': title,
                        'url': item['url'],
                        'icon': icon,
                        'desc': desc
                    })

                if 0 != len(episodes):
                    return

            self.addVideo({
                'good_for_fav': False,
                'prev_url': cUrl,
                'title': baseTitle,
                'url': url,
                'icon': icon,
                'desc': desc
            })
        else:
            data = ph.find(data, 'vk.show(', ');', flags=0)[1].split(',',
                                                                     1)[-1]
            ret = js_execute('print(JSON.stringify(%s));' % data)
            if ret['sts'] and 0 == ret['code']:
                try:
                    data = json_loads(ret['data'])
                    for sNum, season in enumerate(data, 1):
                        subItems = []
                        for eNum, episode in enumerate(season, 1):
                            title = baseTitle + ' s%se%s' % (
                                str(sNum).zfill(2), str(eNum).zfill(2))
                            subItems.append({
                                'good_for_fav': False,
                                'type': 'video',
                                'prev_url': cUrl,
                                'title': title,
                                'url': episode,
                                'icon': icon,
                                'desc': desc
                            })
                        if subItems:
                            self.addDir(
                                MergeDicts(
                                    cItem, {
                                        'good_for_fav':
                                        False,
                                        'prev_url':
                                        cUrl,
                                        'title':
                                        'Staffel %s' % (str(sNum).zfill(2)),
                                        'category':
                                        'sub_items',
                                        'sub_items':
                                        subItems
                                    }))
                except Exception:
                    printExc()
    def listItems(self, cItem, nextCategory, post_data=None):
        printDBG("hostszenestreamz.listItems |%s|" % cItem)

        url = cItem['url']
        page = cItem.get('page', 1)

        sts, data = self.getPage(url, {}, post_data)

        if not sts: return

        nextPage, pagedata = ph.find(data, '<span class="pagesBlockuz1">',
                                     '<span class="numShown73">')

        urls = []
        titles = []
        genres = []
        ldata = ph.findall(data, '<a class="newstitl entryLink"', '</a>')
        for item in ldata:
            url = self.getFullUrl(ph.search(item, ph.A_HREF_URI_RE)[1])
            urls.append(url)
            title = self.cleanHtmlStr(
                ph.search(item, '''href=['"][^'^"]+['"]>(.+)</''')[0])
            titles.append(title)

        gdata = ph.findall(data, '<div class="MesWrapBlogDet"', '</a>')
        for item in gdata:
            if '<script>' in item: continue
            genre = self.cleanHtmlStr(
                ph.search(item, '''href=['"][^'^"]+['"]>([^<]+)</''')[0])
            genre = genre.replace('Genre: ', '')
            if genre.startswith('S-'): genre = genre.replace('S-', '')
            genres.append(genre)

        index = 0
        data = ph.findall(data, '<div class="ImgWrapNews">', '</div>')
        for item in data:
            icon = self.getFullIconUrl(
                ph.search(item, '''src=['"]([^'^"]+?)['"]''')[0])
            url = urls[index]
            title = titles[index]
            genre = genres[index]
            desc = ''
            if genre != '':
                desc = genre
            params = dict(cItem)
            params.update({
                'good_for_fav': True,
                'category': nextCategory,
                'title': title,
                'url': url,
                'desc': desc,
                'icon': icon
            })
            self.addDir(params)
            index += 1
            printDBG("hostszenestreamz.title [%s]" % title)

        if nextPage:
            printDBG("hostszenestreamz.nextPage")
            thispage = ph.findall(pagedata, 'class="swchItem', '</span>')
            current_page = False
            url = ''
            for pitem in thispage:
                if 'swchItemA' in pitem:
                    current_page = True
                elif current_page:
                    url = self.getFullUrl(
                        ph.search(pitem, '''href="([^"]+)"''')[0])
                    break

            if url != '':
                params = dict(cItem)
                params.update({
                    'good_for_fav': False,
                    'title': _('Next page'),
                    'page': page + 1,
                    'url': url
                })
                self.addDir(params)
Exemple #3
0
    def getLinksForItem(self, cItem):
        printDBG("EskaGo.getLinksForItem [%s]" % cItem)
        urlTab = []

        url = cItem['url']

        if cItem.get('is_trailer'):
            urlTab = getDirectM3U8Playlist(strwithmeta(url, {'iptv_proto':'m3u8'}), checkExt=True, checkContent=True, sortWithMaxBitrate=999999999)
            for item in urlTab:
                item['url'] = strwithmeta(item['url'], {'iptv_proto':'m3u8'})
            return urlTab

        if '/vod/' in url:
            sts, data = self.cm.getPage(url, self.defaultParams)
            if not sts: return []
            data = ph.find(data, ('<div', '>', 'layer-vod'), '</script>', flags=0)[1]
            hls = self.cm.getFullUrl(ph.search(data, r'''var\s+?hls\s*?=\s*?(['"])([^>]*?)(?:\1)''')[1], self.cm.meta['url'])
            mp4 = self.cm.getFullUrl(ph.search(data, r'''var\s+?mp4\s*?=\s*?(['"])([^>]*?)(?:\1)''')[1], self.cm.meta['url'])
            urlTab = getDirectM3U8Playlist(hls, checkExt=True, checkContent=True, sortWithMaxBitrate=999999999)
            for item in urlTab:
                item['url'] = strwithmeta(item['url'], {'iptv_proto':'m3u8'})
            if mp4 != '': urlTab.append({'name':'mp4', 'url':mp4, 'need_resolve':0})
            return urlTab

        if self.up.getDomain(self.MAIN_ESKAPL_URL , onlyDomain=True) in url:
            sts, data = self.cm.getPage(url, self.defaultParams)
            if not sts: return []
            data = self.cm.ph.getDataBeetwenMarkers(data, '<div class="play_player">', '</div>')[1]
            url = self.cm.ph.getSearchGroups(data, '''href=['"]([^'^"]+?)['"]''')[0]
            if not self.cm.isValidUrl(url): return []

        sts, data = self.cm.getPage(url)
        if not sts: data = ''

        if '/radio/' in  url:
            tmp = self.cm.ph.getDataBeetwenMarkers(data, 'input[name="data-radio-url"]', ';', withMarkers=False)[1]
            url  =  self.cm.ph.getSearchGroups(tmp, '''(https?://[^'^"]+?)['"]''')[0]
            if url != '' and url.endswith('.pls'):
                sts, tmp = self.cm.getPage(url)
                if not sts: return []
                printDBG(tmp)
                tmp = tmp.split('File')
                if len(tmp): del tmp[0]
                for item in tmp:
                    printDBG('ITEM [%s]' % item)
                    url  = self.cm.ph.getSearchGroups(item, '''(https?://[^\s]+?)\s''')[0]
                    name = self.cm.ph.getSearchGroups(item, '''Title[^=]*?=([^\s]+?)\s''')[0].strip()
                    urlTab.append({'name':name, 'url':url})
            else:
                tmp1 = self.cm.ph.getAllItemsBeetwenMarkers(data, '<script', '</script>')
                for tmp in tmp1:
                    tmp = self.cm.ph.getAllItemsBeetwenMarkers(tmp, '{', '}')
                    for item in tmp:
                        if 'streamUrl' in item:
                            streamUrl  = self.cm.ph.getSearchGroups(item, '''streamUrl\s*=\s*['"](https?://[^'^"]+?)['"]''')[0]
                            streamType = self.cm.ph.getSearchGroups(item, '''streamType\s*=\s*['"]([^'^"]+?)['"]''')[0]
                            if 'aac' in streamType:
                                streamUrl = streamUrl.replace('.mp3', '.aac')
                            elif 'mp3' in streamType:
                                streamUrl = streamUrl.replace('.aac', '.mp3')
                            streamUrl = streamUrl + self.cm.ph.getSearchGroups(data, '''value\s*=\s*['"](timestamp[^'^"]+?)['"]''')[0]
                            urlTab.append({'name':streamType, 'url':streamUrl})
        return urlTab
Exemple #4
0
 def getLinksForVideo(self, cItem):
     try:
         urlTab = []
         url = cItem['url']
         baseUrl = strwithmeta(url)
         HTTP_HEADER = self.cm.getDefaultHeader(browser='chrome')
         referer = baseUrl.meta.get('Referer')
         if referer: HTTP_HEADER['Referer'] = referer
         urlParams = {'header': HTTP_HEADER}
         sts, data = self.cm.getPage(baseUrl, urlParams)
         if not sts: return []
         if data == '': return []
         cUrl = self.cm.meta['url']
         f = ph.find(data,
                     zlib.decompress(
                         base64.b64decode('eJwryEmsTC2yBwALugLN')),
                     '&',
                     flags=0)[1]
         if not f:
             f = cUrl.split(
                 zlib.decompress(base64.b64decode('eJwryEmsTC2yBwALugLN')),
                 1)[-1].rsplit('&', 1)[0]
         if not f:
             f = ph.find(data,
                         zlib.decompress(
                             base64.b64decode('eJwryEmsTC2yBwALugLN')),
                         '&',
                         flags=0)[1]
         if not f: return []
         url = zlib.decompress(
             base64.b64decode(
                 'eJwVylsKgCAQBdDd+NljAdJSZMJrRqbDOEQh7r36PZzx2j2IEz0Qt0HdfaaBIy9t6qYqidrJINOaUDNxjeWH72soclqPemhhIwgQgdg29xc2Sx/I'
             )).format(f, urllib.quote(baseUrl))
         sts, data = self.cm.getPage(self.cm.getFullUrl(url, cUrl))
         if not sts: return []
         if data == '': return []
         meta = {
             'Referer': cUrl,
             'Origin': urlparser.getDomain(baseUrl, False)[:-1],
             'User-Agent': HTTP_HEADER['User-Agent']
         }
         hlsMeta = MergeDicts(meta, {'iptv_proto': 'm3u8'})
         data = ph.find(data, ('<video_sources', '>'),
                        '</video_sources>',
                        flags=0)[1]
         if data == '': return []
         data = ph.findall(data, ('<video_source', '>'), '</video_source>')
         if data == '': return []
         for item in data:
             url = self.cm.getFullUrl(ph.clean_html(item), cUrl)
             if not url: continue
             if 'video/mp4' in item:
                 width = ph.getattr(item, 'width')
                 height = ph.getattr(item, 'height')
                 name = ph.getattr(item, 'name')
                 url = urlparser.decorateUrl(url, meta)
                 urlTab.append({
                     'name':
                     '{0} - {1}x{2}'.format(name, width, height),
                     'url':
                     url
                 })
             elif 'mpegurl' in item:
                 url = urlparser.decorateUrl(url, hlsMeta)
                 tmpTab = getDirectM3U8Playlist(url,
                                                checkExt=False,
                                                checkContent=True)
                 urlTab.extend(tmpTab)
         urlTab.reverse()
         if cItem['category'] != 'list_third':
             self.susmrgts('2', '12', cItem['tps'], cItem['url'],
                           cItem['title'], cItem['icon'], cItem['desc'],
                           'mnez')
         return urlTab
     except Exception:
         return []
Exemple #5
0
    def getLinksForVideo(self, cItem):
        linksTab = self.cacheLinks.get(cItem['url'], [])
        if linksTab:
            return linksTab

        url_data = cItem['url'].split('?', 1)
        if len(url_data) != 2:
            return []

        query = {}
        url_data[1] = url_data[1].split('&')
        for item in url_data[1]:
            item = item.split('=', 1)
            if len(item) != 2:
                continue
            query[item[0]] = item[1]
        url_data[1] = query

        url_data[1]['server'] = 'alternate'
        url_data[1]['referrer'] = 'link'
        url = self.joinLink(url_data)

        sts, data = self.getPage(url)
        if sts:
            e = '1'  #ph.clean_html(ph.find(data, ('<span', '>', 'serverActive'), '</a>')[1])
            data = self.getFunctionCode(data, 'function streams(')
            jscode = 'efun=function(){},elem={slideToggle:efun,toggleClass:efun,hide:efun,removeAttr:efun,attr:efun},$=function(){return elem},$.post=function(){print(arguments[0])};document={"querySelector":function(){return {"textContent":"'
            jscode += e + '"};}};streams();' + data
            ret = js_execute(jscode)
            if ret['sts'] and 0 == ret['code']:
                url = self.getFullUrl(ret['data'].strip(), self.cm.meta['url'])
                sts, data = self.getPage(url)
                if sts:
                    printDBG(">>>")
                    printDBG(data)
                    data = ph.find(data, ('<ul', '>'), '</ul>',
                                   flags=0)[1].split('</li>')
                    for item in data:
                        tmp = ph.find(item, 'show_player(', ')',
                                      flags=0)[1].replace('\\"', '"').replace(
                                          "\\'", "'")
                        url = self.getFullUrl(
                            ph.search(
                                item,
                                '''['"]((?:https?:)?//[^'^"]+?)['"]''')[0])
                        if not url:
                            url = ph.search(item, ph.A)[1]
                        if url:
                            name = []
                            item = ph.findall(item, ('<span', '>'),
                                              '</span>',
                                              flags=0)
                            for t in item:
                                t = ph.clean_html(t)
                                if t:
                                    name.append(t)
                            linksTab.append({
                                'name': ' | '.join(name),
                                'url': url,
                                'need_resolve': 1
                            })

        url_data[1]['server'] = '1'
        url_data[1]['referrer'] = 'link'
        url = self.joinLink(url_data)
        linksTab.insert(0, {'name': 'Server 1', 'url': url, 'need_resolve': 1})

        if len(linksTab):
            self.cacheLinks[cItem['url']] = linksTab

        return linksTab
Exemple #6
0
    def listVodItem(self, cItem, nextCategory):
        printDBG("EskaGo.listVodItem")
        url = cItem['url']
        if '/vod/' in url:
            type = 'vod'
            url = url.replace('/vod/', '/ajax/vod/')
        else:
            type = 'serial'
            url = url.replace('/serial/',
                              '/ajax/serial/').replace('/program/',
                                                       '/ajax/program/')

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

        desc = self.cleanHtmlStr(
            ph.find(data, ('<div', '>', 'text-desc'), '</div>', flags=0)[1])
        icon = ph.find(data, ('<div', '>', 'bg-film'), '</div>', flags=0)[1]
        icon = self.cm.getFullUrl(
            ph.search(icon, ph.IMAGE_SRC_URI_RE)[1], self.cm.meta['url'])
        if not icon: icon = cItem.get('icon', '')

        if type != 'vod':
            tmp = ph.find(data, ('<div', '>', 'seasons'),
                          ('<div', '>', 'clear'),
                          flags=0)[1]
            tmp = ph.findall(tmp, '<a', '</a>')
            for item in tmp:
                url = self.cm.getFullUrl(
                    ph.search(item, ph.A_HREF_URI_RE)[1], self.cm.meta['url'])
                title = self.cleanHtmlStr(item)
                if not title: continue
                self.addDir(
                    MergeDicts(
                        cItem, {
                            'good_for_fav': True,
                            'category': nextCategory,
                            'title': title,
                            's_title': '%s: %s,' % (cItem['title'], title),
                            'url': url,
                            'icon': icon,
                            'desc': desc
                        }))

            if len(self.currList) == 0:
                cItem = MergeDicts(cItem, {'s_title': '%s: ' % cItem['title']})
                self.listVodEpisodes(cItem, data)
        else:
            tmp = ph.find(data, ('<div', '>', 'layer-vod'),
                          '</script>',
                          flags=0)[1]
            if tmp:
                self.addVideo(
                    MergeDicts(cItem, {
                        'good_for_fav': True,
                        'icon': icon,
                        'desc': desc
                    }))

        trailer = ph.find(data, ('<a', '>', 'trailer'), '</a>')[1]
        trailer = self.cm.getFullUrl(
            ph.search(trailer, ph.A_HREF_URI_RE)[1], self.cm.meta['url'])
        if trailer:
            self.addVideo(
                MergeDicts(
                    cItem, {
                        'good_for_fav': True,
                        'title': _('%s - trailer') % (cItem['title']),
                        'url': trailer,
                        'icon': icon,
                        'desc': desc,
                        'is_trailer': True
                    }))
Exemple #7
0
    def listEPG(self, cItem):
        printDBG("La7 - start replay/EPG section - single day")
        label = cItem["category"]
        day_number = label[4:5]
        ch = label[5:]
        url = self.RIVEDILA7_URL.format(day_number, ch)
        sts, html = self.getPage(url)

        if not sts: return

        guida_tv = ph.findall(html, "<div id=\"content_guida_tv_rivedi",
                              "<!-- THEME DEBUG -->")
        if len(guida_tv) > 0:
            #printDBG(guida_tv[0])

            items = ph.findall(guida_tv[0], '<div id="item',
                               '</div>\r\n                  </div>\r\n')
            for item in items:
                t, orario = ph.find(item,
                                    "<div class=\"orario\">",
                                    "</div>",
                                    flags=0)
                t, desc = ph.find(item,
                                  "<div class=\"occhiello\">",
                                  "</div>",
                                  flags=0)
                if desc:
                    desc = self.cleanHtmlStr(desc)

                # search for icon
                icon = re.findall("data-background-image=\"(.*?)\"", item)
                if icon:
                    icon = icon[0]
                    if icon.startswith('//'):
                        icon = 'https:' + icon
                #search for url
                url = re.findall("href=\"(.*?)\"", item)
                if url:
                    url = url[0]
                    cat = 'epg_item'
                    tc = 'white'
                else:
                    url = ' '
                    desc = "NON DISPONIBILE \n" + desc
                    cat = 'epg_item_nop'
                    tc = 'red'

                # search for title
                title = ph.findall(item, '<h2>', '</h2>')
                if title:
                    title = self.cleanHtmlStr(title[0])
                    title = "{0} {1}".format(orario, title)

                params = MergeDicts(
                    cItem, {
                        'category': cat,
                        'title': title,
                        'url': url,
                        'desc': desc,
                        'icon': icon,
                        'text_color': tc
                    })
                printDBG(str(params))
                self.addVideo(params)
    def getLinksForVideo(self, cItem):
        printDBG("FilmyNaDzis.getLinksForVideo [%s]" % cItem)

        if 1 == self.up.checkHostSupport(cItem['url']):
            return self.up.getVideoLinkExt(cItem['url'])

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

        self.cacheLinks = {}

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

        token = ph.find(data, ('<meta', '>', 'token'))[1]
        token_name = ph.getattr(token, 'name')
        token_content = ph.getattr(token, 'content')
        
        printDBG("FilmyNaDzis.getLinksForVideo --> token --> name '%s' - content '%s'" % (token_name, token_content))
        
        urlParams = self.getDefaultParams(True)
        urlParams['header'] = MergeDicts(urlParams['header'], {'Referer': cUrl, 'x-csrf-' +  token_name: token_content })

        data = ph.find(data, ('<div', '>', 'video_thumbnail'), '</div>', flags=0)[1]
        printDBG("------------------------")
        printDBG(data)
        printDBG("------------------------")
        
        tmp = self.getFullUrl(ph.search(data, ph.A)[1], cUrl)
        if tmp: 
            if self.cm.getBaseUrl(tmp) != self.cm.getBaseUrl(cUrl):
                name = self.cm.getBaseUrl(tmp)
                params = {'name': name, 'url':strwithmeta(tmp, {'Referer': cUrl, 'x-csrf-' +  token_name: token_content }), 'need_resolve':1}
                printDBG("-------> link: %s" % str(params))
                urlTab.append(params)
            else:
                printDBG("-------> %s" % tmp)
        
        tmp = ph.find(data, ('<a', '>', ph.check(ph.all, ('data-id', ))))[1]
        tmp = re.compile('''data-([^=]+?)="([^"]*?)"''').findall(tmp)
        
        sts, data = self.getPage(cUrl, urlParams, MergeDicts({'action':'get_video_player'}, dict(tmp)))
        if not sts: 
            return

        tmp = self.cm.ph.getAllItemsBeetwenMarkers(data, '<source', '>')
        if len(tmp):
            for item in tmp:
                type = self.cm.ph.getSearchGroups(item, '''type=['"]([^'^"]+?)['"]''')[0].lower()
                url  = self.cm.ph.getSearchGroups(item, '''src=['"]([^'^"]+?)['"]''')[0]
                
                if 'video/mp4' == type: 
                    urlTab.append({'name':self.up.getHostName(url), 'url':self.getFullUrl(url), 'need_resolve':0})
                elif 'm3u' in url:
                    urlTab.extend(getDirectM3U8Playlist(url, checkExt=False, checkContent=True, sortWithMaxBitrate=999999999))

        tmp = self.cm.ph.getAllItemsBeetwenMarkers(data, '<iframe', '>')
        if len(tmp):
            for item in tmp:
                url  = self.cm.ph.getSearchGroups(item, '''src=['"]([^'^"]+?)['"]''')[0]
                urlTab.append({'name':self.up.getHostName(url), 'url':self.getFullUrl(url), 'need_resolve':1})

        if urlTab:
            self.cacheLinks[cacheKey] = urlTab

        return urlTab
Exemple #9
0
    def getList(self, cItem):
        printDBG("FirstOneTvApi.getChannelsList")
        self.tryTologin()

        channelsTab = []

        if cItem.get('priv_cat') == None:
            defLang = GetDefaultLang()
            sts, data = self.cm.getPage(self.getFullUrl('/Live'), self.http_params)
            if not sts:
                return []

            tmp = ph.find(data, ('<div', '>', 'list-group'), '</section>', flags=0)[1]
            tmp = ph.rfindall(tmp, '</div>', ('<div', '>', 'group-item-grid'), flags=0)
            for item in tmp:
                title = ph.clean_html(ph.getattr(item, 'alt'))
                icon = ph.search(item, ph.IMAGE_SRC_URI_RE)[1]
                url = ph.search(item, ph.A_HREF_URI_RE)[1]
                desc = []
                item = ph.findall(item, ('<div', '>', 'thumb-stats'), '</div>', flags=0)
                for t in item:
                    t = ph.clean_html(t)
                    if t:
                        desc.append(t)
                params = MergeDicts(cItem, {'title': title, 'priv_cat': 'list_channels', 'url': self.getFullUrl(url), 'icon': self.getFullIconUrl(icon), 'desc': ' | '.join(desc)})
                lang = icon.split('?', 1)[0].rsplit('/', 1)[-1].split('.', 1)[0].lower()
                if lang == defLang:
                    channelsTab.insert(0, params)
                else:
                    channelsTab.append(params)
            if self.loggedIn:
                sts, data = self.cm.getPage(self.getFullUrl('/Account/Favorites'), self.http_params)
                if sts:
                    data = ph.find(data, ('<div', '>', 'widgetContent'), '</div>', flags=0)[1]
                    data = ph.find(data, ('<a', '>', 'active'), '</a>')[1]
                    tmp = ph.clean_html(ph.find(data, ('<span', '>'), '</span>', flags=0)[1])
                    try:
                        if int(tmp) > 0:
                            url = ph.search(data, ph.A_HREF_URI_RE)[1]
                            title = ph.clean_html(data)
                            channelsTab.insert(0, MergeDicts(cItem, {'title': title, 'priv_cat': 'list_channels', 'url': self.getFullUrl(url)}))
                    except Exception:
                        printExc()
        else:
            reObj = re.compile('<[/\s]*?br[/\s]*?>', re.I)
            sts, data = self.cm.getPage(cItem['url'], self.http_params)
            if not sts:
                return []

            tmp = ph.find(data, ('<div', '>', 'list-group'), '</section>', flags=0)[1]
            tmp = ph.rfindall(tmp, '</div>', ('<div', '>', 'group-item-grid'), flags=0)
            for item in tmp:
                title = ph.clean_html(ph.find(item, '<h6>', '</h6>', flags=0)[1])
                if not title:
                    title = ph.clean_html(ph.getattr(item, 'alt'))
                icon = ph.search(item, ph.IMAGE_SRC_URI_RE)[1]
                url = ph.search(item, ph.A_HREF_URI_RE)[1]
                desc = []
                tmp = ph.findall(item, ('<div', '>', 'thumb-stats'), '</div>', flags=0)
                for t in tmp:
                    t = ph.clean_html(t)
                    if t:
                        desc.append(t)
                desc = ' | '.join(desc) + '[/br]' + ph.clean_html(reObj.sub('[/br]', ph.find(item, ('<a', '>'), '</a>', flags=0)[1]))
                channelsTab.append(MergeDicts(cItem, {'type': 'video', 'title': title, 'priv_cat': 'list_channels', 'url': self.getFullUrl(url), 'icon': self.getFullIconUrl(icon), 'desc': desc}))
        return channelsTab
Exemple #10
0
    def exploreItem(self, cItem, nextCategory):
        printDBG("C7tvDe.exploreItem")
        sts, data = self.getPage(cItem['url'])
        if not sts:
            return
        self.setMainUrl(self.cm.meta['url'])

        tmp = ph.find(data, 'var contentResources = [', '];', flags=0)[1]
        try:
            tmp = json_loads('[%s]' % tmp)
            for item in tmp:
                icon = self.getFullIconUrl(item.get('poster', ''))
                desc = []
                try:
                    desc.append(str(timedelta(seconds=item['duration'])))
                except Exception:
                    printExc()
                try:
                    desc.append(item['teaser']['description'])
                except Exception:
                    printExc()
                self.addVideo(
                    MergeDicts(
                        cItem, {
                            'good_for_fav': False,
                            'title': item['title'],
                            'item_data': item,
                            'icon': icon,
                            'desc': '[/br]'.join(desc)
                        }))
        except Exception:
            printExc()
            return []

        if not cItem.get('sub_menu_item'):
            tmp = ph.find(data, ('<article', '>', 'class-clip'))[1]
            if not tmp:
                return

            data = ph.find(data, ('<ul', '>', 'format-nav-list'),
                           '</ul>',
                           flags=0)[1]
            data = ph.findall(data, ('<a', '>'), '</a>', flags=ph.START_S)
            for idx in range(1, len(data), 2):
                url = self.getFullUrl(ph.getattr(data[idx - 1], 'href'))
                if '7tv.de' not in self.cm.getBaseUrl(url, True):
                    continue
                title = self.cleanHtmlStr(data[idx])
                self.addDir(
                    MergeDicts(
                        cItem, {
                            'good_for_fav': False,
                            'sub_menu_item': True,
                            'category': nextCategory,
                            'title': title,
                            'url': url
                        }))

            if len(self.currList) == 1 and self.currList[0]['type'] != 'video':
                item = self.currList.pop()
                self.listItems(item, 'explore_item')
Exemple #11
0
    def getLinksForVideo(self, cItem, source_id=None):
        linksTab = []

        if 'item_data' not in cItem:
            sts, data = self.getPage(cItem['url'])
            if not sts:
                return
            client_location = self.cm.meta['url']
            data = ph.find(data, 'var contentResources = [', '];', flags=0)[1]
            try:
                data = json_loads('[%s]' % data)[0]
            except Exception:
                pass
        else:
            client_location = cItem['url']
            data = cItem['item_data']

        try:
            drm = data.get('drm')
            if drm:
                SetIPTVPlayerLastHostError(_('Link protected with DRM.'))
            video_id = data['id']
        except Exception:
            printExc()
            return []

        #dashLinks = self.doGetLinks(video_id, client_location, 'application/dash+xml')
        try:
            for it in (False, True):
                hlsLinks = self.doGetLinks(video_id, client_location,
                                           'application/x-mpegURL', it)
                if hlsLinks:
                    linksTab.extend(
                        getDirectM3U8Playlist(hlsLinks[0]['url'],
                                              checkExt=True,
                                              checkContent=True,
                                              sortWithMaxBitrate=999999999))
                    break

            for it in (True, False):
                mp4Links = self.doGetLinks(video_id, client_location,
                                           'video/mp4', it)
                for item in mp4Links:
                    if item['mimetype'] == 'video/mp4':
                        linksTab.append({
                            'name':
                            '[MP4] bitrate: %s' % item['bitrate'],
                            'url':
                            item['url'],
                            'bitrate':
                            item['bitrate']
                        })
                if mp4Links:
                    break
            if not mp4Links and drm:
                return []
            linksTab.sort(reverse=True, key=lambda k: int(k['bitrate']))
        except Exception:
            printExc()

        return linksTab
Exemple #12
0
    def listItems(self, cItem, nextCategory):
        printDBG("FiliserTv.listItems")

        baseUrl = cItem['url']
        if '?' not in baseUrl:
            baseUrl += '?'
        else:
            baseUrl += '&'

        page = cItem.get('page', 1)
        if page > 1:
            baseUrl += 'page={0}&'.format(page)

        if cItem.get('genres', '') not in ['-', '']:
            baseUrl += 'kat={0}&'.format(urllib.quote(cItem['genres']))

        if cItem.get('language', '') not in ['-', '']:
            baseUrl += 'ver={0}&'.format(urllib.quote(cItem['language']))

        if cItem.get('year', '0') not in ['0', '-', '']:
            baseUrl += 'start_year={0}&end_year={1}&'.format(
                cItem['year'], cItem['year'])

        if cItem.get('sort_by', '0') not in ['0', '-', '']:
            baseUrl += 'sort_by={0}&'.format(urllib.quote(cItem['sort_by']))

        if cItem.get('order', '0') not in ['0', '-', '']:
            baseUrl += 'type={0}&'.format(urllib.quote(cItem['order']))

        sts, data = self.getPage(self.getFullUrl(baseUrl), self.defaultParams)
        if not sts: return

        if '>Następna<' in data:
            nextPage = True
        else:
            nextPage = False

        data = self.cm.ph.getAllItemsBeetwenMarkers(data,
                                                    '<section class="item"',
                                                    '</section>',
                                                    withMarkers=True)
        for item in data:
            url = self.getFullUrl(ph.search(item, ph.A)[1])
            icon = self.getFullIconUrl(ph.search(item, ph.IMG)[1].strip())
            title = ph.clean_html(ph.getattr(item, 'alt'))
            if title == '': title = ph.clean_html(ph.getattr(item, 'title'))
            title1 = ph.clean_html(
                ph.find(item, ('<h3', '>'), '</h3>', flags=0)[1])
            title2 = ph.clean_html(
                ph.find(item, ('<h4', '>'), '</h4>', flags=0)[1])

            desc = ph.clean_html(
                item.split('<div class="block2">')[-1].replace(
                    '<p class="desc">', '[/br]'))
            params = {
                'good_for_fav': True,
                'title': title,
                'url': url,
                'icon': icon,
                'desc': desc
            }
            if '/film/' in url:
                self.addVideo(params)
            elif '/serial/' in url:
                params['category'] = nextCategory
                self.addDir(params)

        if nextPage:
            params = dict(cItem)
            params.update({'title': _('Next page'), 'page': page + 1})
            self.addDir(params)
Exemple #13
0
    def getVideoLinks(self, baseUrl):
        printDBG('YifyTV.getVideoLinks [%s]' % baseUrl)
        if len(self.cacheLinks.keys()):
            for key in self.cacheLinks:
                for idx in range(len(self.cacheLinks[key])):
                    if baseUrl 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

        urlTab = []
        baseUrl = strwithmeta(baseUrl)
        imdbid = baseUrl.meta.get('imdbid', '')
        sub_tracks = baseUrl.meta.get('external_sub_tracks', [])
        header = dict(self.AJAX_HEADER)
        if 'sou' in baseUrl.meta:
            souTab = [baseUrl.meta['sou']]
            if souTab[0] == 'pic':
                souTab.append('adr')
            if souTab[0] == 'adr':
                souTab.append('pic')
            for sou in souTab:
                post_data = {'fv': '27', 'url': baseUrl, 'sou': sou}
                url = 'https://ymovies.tv/playerlite/pk/pk/plugins/player_p2.php'
                sts, data = self.getPage(url, {'header': header}, post_data)
                if not sts:
                    return []
                cUrl = self.cm.meta['url']
                printDBG(
                    '+++++++++++++++++++++++  data  ++++++++++++++++++++++++')
                printDBG(data)
                printDBG(
                    '+++++++++++++++++++++++++++++++++++++++++++++++++++++++')
                try:
                    attempt = 0
                    while attempt < 3:
                        attempt += 1
                        printDBG(data)
                        if 'jscode' in data:
                            try:
                                data = json_loads(data)[0]['jscode'][1:-1]
                                jsTab = ['']
                                jsTab.append(
                                    'var iptv_href="%s"; var iptv_domain="%s"; var iptv_video_id="%s"; var iptv_jwpath="%s";\n'
                                    % (self.getMainUrl(),
                                       self.up.getDomain(
                                           self.getMainUrl()), imdbid, url))
                                jsTab.append(
                                    base64.b64decode(
                                        'ZnVuY3Rpb24gU2hvd0Rpdigpe31mdW5jdGlvbiBzaG93aUZyYW1lKCl7cHJpbnQoYXJndW1lbnRzWzBdKX1mdW5jdGlvbiBnZXRKd1BhdGgoKXtyZXR1cm4gaXB0dl9qd3BhdGh9ZnVuY3Rpb24gZ2V0X3BhcmFtc19ub19zb3JjZXMoKXtyZXR1cm4gaXB0dl92aWRlb19pZH1mdW5jdGlvbiBzZXRUaW1lb3V0KHQsbil7aWYoaXB0dl9kaXJlY3QpdHJ5e3QoKX1jYXRjaChlKXtwcmludCgiXG4iKX1lbHNlIHRoaXMudHJ5dXAoKX12YXIgZG9jdW1lbnQ9e30sd2luZG93PXRoaXMsbG9jYXRpb249e307bG9jYXRpb24uaHJlZj1pcHR2X2hyZWYsbG9jYXRpb24uaG9zdG5hbWU9aXB0dl9kb21haW4sbG9jYXRpb24udG9TdHJpbmc9ZnVuY3Rpb24oKXtyZXR1cm4gaXB0dl9ocmVmfSxkb2N1bWVudC5sb2NhdGlvbj1sb2NhdGlvbjt2YXIgZWxlbWVudD1mdW5jdGlvbih0KXt0aGlzLnRleHQ9ZnVuY3Rpb24oKXtyZXR1cm4ibm9uZSJ9LHRoaXMuZmlyc3Q9ZnVuY3Rpb24oKXtyZXR1cm4gbmV3IGVsZW1lbnR9fSwkPWZ1bmN0aW9uKHQpe3JldHVybiBuZXcgZWxlbWVudCh0KX0scGxheWVybW9kZT0iIixzb3VyY2VTZWxlY3RlZD0wLHNvdXJjZXM9W3tzdWJfZGVsYXk6MCxzdWJfZmFjdG9yOjF9XTskLmdldD1mdW5jdGlvbigpe3JldHVybiBwcmludChhcmd1bWVudHNbMF0pLHtkb25lOlNob3dEaXYsZXJyb3I6U2hvd0Rpdn19LCQucG9zdD1mdW5jdGlvbigpe3ByaW50KCJcbklQVFZfUE9TVF9TVEFSVFxuIikscHJpbnQoSlNPTi5zdHJpbmdpZnkoe3VybDphcmd1bWVudHNbMF0scGFyYW1zOmFyZ3VtZW50c1sxXX0pKSxwcmludCgiXG5JUFRWX1BPU1RfRU5EXG4iKX07'
                                    ))
                                jsTab.append('var iptv_fun = %s; iptv_fun();' %
                                             data)
                                for iptv_direct in ['false', 'true']:
                                    jsTab[
                                        0] = 'var iptv_direct = %s;' % iptv_direct
                                    jscode = '\n'.join(jsTab)
                                    printDBG(
                                        '+++++++++++++++++++++++  CODE  ++++++++++++++++++++++++'
                                    )
                                    printDBG(jscode)
                                    printDBG(
                                        '+++++++++++++++++++++++++++++++++++++++++++++++++++++++'
                                    )
                                    ret = js_execute(jscode)
                                    if not ret['sts'] or 0 != ret['code']:
                                        ret = js_execute(
                                            jscode.replace('eval(', 'print('))
                                    if ret['sts'] and 0 == ret['code']:
                                        decoded = ret['data'].strip()
                                        printDBG('DECODED DATA -> [%s]' %
                                                 decoded)
                                        data = decoded
                                        break
                                if 'jscode' in data:
                                    data = data[data.
                                                find('['):data.rfind(']') + 1]
                                    data = json_loads('"%s"' % data)
                                    continue

                            except Exception:
                                printExc()

                            if 'IPTV_POST_START' in data:
                                data = self.cm.ph.getDataBeetwenMarkers(
                                    data, 'IPTV_POST_START', 'IPTV_POST_END',
                                    0)[1]
                                try:
                                    tmp = json_loads(data.strip())
                                    sts, data = self.getPage(
                                        tmp['url'], {
                                            'header': header,
                                            'raw_post_data': True
                                        }, tmp['params'])
                                    if not sts:
                                        return []
                                    tmp = json_loads(data)
                                    for hostDomain in tmp['hosts']:
                                        urlTab.append({
                                            'name':
                                            hostDomain,
                                            'url':
                                            'http://%s%s' %
                                            (hostDomain, tmp['path'])
                                        })
                                    if len(urlTab):
                                        break
                                except Exception:
                                    printExc()

                            g3 = self.cm.ph.getSearchGroups(
                                data + '&', '[&\\?]g3=([^&]+?)&')[0]
                            emb = self.cm.ph.getSearchGroups(
                                data + '&', '[&\\?]emb=([^&^\\*]+?)[&\\*]')[0]
                            if emb != '':
                                data = urllib.unquote(emb)
                            if g3 != '':
                                post_data = {
                                    'fv': '0',
                                    'g3': urllib.unquote(g3)
                                }
                                url = 'https://ymovies.tv/playerlite/pk/pk/plugins/player_g3.php'
                                sts, data = self.getPage(
                                    url, {'header': header}, post_data)
                                if not sts:
                                    return []
                                printDBG(data)
                            elif self.cm.isValidUrl(
                                    data) and 1 == self.up.checkHostSupport(
                                        data):
                                urlTab = self.up.getVideoLinkExt(data)
                                break
                            else:
                                if 'showiFrame(' in data:
                                    if 'emb=' in data:
                                        url = urllib.unquote(
                                            ph.find(data,
                                                    "emb='+'",
                                                    "'",
                                                    flags=0)[1])
                                        tmp = url.split('sub.file', 1)
                                        url = tmp[0]
                                        subTrack = urllib.unquote(
                                            tmp[1]) if len(tmp) == 2 else ''
                                    else:
                                        subTrack = ''
                                        url = ph.find(data,
                                                      'showiFrame(',
                                                      ')',
                                                      flags=0)[1].strip()[1:-1]
                                    url = self.getFullUrl(url, cUrl)
                                    subTrack = self.getFullUrl(subTrack, cUrl)
                                    tmpUrlTab = self.up.getVideoLinkExt(url)
                                    if subTrack and tmpUrlTab:
                                        format = subTrack[-3:]
                                        for idx in range(len(tmpUrlTab)):
                                            tmpUrlTab[idx][
                                                'url'] = strwithmeta(
                                                    tmpUrlTab[idx]['url'], {
                                                        'external_sub_tracks':
                                                        [{
                                                            'title': '',
                                                            'url': subTrack,
                                                            'lang': 'en',
                                                            'format': format
                                                        }]
                                                    })
                                    urlTab.extend(tmpUrlTab)
                                    printDBG(urlTab)
                                    break

                                if 'sources[sourceSelected]["paramId"]' in data:
                                    data = data.replace('"+"',
                                                        '').replace(' ', '')
                                    paramSite = self.cm.ph.getSearchGroups(
                                        data,
                                        'sources\\[sourceSelected\\]\\["paramSite"\\]="([^"]+?)"'
                                    )[0]
                                    data = self.cm.ph.getSearchGroups(
                                        data,
                                        'sources\\[sourceSelected\\]\\["paramId"\\]="([^"]+?)"'
                                    )[0]
                                    printDBG(
                                        'data ------------------------- [%s]' %
                                        data)
                                    if data.startswith('enc'):
                                        encrypted = base64.b64decode(data[3:])
                                        key = unhexlify(
                                            base64.b64decode(
                                                'MzAzOTM4NzMzOTM3MzU0MTMxMzIzMzczMzEzMzM1NjQ2NDY2Njc3NzQ4MzczODM0MzczNTMzMzQzNjcyNjQ3Nw=='
                                            ))
                                        iv = unhexlify(
                                            base64.b64decode(
                                                'NWE0MTRlMzEzNjMzNjk2NDZhNGM1MzUxMzU0YzY0MzU='
                                            ))
                                        cipher = AES_CBC(key=key,
                                                         padding=noPadding(),
                                                         keySize=32)
                                        data = cipher.decrypt(
                                            encrypted, iv).split('\x00')[0]
                                        if 'ucl' == paramSite:
                                            urlTab.extend(
                                                self.up.getVideoLinkExt(
                                                    'https://userscloud.com/embed-'
                                                    + data + '-1280x534.html'))
                                        elif 'tus' == paramSite:
                                            urlTab.extend(
                                                self.up.getVideoLinkExt(
                                                    'https://tusfiles.net/embed-'
                                                    + data +
                                                    '-1280x534.html?v=34'))
                                        elif 'up' == paramSite:
                                            urlTab.extend(
                                                self.up.getVideoLinkExt(
                                                    'http://uptobox.com/' +
                                                    data))
                                        break
                        if '("' in data:
                            data = self.cm.ph.getDataBeetwenMarkers(
                                data, '(', ')', False)[1]
                            data = json_loads(data)
                        if isinstance(data, basestring):
                            data = json_loads(data)
                        printDBG(data)
                        for item in data:
                            if (item.get('type', '').startswith('video/')
                                    or item.get('type', '').startswith(
                                        'application/x-shockwave-flash')
                                ) and self.cm.isValidUrl(item.get('url', '')):
                                urlTab.append({
                                    'name':
                                    '{0}x{1}'.format(item.get('height', ''),
                                                     item.get('width', '')),
                                    'url':
                                    item['url'],
                                    'need_resolve':
                                    0
                                })
                    break
                except Exception:
                    SetIPTVPlayerLastHostError(
                        'The Mirror is broken.\nIf available you can choose other source.'
                    )
                    printExc()
                    return []

                if len(urlTab):
                    break

        elif self.cm.isValidUrl(baseUrl):
            urlTab = self.up.getVideoLinkExt(baseUrl)
        printDBG('>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>')
        printDBG(urlTab)
        for idx in range(len(urlTab)):
            subs = list(
                strwithmeta(urlTab[idx]['url']).meta.get(
                    'external_sub_tracks', []))
            subs.extend(sub_tracks)
            urlTab[idx]['url'] = strwithmeta(urlTab[idx]['url'],
                                             {'external_sub_tracks': subs})

        printDBG('>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>')
        printDBG(urlTab)
        return urlTab
    def listItems(self, cItem):
        printDBG("..:: E2iStream ::.. -  listItems(self, cItem): [%s]" % cItem)
        i = 0

        page = cItem.get('page', 1)

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

        nextPage = self.cm.ph.getDataBeetwenNodes(
            data, ('<div class=', '>', 'paging paging--right paging--padding'),
            ('</div', '>'))[1]
        nextPage = self.cm.ph.getSearchGroups(
            nextPage,
            '''<a[^>]+?href=['"]([^'^"]+?)['"][^>]*?>%s</a>''' % (page + 1))[0]
        nextPage = ph.clean_html(nextPage)

        block = self.cm.ph.getAllItemsBeetwenNodes(
            data, ('<a class="', '>', 'dashboard-item dashboard-item--video'),
            ('</a', '>'))

        while i < len(block):
            desc = []
            title = self.cm.ph.getAllItemsBeetwenNodes(
                block[i], ('<div class="', '>', 'dashboard-item__title'),
                ('</div', '>'), False)
            title = map(
                lambda cleanTitle: cleanTitle.replace(
                    '\r\n                    ', ''), title)
            title = map(
                lambda cleanTitle: cleanTitle.replace('\r\n                ',
                                                      ''), title)
            title = title[0]
            title = ph.clean_html(title)
            videourl = ph.find(block[i], 'href="/video', '"', False)[1]
            videourl = self.MAIN_URL + 'video' + videourl
            imageurl = self.cm.ph.getAllItemsBeetwenNodes(
                block[i], 'style="background-image: url(\'', ('\');">'),
                False)[1]
            vidviews = self.cm.ph.getAllItemsBeetwenNodes(
                block[i], ('<div class="', '>', 'dashboard-item__views'),
                ('</div', '>'), False)
            vidviews = map(
                lambda cleanTitle: cleanTitle.replace(
                    '\r\n                        ', ''), vidviews)
            vidviews = map(
                lambda cleanTitle: cleanTitle.replace('\r\n                ',
                                                      ''), vidviews)
            vidviews = vidviews[0]
            numstars = self.cm.ph.getAllItemsBeetwenNodes(
                block[i], ('<li><i class=\'', '>', 'icon icon-star blank'),
                ('\'></i></li>'), False)
            numstars = len(numstars)
            desc.append('%s Rated %s/%s' % (vidviews, 5 - numstars, 5))
            desc = [' | '.join(desc)]
            params = dict(cItem)
            params.update({
                'good_for_fav': True,
                'title': title,
                'url': videourl,
                'icon': imageurl,
                'desc': '[/br]'.join(desc)
            })
            self.addVideo(params)
            i += 1

        if nextPage:
            params = dict(cItem)
            params.update({
                'good_for_fav': False,
                'title': _("Next page"),
                'page': page + 1,
                'url': self.getFullUrl(nextPage)
            })
            self.addDir(params)
Exemple #15
0
    def listVodFilters(self, cItem, nextCategory):
        printDBG("EskaGo.listVodFilters")
        url = cItem['url'].replace('/vod/', '/ajax/vod/')
        sts, data = self.cm.getPage(url)
        if not sts: return

        idx = cItem.get('f_idx', 0)

        if idx == 0:
            tmp = ph.find(data, ('<ul', '>', 'cat-box'),
                          ('<div', '>', 'clear'),
                          flags=0)[1].split('</ul>')
            for sData in tmp:
                subItems = []
                sTitle = self.cleanHtmlStr(
                    ph.find(sData, '<span', '</span>')[1])
                if sTitle == '':
                    if len(self.currList):
                        sTitle = self.currList[-1]['title']
                        subItems = self.currList[-1]['sub_items']
                        del self.currList[-1]
                    else:
                        continue

                sData = ph.findall(sData, '<a', '</a>')
                for item in sData:
                    url = self.cm.getFullUrl(
                        ph.search(item, ph.A_HREF_URI_RE)[1],
                        self.cm.meta['url'])
                    icon = self.cm.getFullUrl(
                        ph.search(item, ph.IMAGE_SRC_URI_RE)[1],
                        self.cm.meta['url'])
                    title = self.cleanHtmlStr(item)
                    subItems.append(
                        MergeDicts(
                            cItem, {
                                'url': url,
                                'title': title,
                                'icon': icon,
                                'f_idx': idx + 1
                            }))
                if len(subItems):
                    self.addDir(
                        MergeDicts(
                            cItem, {
                                'category': 'sub_items',
                                'title': sTitle,
                                'sub_items': subItems
                            }))
            if len(self.currList) == 1:
                self.currList = self.currList[0]['sub_items']
            if len(self.currList):
                self.currList.insert(
                    0,
                    MergeDicts(cItem, {
                        'title': _('--All--'),
                        'f_idx': idx + 1
                    }))
            else:
                idx = 1

        if idx == 1:
            sData = ph.find(data, ('<div', '>', 'sort'), '</ul>', flags=0)[1]
            sData = ph.findall(sData, '<a', '</a>')
            for item in sData:
                url = ph.search(item, ph.A_HREF_URI_RE)[1]
                if url == '' or 'javascript' in url:
                    continue
                url = self.cm.getFullUrl(url, self.cm.meta['url'])
                title = self.cleanHtmlStr(item)
                self.addDir(
                    MergeDicts(cItem, {
                        'title': title,
                        'url': url,
                        'f_idx': idx + 1
                    }))
        elif idx == 2:
            sData = ph.find(data, ('<div', '>', 'sort'),
                            ('<div', '>', 'clear'),
                            flags=0)[1]
            sData = ph.find(sData, '</ul>', ('<div', '>'), flags=0)[1]
            sData = ph.findall(sData, '<a', '</a>')
            for item in sData:
                url = self.cm.getFullUrl(
                    ph.search(item, ph.A_HREF_URI_RE)[1], self.cm.meta['url'])
                title = self.cleanHtmlStr(item)
                self.addDir(
                    MergeDicts(cItem, {
                        'category': nextCategory,
                        'title': title,
                        'url': url
                    }))
Exemple #16
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
Exemple #17
0
    def listVodItems(self, cItem, nextCategory):
        printDBG("EskaGo.listVodItems")
        page = cItem.get('page', 1)
        url = cItem['url'].replace('/vod/', '/ajax/vod/')
        sts, data = self.cm.getPage(url)
        if not sts: return

        nextPage = ph.find(data, ('<div', '>', 'pagination'),
                           '</div>',
                           flags=0)[1]
        nextPage = self.cm.getFullUrl(
            ph.search(
                nextPage, r'''<a[^>]+?href=(['"])([^>]*?)(?:\1)[^>]*?>%s<''' %
                (page + 1))[1], self.cm.meta['url'])

        if '/filmy' in url:
            reIcon = re.compile(
                r'''<img[^>]+?data\-src=(['"])([^>]*?\.(?:jpe?g|png)(?:\?[^\1]*?)?)(?:\1)''',
                re.I)
            data = ph.findall(data, ('<div', '>', 'tooltip'), '</li>')
            for item in data:
                url = ph.find(item, ('<div', '>', 'box-tv-slide'),
                              '</div>',
                              flags=0)[1]
                url = self.cm.getFullUrl(
                    ph.search(url, ph.A_HREF_URI_RE)[1], self.cm.meta['url'])
                icon = self.cm.getFullUrl(
                    ph.search(item, reIcon)[1], self.cm.meta['url'])
                title = self.cleanHtmlStr(
                    ph.find(item, ('<h', '>'), ('</h', '>'), flags=0)[1])
                desc = []
                desc.append(
                    self.cleanHtmlStr(
                        ph.find(item, ('<span', '>', 'cat-date'),
                                '</span>',
                                flags=0)[1]))
                desc.append(
                    self.cleanHtmlStr(
                        ph.find(item, ('<span', '>', 'cat-time'),
                                '</span>',
                                flags=0)[1]))
                desc = ' | '.join(desc) + '[/br]' + self.cleanHtmlStr(
                    ph.find(item,
                            ('<p', '>', 'opis-view'), '</p>', flags=0)[1])
                self.addDir(
                    MergeDicts(
                        cItem, {
                            'good_for_fav': True,
                            'category': nextCategory,
                            'title': title,
                            'url': url,
                            'icon': icon,
                            'desc': desc
                        }))
        else:
            data = ph.findall(data, ('<div', '>', 'slider-section'),
                              ('<div', '>', '_slide'),
                              flags=0)
            for item in data:
                url = self.cm.getFullUrl(
                    ph.search(item, ph.A_HREF_URI_RE)[1], self.cm.meta['url'])
                icon = self.cm.getFullUrl(
                    ph.search(item, ph.IMAGE_SRC_URI_RE)[1],
                    self.cm.meta['url'])
                title = self.cleanHtmlStr(
                    ph.find(item, ('<h', '>'), ('</h', '>'), flags=0)[1])
                desc = self.cleanHtmlStr(ph.find(item, '<p', '</p>')[1])
                self.addDir(
                    MergeDicts(
                        cItem, {
                            'good_for_fav': True,
                            'category': nextCategory,
                            'title': title,
                            'url': url,
                            'icon': icon,
                            'desc': desc
                        }))

        if nextPage:
            self.addDir(
                MergeDicts(cItem, {
                    'title': _('Next page'),
                    'url': nextPage,
                    'page': page + 1
                }))
    def exploreItem(self, cItem):
        printDBG("Christusvincit.exploreItem")
        playerConfig = None

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

            if 'articles.php' in cUrl:
                iframe = ph.search(data, ph.IFRAME_SRC_URI_RE)[1]
                if not iframe:
                    iframe = ph.find(data,
                                     ('<script', '>', 'embedIframeJs'))[1]
                    iframe = ph.getattr(iframe, 'src')

                if iframe and '?' in iframe:
                    sts, tmp = self.getPage(
                        self.getFullUrl(
                            iframe.replace('?', '?iframeembed=true&')))
                    if not sts:
                        return
                    playerConfig = ph.find(tmp, '{"playerConfig"',
                                           '};')[1][:-1]
                else:
                    sections = ph.find(data, '<noscript', 'scapmain-left')[1]
                    sections = ph.rfindall(sections,
                                           '</table>',
                                           ('<td', '>', 'capmain-left'),
                                           flags=0)
                    for section in sections:
                        self.handleSection(cItem, cItem['category'], section)
            else:
                playerConfig = ph.find(data, '{"playerConfig"', '};')[1][:-1]

            if playerConfig:
                try:
                    playerConfig = json_loads(playerConfig)
                    playlistResult = playerConfig.get('playlistResult', {})
                    if not playlistResult:
                        playlistResult['0'] = {
                            'items': [playerConfig['entryResult']['meta']]
                        }
                    for key, section in playlistResult.iteritems():
                        for item in section['items']:
                            icon = self.getFullUrl(item['thumbnailUrl'])
                            title = item['name']
                            desc = '%s | %s' % (str(
                                timedelta(seconds=item['duration'])),
                                                item['description'])
                            params = {
                                'title': title,
                                'icon': icon,
                                'desc': desc,
                                'f_id': item['id']
                            }
                            if item.get('hlsStreamUrl'):
                                params['url'] = item['hlsStreamUrl']
                            self.addVideo(params)
                except Exception:
                    printExc()

        rtmpItem = dict(cItem).pop('rtmp_item', None)
        if rtmpItem:
            self.addVideo(rtmpItem)
    def listItems(self, cItem, nextCategory):
        printDBG('FilmstreamvkCom.listItems')
        page = cItem.get('page', 1)
        sts, data = self.getPage(cItem['url'])
        if not sts:
            return
        cUrl = self.cm.meta['url']
        nextPage = ph.find(data, 'pagenavi', '</div>', flags=0)[1]
        nextPage = ph.rfind(data, '>%s</a>' % (page + 1), '<a ')[1]
        nextPage = self.getFullUrl(ph.search(nextPage, ph.A)[1])
        data = ph.findall(data, ('<div', '>', 'movie-preview'),
                          ('<div', '>', 'clear'))
        for sItem in data:
            sItem = ph.rfindall(sItem,
                                '</div>', ('<div', '>', 'movie-preview'),
                                flags=0)
            for item in sItem:
                url = self.getFullUrl(ph.search(item, ph.A)[1])
                icon = self.getFullIconUrl(ph.search(item, ph.IMG)[1])
                title = ph.clean_html(
                    ph.find(item, ('<span', '>', 'movie-title'),
                            '</span>',
                            flags=0)[1])
                tmp = ph.clean_html(
                    ph.find(item, ('<span', '>', 'movie-release'),
                            '</span>',
                            flags=0)[1])
                if tmp:
                    title = '%s (%s)' % (title, tmp)
                tmp = ph.findall(item, ('<p', '>'), '</p>', flags=0)
                desc = []
                for t in tmp:
                    t = ph.clean_html(t)
                    if t:
                        desc.append(t)

                tmp = ph.clean_html(
                    ph.find(item, ('<div', '>', 'movie-info'),
                            '</div>',
                            flags=0)[1])
                if tmp:
                    desc.append(tmp)
                params = MergeDicts(
                    cItem, {
                        'category': nextCategory,
                        'url': url,
                        'title': title,
                        'icon': icon,
                        'desc': '[/br]'.join(desc)
                    })
                if 'saison-' in url or '/manga/' in url or '/serie/' in url:
                    season = ph.search(url + '-', 'aison-([0-9]+?)-')[0]
                    params['season'] = season
                    self.addDir(params)
                else:
                    self.addVideo(params)

        if nextPage:
            params = dict(cItem)
            params.update({
                'title': _('Next page'),
                'url': nextPage,
                'page': page + 1
            })
            self.addDir(params)
    def listItems(self, cItem, nextCategory):
        printDBG("HD1080Online.listItems")
        page = cItem.get('page', 1)

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

        nextPage = ph.find(data, ('<span', '>', 'pnext'), '</span>',
                           flags=0)[1]
        nextPage = self.getFullUrl(ph.search(nextPage, ph.A)[1])

        data = ph.find(data, ('<div', '>', 'dle-content'), ('<aside', '>'))[1]
        data = ph.rfindall(data, '</div>', ('<div', '>', 'kino-item'))
        if data and nextPage:
            data[-1] = ph.find(data[-1], '<div', ('<div', '>', 'pagi-nav'))[1]

        for item in data:
            url = self.getFullUrl(ph.search(item, ph.A)[1])
            icon = self.getFullIconUrl(ph.search(item, ph.IMG)[1])
            title = self.cleanHtmlStr(
                ph.find(item, ('<div', '>', 'title'), '</div>', flags=0)[1])

            desc = []
            tmp = ph.find(item, ('<ul', '>', 'lines'), '<ul', flags=0)[1]
            tmp = ph.findall(tmp, ('<li', '>'), '</li>', flags=0)
            for t in tmp:
                t = ph.clean_html(t)
                if t: desc.append(t)

            # rating
            desc.append(
                ph.clean_html(
                    ph.rfind(item, ('<div', '>', 'ratig-layer'), ('<b', '>'),
                             flags=0)[1]))
            t = ph.clean_html(
                ph.find(item, ('<li', '>', 'current-rating'), '</li>',
                        flags=0)[1])
            if t.isdigit(): desc[-1] += ' %s/10' % str(int(t) / 10.0)

            desc.append(
                ph.clean_html(
                    ph.find(item, ('<div', '>', 'desc'), '</div>',
                            flags=0)[1]))
            self.addDir(
                MergeDicts(
                    cItem, {
                        'good_for_fav': True,
                        'category': nextCategory,
                        'title': title,
                        'url': url,
                        'icon': icon,
                        'desc': '[/br]'.join(desc)
                    }))

        if nextPage:
            self.addDir(
                MergeDicts(
                    cItem, {
                        'good_for_fav': False,
                        'title': _('Next page'),
                        'url': nextPage,
                        'page': page + 1
                    }))
Exemple #21
0
    def showProgram(self, cItem, pagenum=0):
        printDBG('La7 - start ondemand single program list')
        url = self.getFullUrl(cItem["url"] + "/rivedila7")

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

        if pagenum == 0:
            # last episode
            t, replica = ph.find(
                html,
                "<div class=\"ultima_puntata\">",
                "</div>\r\n                                    </div>",
                flags=0)
            if replica:
                icon = re.findall("background-image=\"(.*?)\"", replica)[0]
                url = re.findall("<a href=\"(.*?)\"", replica)[0]
                t, title = ph.find(replica,
                                   "<div class=\"title_puntata\">",
                                   "</div>",
                                   flags=0)
                t, data = ph.find(replica,
                                  "<div class=\"scritta_ultima\">",
                                  "</div>",
                                  flags=0)
                data = self.cleanHtmlStr(data)
                t, desc = ph.find(replica,
                                  "<div class=\"occhiello\">",
                                  "</div>",
                                  flags=0)

                title = title + " (" + data + ")"
                title = HTMLParser.HTMLParser().unescape(title).encode('utf-8')
                desc = HTMLParser.HTMLParser().unescape(desc).encode('utf-8')
                self.addVideo(
                    MergeDicts(
                        cItem, {
                            'category': 'epg_item',
                            'title': title,
                            'url': url,
                            'icon': icon,
                            'desc': desc
                        }))
            else:
                printDBG(
                    "la7 - no last episode video box for program '{0}'".format(
                        cItem["title"]))

            # last week episodes
            t, settimana = ph.find(html,
                                   "> LA SETTIMANA <",
                                   "Puntate Cult",
                                   flags=0)
            if not settimana:
                t, settimana = ph.find(html,
                                       "> LA SETTIMANA <",
                                       "</body>",
                                       flags=0)
            if settimana:
                episodi = re.findall(
                    "<a.*href=\"(.*?)\">\r\n.*<div class=\"holder-bg\">\r\n.*<div.*-image=\"(.*?)\"((.|\n)*?)</a>",
                    settimana)

                for r in episodi:
                    url = r[0]
                    icon = self.getFullUrl(r[1])
                    t, title = ph.find(r[2],
                                       "<div class=\"title\">",
                                       "</div>",
                                       flags=0)
                    if title:
                        title = self.cleanHtmlStr(title)
                    t, data = ph.find(r[2],
                                      "<div class=\"data\">",
                                      "</div>",
                                      flags=0)
                    if data:
                        title = title + " (" + data + ")"
                    title = HTMLParser.HTMLParser().unescape(title).encode(
                        'utf-8')
                    self.addVideo(
                        MergeDicts(
                            cItem, {
                                'category': 'epg_item',
                                'title': title,
                                'url': url,
                                'icon': icon
                            }))
            else:
                printDBG(
                    "la7 - error searching last week episodes for program '{0}'"
                    .format(cItem["title"]))

        # older episodes
        url = self.getFullUrl(cItem["url"] +
                              "/rivedila7/?page={0}".format(pagenum))

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

        t, finale = ph.find(html, "Puntate Cult", "</body>", flags=0)
        repliche = re.findall(
            "<a.*href=\"(.*?)\">\r\n.*<div class=\"holder-bg\">\r\n.*<div.*-image=\"(.*?)\"((.|\n)*?)</a>",
            finale)

        for r in repliche:
            url = r[0]
            icon = self.getFullUrl(r[1])
            t, title = ph.find(r[2],
                               "<div class=\"title\">",
                               "</div>",
                               flags=0)
            if title:
                title = self.cleanHtmlStr(title)
            t, data = ph.find(r[2], "<div class=\"data\">", "</div>", flags=0)
            if data:
                title = title + " (" + data + ")"
            title = HTMLParser.HTMLParser().unescape(title).encode('utf-8')
            self.addVideo(
                MergeDicts(
                    cItem, {
                        'category': 'epg_item',
                        'title': title,
                        'url': url,
                        'icon': icon
                    }))

        # look for next button in page
        if html.find("<li class=\"pager-next\">") != -1:
            pagenum = pagenum + 1
            self.addMore(
                MergeDicts(
                    cItem, {
                        'category': 'program_next',
                        'title': _('Next page'),
                        'page_number': pagenum
                    }))
    def exploreItem(self, cItem, nextCategory):
        printDBG("HD1080Online.exploreItem")
        self.cacheLinks = {}

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

        desc = []
        descObj = self.getArticleContent(cItem, data)[0]
        icon = descObj['images'][0]['url']
        baseTitle = descObj['title']
        for item in descObj['other_info']['custom_items_list']:
            desc.append(item[1])
        desc = ' | '.join(desc) + '[/br]' + descObj['text']

        data = ph.find(data, ('<div', '>', 'player-section'),
                       ('<div', '>', 'ratig'),
                       flags=0)[1]
        printDBG(data)
        titles = []
        tmp = ph.findall(data, ('<li', '>'), '</li>', flags=0)
        for t in tmp:
            titles.append(ph.clean_html(t))

        data = ph.findall(data, ('<div', '>', 'player-box'), '</div>', flags=0)

        for idx, item in enumerate(data):
            url = self.getFullUrl(ph.search(item, ph.IFRAME)[1])
            if not url: continue
            title = baseTitle
            if idx < len(titles): title += ' - ' + titles[idx]

            if ('/video/' in url and '/serials/' in url) or 'playlist' in url:
                url = strwithmeta(url, {'Referer': cUrl})
                seasons = self.hdgocc.getSeasonsList(url)
                for item in seasons:
                    self.addDir(
                        MergeDicts(
                            cItem, {
                                'good_for_fav': False,
                                'prev_url': cUrl,
                                'category': nextCategory,
                                'serie_title': baseTitle,
                                'title': _('Season %s') % item['title'],
                                'season_id': item['id'],
                                'url': item['url'],
                                'icon': icon,
                                'desc': desc
                            }))

                if 0 == len(seasons):
                    seasonUrl = url
                    episodes = self.hdgocc.getEpiodesList(seasonUrl, -1)
                    for item in episodes:
                        title = '{0} - {1} - s01e{2} '.format(
                            baseTitle, item['title'],
                            str(item['id']).zfill(2))
                        self.addVideo({
                            'good_for_fav': False,
                            'type': 'video',
                            'prev_url': cUrl,
                            'title': title,
                            'url': item['url'],
                            'icon': icon,
                            'desc': desc
                        })
            elif '/video/' in url:
                self.addVideo({
                    'good_for_fav': False,
                    'prev_url': cUrl,
                    'title': title,
                    'url': url,
                    'icon': icon,
                    'desc': desc
                })
            else:  # trailes ??
                self.addVideo({
                    'good_for_fav': False,
                    'prev_url': cUrl,
                    'title': title,
                    'url': url,
                    'icon': icon,
                    'desc': desc
                })
Exemple #23
0
    def listTgr(self, cItem):
        printDBG("Raiplay. start tgr list")
        if cItem["category"] != "tgr-root":
            url = cItem["url"]
        else:
            url = self.TG_URL

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

        # search for dirs
        items = ph.findall(data,
                           '<item behaviour="region">',
                           '</item>',
                           flags=0)
        items.extend(
            ph.findall(data, '<item behaviour="list">', '</item>', flags=0))

        for item in items:
            r_title = ph.find(item, '<label>', '</label>', flags=0)
            r_url = ph.find(item, '<url type="list">', '</url>', flags=0)
            r_image = ph.find(item, '<url type="image">', '</url>', flags=0)
            if r_title[0] and r_url[0]:
                if r_image[0]:
                    icon = self.MAIN_URL + r_image[1]
                else:
                    icon = self.NOTHUMB_URL

                title = r_title[1]
                url = self.MAIN_URL + r_url[1]
                self.addDir(
                    MergeDicts(
                        cItem, {
                            'category': 'tgr',
                            'title': title,
                            'url': url,
                            'icon': icon
                        }))

        # search for video links
        items = ph.findall(data,
                           '<item behaviour="video">',
                           '</item>',
                           flags=0)
        for item in items:
            r_title = ph.find(item, '<label>', '</label>', flags=0)
            r_url = ph.find(item, '<url type="video">', '</url>', flags=0)
            r_image = ph.find(item, '<url type="image">', '</url>', flags=0)
            if r_title[0] and r_url[0]:
                if r_image[0]:
                    icon = self.MAIN_URL + r_image[1]
                else:
                    icon = self.NOTHUMB_URL

                title = r_title[1]
                videoUrl = r_url[1]
                params = {
                    'title': title,
                    'url': videoUrl,
                    'icon': icon,
                    'category': 'video_link'
                }
                printDBG("add video '%s' with pathId '%s'" % (title, videoUrl))
                self.addVideo(params)
    def exploreItem(self, cItem):
        printDBG('Filma24IO.exploreItem')
        self.cacheLinks = {}
        sts, data = self.getPage(cItem['url'])
        if not sts:
            return
        cUrl = self.cm.meta['url']
        self.setMainUrl(cUrl)
        desc = []
        try:
            descObj = self.getArticleContent(cItem, data)[0]
            for item in descObj['other_info']['custom_items_list']:
                desc.append(item[1])

            desc = ' | '.join(desc) + '[/br]' + descObj['text']
        except Exception:
            printExc()

        trailerUrl = ph.find(data, ('<div', '>', 'trailer-player'),
                             '</div>',
                             flags=0)[1]
        trailerUrl = self.getFullUrl(ph.search(trailerUrl, ph.IFRAME)[1])
        if trailerUrl:
            trailerUrl = strwithmeta(trailerUrl, {'Referer': cItem['url']})
            params = {
                'good_for_fav': False,
                'title': '%s - %s' % (cItem['title'], _('trailer')),
                'url': trailerUrl,
                'trailer': True,
                'desc': desc,
                'prev_url': cItem['url']
            }
            self.addVideo(MergeDicts(cItem, params))
        self.cacheLinks[cUrl] = []
        tmp = ph.findall(data, ('<ul', '>', 'w-links'), '</ul>', flags=0)
        for tmpItem in tmp:
            tmpItem = ph.findall(tmpItem, ('<a', '>'),
                                 '</a>',
                                 flags=ph.START_S)
            for idx in range(1, len(tmpItem), 2):
                name = ph.clean_html(tmpItem[idx])
                url = self.getFullUrl(ph.getattr(tmpItem[idx - 1], 'href'))
                self.cacheLinks[cUrl].append({
                    'name': name,
                    'url': url,
                    'need_resolve': 1
                })

        tmp = ph.find(data, ('<div', '>', 'movie-player'), '</div>',
                      flags=0)[1]
        url = self.getFullUrl(ph.search(tmp, ph.IFRAME)[1])
        if url:
            self.cacheLinks[cUrl].insert(
                0, {
                    'name': self.cm.getBaseUrl(url, True).upper(),
                    'url': url,
                    'need_resolve': 1
                })
        if len(self.cacheLinks[cUrl]):
            self.addVideo(
                MergeDicts(
                    cItem, {
                        'good_for_fav': False,
                        'url': cUrl,
                        'desc': desc,
                        'prev_url': cItem['url']
                    }))
 def listEpisodes(self, cItem):
     sts, data = self.cm.getPage(cItem['url'], self.defaultParams)
     if not sts: return
     tmpurl = cItem['url']
     # if we are not already viewing all we need to grab the url and load it up.
     hadViewAll = False
     viewAllUrl = ph.rfind(data,
                           '>View all',
                           '<a',
                           flags=ph.I | ph.START_E | ph.END_E)[1]
     viewAllUrl = self.getFullUrl(
         ph.search(viewAllUrl, ph.A)[1], self.cm.meta['url'])
     if viewAllUrl:
         sts, data = self.cm.getPage(viewAllUrl, self.defaultParams)
         if not sts: return
         tmpurl = viewAllUrl
         hadViewAll = True
     nextPage = ph.find(data, ('<a', '>', 'Next Page'))[1]
     nextPage = self.getFullUrl(ph.search(nextPage, ph.A)[1], tmpurl)
     if 'class="button series-nav__button series-nav__button' in data:
         # we have a season navigation
         block = self.cm.ph.getAllItemsBeetwenNodes(
             data, 'class="button series-nav__button series-nav__button',
             ('</li>'))
         for series in block:
             seriesTitle = self.cm.ph.getAllItemsBeetwenNodes(
                 series,
                 '<span class="button__text typo typo--bullfinch typo--bold">',
                 '</span>', False)[0]
             self.addMarker({
                 'title': '\c0000??00' + seriesTitle,
                 'desc': seriesTitle
             })
             seriesUrl = self.cm.ph.getSearchGroups(series,
                                                    'href="([^"]+?)"')[0]
             if seriesUrl == '':
                 seriesUrl = tmpurl  # add landing url (season 1)
             else:
                 seriesUrl = self.MAIN_URL + seriesUrl[:0] + seriesUrl[1:]
             icon = ph.search(series, self.reSrcset)[0]
             # get the page as per the url, read the episodes.
             sts, data = self.cm.getPage(seriesUrl, self.defaultParams)
             if not sts: return
             episodes = self.cm.ph.getAllItemsBeetwenNodes(
                 data, '<ul class="gel-layout">', '</ul>')[0]
             episodes = self.cm.ph.getAllItemsBeetwenNodes(
                 episodes, '<li class="grid__item', '</li>')
             for episode in episodes:
                 tmpTitle = self.cleanHtmlStr(
                     self.cm.ph.getAllItemsBeetwenNodes(
                         episode,
                         '<div class="content-item__title typo typo--skylark typo--bold">',
                         '</div>', False)[0])
                 title = '%s - %s' % (cItem['title'], tmpTitle)
                 videoUrl = self.cm.ph.getSearchGroups(
                     episode, 'href="([^"]+?)"')[0]
                 videoUrl = self.MAIN_URL + videoUrl[:0] + videoUrl[1:]
                 desc = self.cm.ph.getAllItemsBeetwenNodes(
                     episode,
                     '<div class="content-item__description typo typo--bullfinch">',
                     '<', False)[0] + '...'
                 desc = '\c00????00Description: \c00??????' + desc
                 params = MergeDicts(
                     cItem, {
                         'good_for_fav': True,
                         'title': ph.clean_html(title),
                         'url': videoUrl,
                         'desc': desc,
                         'icon': self.getFullIconUrl(icon)
                     })
                 self.addVideo(params)
     elif '/episodes/' in tmpurl and hadViewAll:
         episodes = self.cm.ph.getAllItemsBeetwenNodes(
             data, '<ul class="gel-layout">', '</ul>')[0]
         episodes = self.cm.ph.getAllItemsBeetwenNodes(
             episodes, '<li class="grid__item', '</li>')
         seriesTitle = self.cm.ph.getAllItemsBeetwenNodes(
             data,
             '<h1 class="hero-header__title typo typo--bold typo--buzzard">',
             '</h1>', False)[0]
         icon = ph.search(data, self.reSrcset)[0]
         for episode in episodes:
             tmpTitle = self.cleanHtmlStr(
                 self.cm.ph.getAllItemsBeetwenNodes(
                     episode,
                     '<div class="content-item__title typo typo--skylark typo--bold">',
                     '</div>', False)[0])
             title = '%s - %s' % (seriesTitle, tmpTitle)
             videoUrl = self.cm.ph.getSearchGroups(episode,
                                                   'href="([^"]+?)"')[0]
             videoUrl = self.MAIN_URL + videoUrl[:0] + videoUrl[1:]
             desc = self.cm.ph.getAllItemsBeetwenNodes(
                 episode,
                 '<div class="content-item__description typo typo--bullfinch">',
                 '<', False)[0] + '...'
             desc = '\c00????00Description: \c00??????' + desc
             params = MergeDicts(
                 cItem, {
                     'good_for_fav': True,
                     'title': ph.clean_html(title),
                     'url': videoUrl,
                     'desc': desc,
                     'icon': self.getFullIconUrl(icon)
                 })
             self.addVideo(params)
     elif '/episode/' in tmpurl and not hadViewAll:
         icon = ph.search(data, self.reSrcset)[0]
         title = ph.clean_html(
             self.cm.ph.getAllItemsBeetwenNodes(data,
                                                '<h1 class="tvip-hide">',
                                                '</h1>', False)[0])
         desc = self.cm.ph.getAllItemsBeetwenNodes(
             data, '<p class="synopsis__paragraph">', '<', False)[0]
         desc = '\c00????00Description: \c00??????' + desc
         params = MergeDicts(
             cItem, {
                 'good_for_fav': True,
                 'title': title,
                 'url': tmpurl,
                 'desc': desc,
                 'icon': self.getFullIconUrl(icon)
             })
         self.addVideo(params)
         block = self.cm.ph.getAllItemsBeetwenNodes(
             data, '<li class="related-episodes__item', '</li>')
         seriesTitle = self.cm.ph.getAllItemsBeetwenNodes(
             data,
             '<span class="typo typo--bold play-cta__title typo--buzzard">',
             '</span>', False)[0]
         for episodes in block:
             if 'Description: This episode' in episodes: continue
             desc = self.cm.ph.getAllItemsBeetwenNodes(
                 episodes, 'aria-label="', '"', False)[0]
             tmp = desc.split('Description: ')
             title = seriesTitle + ' - ' + ph.clean_html(tmp[0])
             desc = tmp[1]
             videoUrl = self.cm.ph.getSearchGroups(episodes,
                                                   'href="([^"]+?)"')[0]
             videoUrl = self.MAIN_URL + videoUrl[:0] + videoUrl[1:]
             desc = '\c00????00Description: \c00??????' + desc
             params = MergeDicts(
                 cItem, {
                     'good_for_fav': True,
                     'title': title,
                     'url': videoUrl,
                     'desc': desc,
                     'icon': self.getFullIconUrl(icon)
                 })
             self.addVideo(params)
     if nextPage:
         params = MergeDicts(cItem, {
             'good_for_fav': False,
             'title': _('Next page'),
             'url': nextPage
         })
         self.addDir(params)
    def listMain(self, cItem):
        printDBG('Filma24IO.listMain')
        sts, data = self.getPage(self.getMainUrl())
        if not sts:
            return
        self.setMainUrl(self.cm.meta['url'])
        subItems = []
        tmp = ph.find(data, ('<div', '>', 'sort'), '</ul>', flags=0)[1]
        tmp = ph.findall(tmp, ('<a', '>'), '</a>', flags=ph.START_S)
        for idx in range(1, len(tmp), 2):
            url = self.getFullUrl(ph.search(tmp[idx - 1], ph.A)[1])
            title = ph.clean_html(tmp[idx])
            subItems.append(
                MergeDicts(cItem, {
                    'title': title,
                    'url': url,
                    'category': 'list_items'
                }))

        tmp = ph.find(data, ('<div', '>', 'head-menu'),
                      ('<div', '>', 'head-categories'),
                      flags=0)[1]
        tmp = ph.findall(tmp, ('<a', '>'), '</a>', flags=ph.START_S)
        for idx in range(1, len(tmp), 2):
            url = self.getFullUrl(ph.getattr(tmp[idx - 1], 'href'))
            title = ph.clean_html(tmp[idx])
            icon = self.getFullIconUrl(ph.search(tmp[idx], ph.IMG)[1])
            if subItems:
                params = {'category': 'sub_items', 'sub_items': subItems}
                subItems = []
            else:
                params = {'category': 'list_items'}
            self.addDir(
                MergeDicts(cItem, params, {
                    'title': title,
                    'url': url,
                    'icon': icon
                }))

        subItems = []
        tmp = ph.find(data, ('<div', '>', 'head-categories'),
                      '</div>',
                      flags=0)[1]
        sTitle = ph.clean_html(ph.find(tmp, ('<a', '>'), '</a>', flags=0)[1])
        sIcon = self.getFullIconUrl(ph.search(tmp[idx], ph.IMG)[1])
        tmp = ph.findall(tmp, ('<li', '>'), '</li>', flags=0)
        for item in tmp:
            if '_blank' in item:
                continue
            url = self.getFullUrl(ph.search(item, ph.A)[1])
            title = ph.clean_html(item)
            subItems.append(
                MergeDicts(
                    cItem, {
                        'title': title,
                        'icon': sIcon,
                        'url': url,
                        'category': 'list_items'
                    }))

        if subItems:
            self.addDir(
                MergeDicts(
                    cItem, {
                        'title': sTitle,
                        'category': 'sub_items',
                        'sub_items': subItems,
                        'icon': sIcon
                    }))
        MAIN_CAT_TAB = [{
            'category': 'search',
            'title': _('Search'),
            'search_item': True
        }, {
            'category': 'search_history',
            'title': _('Search history')
        }]
        self.listsTab(MAIN_CAT_TAB, cItem)
Exemple #27
0
    def _real_extract(self, url, allowVP9=False, allowAgeGate=False):
        # Extract original video URL from URL with redirection, like age verification, using next_url parameter
        mobj = re.search(self._NEXT_URL_RE, url)
        if mobj:
            #https
            url = 'http://www.youtube.com/' + compat_urllib_parse.unquote(
                mobj.group(1)).lstrip('/')
        video_id = self._extract_id(url)
        if 'yt-video-id' == video_id:
            video_id = self.cm.ph.getSearchGroups(
                url + '&', '[\?&]docid=([^\?^&]+)[\?&]')[0]
            isGoogleDoc = True
            url = url
            videoKey = 'docid'
            videoInfoBase = 'https://docs.google.com/get_video_info?docid=%s' % video_id
            COOKIE_FILE = GetCookieDir('docs.google.com.cookie')
            videoInfoparams = {
                'cookiefile': COOKIE_FILE,
                'use_cookie': True,
                'load_cookie': False,
                'save_cookie': True
            }
        else:
            url = 'http://www.youtube.com/watch?v=%s&' % video_id
            isGoogleDoc = False
            videoKey = 'video_id'
            videoInfoBase = 'https://www.youtube.com/get_video_info?video_id=%s&' % video_id
            videoInfoparams = {}

        sts, video_webpage = self.cm.getPage(url)
        if not sts: raise ExtractorError('Unable to download video webpage')

        # Get video info
        #if re.search(r'player-age-gate-content">', video_webpage) is not None:
        if allowAgeGate and re.search(r'"LOGIN_REQUIRED"',
                                      video_webpage) is not None:
            #self.report_age_confirmation()
            age_gate = True
            # We simulate the access to the video from www.youtube.com/v/{video_id}
            # this can be viewed without login into Youtube
            data = compat_urllib_parse.urlencode({
                'el':
                'embedded',
                'gl':
                'US',
                'hl':
                'en',
                'eurl':
                'https://youtube.googleapis.com/v/' + video_id,
                'asv':
                3,
                'sts':
                '1588',
            })
            video_info_url = videoInfoBase + data
            sts, video_info = self.cm.getPage(video_info_url, videoInfoparams)
            if not sts:
                raise ExtractorError('Faile to get "%s"' % video_info_url)
        else:
            age_gate = False
            for el_type in ['&el=detailpage', '&el=embedded', '&el=vevo', '']:
                #https
                video_info_url = videoInfoBase + (
                    '%s&ps=default&eurl=&gl=US&hl=en' % (el_type))
                sts, video_info = self.cm.getPage(video_info_url,
                                                  videoInfoparams)
                if not sts: continue
                if 'channel_creation_token' in video_info or '&account_playback_token=' in video_info:
                    break
        if 'channel_creation_token' not in video_info and '&account_playback_token=' not in video_info:
            raise ExtractorError('"token" parameter not in video info')

        # Check for "rental" videos
        if 'ypc_video_rental_bar_text' in video_info and 'author' not in video_info:
            raise ExtractorError('"rental" videos not supported')

        # Start extracting information

        video_info = video_info.split('&')
        video_info2 = {}
        for item in video_info:
            item = item.split('=')
            if len(item) < 2: continue
            video_info2[item[0].strip()] = item[1].strip()
        video_info = video_info2
        del video_info2
        dashmpd = str(_unquote(str(video_info.get('dashmpd', '')), None))
        # subtitles
        if 'length_seconds' not in video_info:
            video_duration = ''
        else:
            video_duration = video_info['length_seconds']

        if 'url_encoded_fmt_stream_map' in video_info:
            video_info['url_encoded_fmt_stream_map'] = [
                _unquote(video_info['url_encoded_fmt_stream_map'], None)
            ]
        if 'adaptive_fmts' in video_info:
            video_info['adaptive_fmts'] = [
                _unquote(video_info['adaptive_fmts'], None)
            ]

        try:
            mobj = re.search(r';ytplayer.config = ({.*?});', video_webpage)
            if not mobj:
                raise ValueError('Could not find vevo ID')
            ytplayer_config = json_loads(mobj.group(1))
            args = ytplayer_config['args']
            # Easy way to know if the 's' value is in url_encoded_fmt_stream_map
            # this signatures are encrypted
            if 'url_encoded_fmt_stream_map' not in args:
                raise ValueError('No stream_map present')  # caught below
            re_signature = re.compile(r'[&,]s=')
            m_s = re_signature.search(args['url_encoded_fmt_stream_map'])
            if m_s is not None:
                printDBG('%s: Encrypted signatures detected.' % video_id)
                video_info['url_encoded_fmt_stream_map'] = [
                    args['url_encoded_fmt_stream_map']
                ]
            m_s = re_signature.search(args.get('adaptive_fmts', ''))
        except ValueError:
            pass

        # Decide which formats to download

        is_m3u8 = 'no'
        url_map = {}
        video_url_list = {}

        if len(video_info.get('url_encoded_fmt_stream_map', [])) >= 1 or len(
                video_info.get('adaptive_fmts', [])) >= 1:
            encoded_url_map = video_info.get('url_encoded_fmt_stream_map',
                                             [''])[0] + ',' + video_info.get(
                                                 'adaptive_fmts', [''])[0]
            _supported_formats = self._supported_formats
            if allowVP9:
                _supported_formats.extend(['313', '271'])
            for url_data_str in encoded_url_map.split(','):
                if 'index=' in url_data_str and 'index=0-0&' in url_data_str:
                    continue
                if 'itag=' in url_data_str and 'url=' in url_data_str:
                    url_data_str = url_data_str.split('&')
                    url_data = {}

                    supported = False
                    for item in url_data_str:
                        item = item.split('=')
                        if len(item) < 2: continue
                        key = item[1].strip()
                        if item[0] == 'itag':
                            if key in self._supported_formats:
                                supported = True
                            else:
                                break
                        url_data[item[0]] = key

                    if not supported:
                        continue

                    url_item = {'url': _unquote(url_data['url'], None)}
                    if 'sig' in url_data:
                        signature = url_data['sig']
                        url_item['url'] += '&signature=' + signature
                    elif 's' in url_data:
                        url_item['esign'] = _unquote(url_data['s'])
                        if 'sp' in url_data:
                            url_item['url'] += '&%s={0}' % url_data['sp']
                        else:
                            url_item['url'] += '&signature={0}'
                    if not 'ratebypass' in url_item['url']:
                        url_item['url'] += '&ratebypass=yes'
                    url_map[url_data['itag']] = url_item
                video_url_list = self._get_video_url_list(url_map, allowVP9)

        if video_info.get('hlsvp') and not video_url_list:
            is_m3u8 = 'yes'
            manifest_url = _unquote(video_info['hlsvp'], None)
            url_map = self._extract_from_m3u8(manifest_url, video_id)
            video_url_list = self._get_video_url_list(url_map, allowVP9)

        if video_info.get('player_response') and not video_url_list:
            is_m3u8 = 'yes'
            manifest_url = _unquote(video_info['player_response'], None)
            manifest = re.search('"hlsManifestUrl":"(.*?)"', manifest_url)
            if manifest:
                manifest_url = manifest.group(1)
                url_map = self._extract_from_m3u8(manifest_url, video_id)
                video_url_list = self._get_video_url_list(url_map, allowVP9)

        if video_info.get('player_response') and not video_url_list:
            try:
                is_m3u8 = 'no'
                cipher = {}
                url_data_str = json_loads(
                    _unquote(video_info['player_response'],
                             None))['streamingData']['formats']
                try:
                    url_data_str += json_loads(
                        _unquote(video_info['player_response'],
                                 None))['streamingData']['adaptiveFormats']
                except Exception:
                    printExc()
                for url_data in url_data_str:
                    try:
                        url_item = {'url': url_data['url']}
                    except Exception:
                        printExc()
                        cipher = url_data['cipher']
                        cipher = cipher.split('&')
                        for item in cipher:
                            #sig_item = ''
                            #s_item = ''
                            #sp_item = ''
                            if 'url=' in item:
                                url_item = {
                                    'url': _unquote(item.replace('url=', ''),
                                                    None)
                                }
                            if 'sig=' in item:
                                sig_item = item.replace('sig=', '')
                            if 's=' in item: s_item = item.replace('s=', '')
                            if 'sp=' in item: sp_item = item.replace('sp=', '')
                        if 'sig' in cipher:
                            signature = sig_item
                            url_item['url'] += '&signature=' + signature
                        elif len(s_item):
                            url_item['esign'] = _unquote(s_item)
                            if len(sp_item):
                                url_item['url'] += '&%s={0}' % sp_item
                            else:
                                url_item['url'] += '&signature={0}'
                        if not 'ratebypass' in url_item['url']:
                            url_item['url'] += '&ratebypass=yes'
                    url_map[str(url_data['itag'])] = url_item
                video_url_list = self._get_video_url_list(url_map, allowVP9)
            except Exception:
                printExc()

        if not video_url_list:
            return []

        if self.cm.isValidUrl(dashmpd):
            sign = ph.search(dashmpd, r'/s/([a-fA-F0-9\.]+)')[0]
            if sign: dashmpd = dashmpd.replace(sign, '{0}')
            video_url_list.append(('mpd', {'url': dashmpd}))
            if sign: video_url_list[-1][1]['esign'] = sign

        signItems = []
        signatures = []
        for idx in range(len(video_url_list)):
            if 'esign' in video_url_list[idx][1]:
                signItems.append(video_url_list[idx][1])
                signatures.append(video_url_list[idx][1]['esign'])

        if len(signatures):
            # decrypt signatures
            printDBG("signatures: %s" % signatures)
            playerUrl = ''
            tmp = ph.find(video_webpage, ('<script', '>', 'player/base'))[1]
            playerUrl = ph.getattr(tmp, 'src')
            if not playerUrl:
                for reObj in [
                        '"assets"\:[^\}]+?"js"\s*:\s*"([^"]+?)"',
                        'src="([^"]+?)"[^>]+?name="player/base"'
                ]:
                    playerUrl = ph.search(video_webpage, reObj)[0]
                    if playerUrl:
                        break
            playerUrl = self.cm.getFullUrl(playerUrl.replace('\\', ''),
                                           self.cm.meta['url'])
            if playerUrl:
                decSignatures = CYTSignAlgoExtractor(
                    self.cm).decryptSignatures(signatures, playerUrl)
                if len(signatures) == len(signItems):
                    try:
                        for idx in range(len(signItems)):
                            signItems[idx]['url'] = signItems[idx][
                                'url'].format(decSignatures[idx])
                    except Exception:
                        printExc()
                        SetIPTVPlayerLastHostError(
                            _('Decrypt Signatures Error'))
                        return []
                else:
                    return []

        if isGoogleDoc:
            cookieHeader = self.cm.getCookieHeader(COOKIE_FILE)

        sub_tracks = self._get_subtitles(video_id)
        results = []
        for format_param, url_item in video_url_list:
            # Extension
            video_extension = self._video_extensions.get(format_param, 'flv')

            #video_format = '{0} - {1}'.format(format_param if format_param else video_extension,
            #                                  self._video_dimensions.get(format_param, '???'))
            video_format = self._video_dimensions.get(format_param, '???')
            video_real_url = url_item['url']
            if len(sub_tracks):
                video_real_url = strwithmeta(
                    video_real_url, {'external_sub_tracks': sub_tracks})
            if isGoogleDoc:
                video_real_url = strwithmeta(video_real_url,
                                             {'Cookie': cookieHeader})

            results.append({
                'id': video_id,
                'url': video_real_url,
                'uploader': '',
                'title': '',
                'ext': video_extension,
                'format': video_format,
                'thumbnail': '',
                'duration': video_duration,
                'player_url': '',
                'm3u8': is_m3u8,
            })

        return results
    def getLinksForVideo(self, cItem):
        printDBG("BajeczkiOrg.getLinksForVideo [%s]" % cItem)
        urlTab = self.cacheLinks.get(cItem['url'], [])
        if urlTab: return urlTab

        self.cacheLinks = {}

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

        data = self.cm.ph.getDataBeetwenNodes(data,
                                              ('<div', '>', 'entry-content'),
                                              ('<aside', '>'))[1]
        data = re.sub("<!--[\s\S]*?-->", "", data)

        tmp = ph.find(data, '<video', '</video>', flags=ph.IGNORECASE)[1]
        tmp = ph.findall(tmp, '<source', '>', flags=ph.IGNORECASE)
        for item in tmp:
            url = self.getFullUrl(
                self.cm.ph.getSearchGroups(item,
                                           '''src=['"]([^'^"]+?)['"]''',
                                           ignoreCase=True)[0])
            type = self.cm.ph.getSearchGroups(item,
                                              '''type=['"]([^'^"]+?)['"]''',
                                              ignoreCase=True)[0].lower()
            if 'mp4' in type:
                name = self.up.getDomain(url)
                urlTab.append({
                    'name':
                    name,
                    'url':
                    strwithmeta(url, {
                        'direct_link': True,
                        'Referer': self.cm.meta['url']
                    }),
                    'need_resolve':
                    1
                })

        tmp = ph.findall(data, ('<div', '>', 'data-item'),
                         flags=ph.IGNORECASE | ph.START_E)
        for item in tmp:
            if 'sources' not in item: continue
            item = ph.clean_html(ph.getattr(item, 'data-item'))
            try:
                item = json_loads(item)
                for it in item['sources']:
                    it['type'] = it.get(
                        'type',
                        it['src'].split('?', 1)[0].rsplit('.', 1)[-1]).lower()
                    url = strwithmeta(it['src'], {
                        'direct_link': True,
                        'Referer': self.cm.meta['url']
                    })
                    if 'mp4' in it['type']:
                        urlTab.append({
                            'name': it['type'],
                            'url': url,
                            'need_resolve': 1
                        })
                    elif 'mpeg' in it['type']:
                        urlTab.extend(getDirectM3U8Playlist(url))
            except Exception:
                printExc()

        tmp = self.cm.ph.getAllItemsBeetwenMarkers(data,
                                                   '<iframe',
                                                   '>',
                                                   caseSensitive=False)
        for item in tmp:
            url = self.getFullUrl(
                self.cm.ph.getSearchGroups(item,
                                           '''src=['"]([^'^"]+?)['"]''',
                                           ignoreCase=True)[0])
            if 1 == self.up.checkHostSupport(url):
                name = self.up.getDomain(url)
                urlTab.append({
                    'name':
                    name,
                    'url':
                    strwithmeta(url, {'Referer': cItem['url']}),
                    'need_resolve':
                    1
                })

        if not urlTab:
            unique = set()
            data = re.compile(
                '''['">]\s*?(https?://[^'^"^<]*?/watch\?v=[^'^"]+?)\s*?[<'"]'''
            ).findall(data)
            for url in data:
                if url not in unique:
                    urlTab.append({
                        'name':
                        'Youtube',
                        'url':
                        strwithmeta(url, {'Referer': cItem['url']}),
                        'need_resolve':
                        1
                    })
                    unique.add(url)

        if urlTab:
            self.cacheLinks[cItem['url']] = urlTab

        return urlTab
Exemple #29
0
    def listMain(self, cItem, nextCategory):
        printDBG("KKisteAG.listMain")
        self.cacheFilters = {}

        sts, data = self.getPage(self.getFullUrl('/featured'))
        if not sts: return
        data = re.sub("<!--[\s\S]*?-->", "", data)

        if 'myFilter()' in data:
            tmp = ph.find(data, ('<ul', '>', 'menu-main-menu'),
                          '</div>',
                          flags=0)[1]
            tmp = re.compile('</?ul[^>]*?>').split(tmp)

            sTitle = ''
            url = ''
            for section in tmp:
                subItems = []
                section = ph.findall(section, ('<a', '>'),
                                     '</a>',
                                     flags=ph.START_S)
                for idx in range(1, len(section), 2):
                    url = ph.search(section[idx - 1], ph.A)[1]
                    title = ph.clean_html(section[idx])
                    if url == '#':
                        continue
                    else:
                        subItems.append(
                            MergeDicts(
                                cItem, {
                                    'category': nextCategory,
                                    'title': title,
                                    'url': self.getFullUrl(url)
                                }))

                if subItems and sTitle:
                    self.addDir(
                        MergeDicts(
                            cItem, {
                                'category': 'sub_items',
                                'title': sTitle,
                                'sub_items': subItems
                            }))
                    sTitle = ''
                else:
                    self.currList.extend(subItems)

                if url == '#': sTitle = title

            # filter
            filtersMap = {
                'Sortieren nach': 'order_by',
                'Auflösung': 'res',
                'Yahr': 'year',
                'Genres': 'genre'
            }
            tmp = ph.find(data, ('<div', '>', 'tag_cloud'),
                          ('<div', '>', 'loop-'),
                          flags=0)[1]
            tmp = ph.rfindall(tmp, '</div>', ('<h3', '</h3>'), flags=ph.END_S)
            for idx in range(1, len(tmp), 2):
                sTitle = ph.clean_html(tmp[idx - 1])
                key = filtersMap.get(sTitle, '')
                if not key: continue
                self.cacheFilters[key] = []
                filters = []
                items = ph.findall(tmp[idx], ('<a', '>'),
                                   '</a>',
                                   flags=ph.START_S)
                for i in range(1, len(items), 2):
                    value = ph.search(ph.getattr(items[i - 1], 'href'),
                                      '%s=([^&]+)' % key)[0]
                    self.cacheFilters[key].append({
                        'f_%s' % key:
                        value,
                        'title':
                        ph.clean_html(items[i])
                    })

                if self.cacheFilters[key]:
                    self.cacheFilters[key].insert(0, {'title': _('All')})
                    self.cacheFiltersKeys.append(key)

            if len(self.cacheFiltersKeys):
                self.addDir(
                    MergeDicts(cItem, {
                        'category': 'list_filters',
                        'title': 'FILTER',
                        'f_idx': 0
                    }))
        else:
            pass
            # ToDo

        MAIN_CAT_TAB = [{
            'category': 'search',
            'title': _('Search'),
            'search_item': True
        }, {
            'category': 'search_history',
            'title': _('Search history'),
        }]
        self.listsTab(MAIN_CAT_TAB, cItem)
Exemple #30
0
    def listMain(self, cItem, nextCategory):
        printDBG("Cinemaxx.listMain")
        sts, data = self.getPage(self.getMainUrl())
        if not sts: return
        self.setMainUrl(self.cm.meta['url'])

        subItems = []
        tmp = ph.findall(data, ('<div', '>', 'owl-cat'), '</div>')
        for item in tmp:
            icon = self.getFullIconUrl(ph.search(item, ph.IMAGE_SRC_URI_RE)[1])
            item = ph.find(item, ('<h2', '>'), '</h2>', flags=0)[1]
            url = self.getFullUrl(ph.search(item, ph.A_HREF_URI_RE)[1])
            title = self.cleanHtmlStr(item)
            subItems.append(
                MergeDicts(
                    cItem, {
                        'good_for_fav': True,
                        'category': nextCategory,
                        'title': title,
                        'url': url
                    }))

        printDBG(subItems)
        sections = ph.find(data, ('<div', '>', 'navbar-collapse'), '</div>')[1]
        sections = ph.rfindall(sections, '</li>', ('<li', '>', 'nav'), flags=0)
        for section in sections:
            tmp = ph.findall(section, ('<a', '>'),
                             '</a>',
                             flags=ph.START_S,
                             limits=1)
            if not tmp: continue
            sTitle = ph.clean_html(tmp[1])
            sUrl = ph.getattr(tmp[0], 'href')

            if sUrl == '/':
                self.addDir(
                    MergeDicts(
                        cItem, {
                            'category': 'sub_items',
                            'sub_items': subItems,
                            'title': sTitle
                        }))
            elif '<ul' in section:
                subItems = []
                section = ph.findall(section, ('<li', '>'), '</li>', flags=0)
                for item in section:
                    title = ph.clean_html(item)
                    url = self.getFullUrl(ph.search(item, ph.A_HREF_URI_RE)[1])
                    subItems.append(
                        MergeDicts(
                            cItem, {
                                'good_for_fav': True,
                                'category': nextCategory,
                                'title': title,
                                'url': url
                            }))
                if len(subItems):
                    self.addDir(
                        MergeDicts(
                            cItem, {
                                'category': 'sub_items',
                                'sub_items': subItems,
                                'title': sTitle
                            }))
            else:
                self.addDir(
                    MergeDicts(
                        cItem, {
                            'category': nextCategory,
                            'url': self.getFullUrl(sUrl),
                            'title': sTitle
                        }))

        MAIN_CAT_TAB = [{
            'category': 'search',
            'title': _('Search'),
            'search_item': True
        }, {
            'category': 'search_history',
            'title': _('Search history'),
        }]
        self.listsTab(MAIN_CAT_TAB, cItem)