Exemple #1
0
 def listSearchItems(self, cItem):
     page = cItem.get('page', 1)
     sts, data = self.getPage(cItem['url'])
     if not sts:
         return
     self.setMainUrl(self.cm.meta['url'])
     tmp = ph.find(data, ('<span', '>', 'pagesBlock'), '</div>')[1]
     tmp = ph.find(tmp, ('<a', '>', ';p=%s;' % (page + 1)))[1]
     nextPage = self.getFullUrl(ph.getattr(tmp, 'href'))
     data = ph.find(data, ('<div', '>', 'eTitle'),
                    ('<div', '>', 'clearfix'),
                    flags=ph.START_E)[1]
     data = ph.rfindall(data, '</div>', ('<div', '>', 'eTitle'), flags=0)
     for item in data:
         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, ('<a', '>'), '</a>', flags=0)[1])
         desc = [
             ph.clean_html(
                 ph.find(item, ('<div', '>', 'eDetails'), '</div>',
                         flags=0)[1])
         ]
         desc.append(
             ph.clean_html(
                 ph.find(item, ('<div', '>', 'eMessage'), '</div>',
                         flags=0)[1]))
         self.addVideo({
             'good_for_fav': True,
             '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
                 }))
    def _listItems(self, data):
        retTab = []
        data = ph.rfindall(data, '</div>', ('<div', '>', 'box_movie'))
        printDBG(data)

        for item in data:
            printDBG('+++')
            url = self.getFullUrl(ph.search(item, ph.A)[1])
            if not url:
                continue
            title = ph.clean_html(ph.rfind(item, '</div>', '</div>')[1])
            if title == '':
                title = ph.clean_html(ph.getattr(item, 'title'))
            icon = self.getFullIconUrl(ph.getattr(item, 'data-src'))
            if icon == '':
                icon = self.getFullIconUrl(
                    ph.search(item, '''\surl\(([^\)]+?)\)''')[0].strip())

            desc = []
            tmp = ph.find(item, ('<div', '>', 'cats'), '</div>', flags=0)[1]
            tmp = ph.findall(tmp, ('<a', '>'), '</a>')
            for t in tmp:
                t = ph.clean_html(t)
                if t != '':
                    desc.append(t)

            desc = [', '.join(desc)]
            tmp = ph.findall(item, ('<', '>', 'badge-small'), ('</', '>', 'a'))
            for t in tmp:
                t = ph.clean_html(t)
                if t != '':
                    desc.append(t)

            desc = ' | '.join(desc)
            desc += '[/br]' + ph.clean_html(
                ph.find(item, ('<p', '>'), '</p>')[1])
            retTab.append({
                'title': title,
                'url': url,
                'icon': icon,
                'desc': desc
            })
        return retTab
Exemple #3
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)
Exemple #4
0
    def doListItems(self, cItem, data):
        data = ph.rfindall(data, '</div>', ('<div', '>', 'post-'))
        for item in data:
            url = self.getFullUrl( ph.search(item, ph.A)[1] )
            icon = self.getFullIconUrl( ph.search(item, self.reIMG)[1] )
            title = ph.clean_html(ph.find(item, ('<h2', '>'), '</h2>', flags=0)[1])

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

            desc = [' | '.join(desc)]
            desc.append(ph.clean_html(ph.find(item, ('<p', '>'), '</p>', flags=0)[1]))

            desc.append(ph.clean_html(ph.find(item, ('<div', '>', 'desc'), '</div>', flags=0)[1]))
            self.addDir(MergeDicts(cItem, {'good_for_fav':True, 'prev_url':url, 'category':'explore_item', 'title':title, 'url':url, 'icon':icon, 'desc':'[/br]'.join(desc)}))
    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 #6
0
    def _findMainFunctionName(self):
        data = self.playerData

        name = ph.find(data, '"signature",', '}', 0)[1].split('(',
                                                              1)[0].strip()
        if name and not any((c in name) for c in ''', '"'''):
            return name.strip()

        name = ph.find(data, '.sig||', '}', 0)[1].split('(', 1)[0].strip()
        if name and not any((c in name) for c in ''', '"'''):
            return name.strip()

        tmp = ph.find(data, 'yt.akamaized.net', '}', 0)[1]
        if tmp:
            printDBG("DATA: %s" % tmp)
            tmp = ph.rfindall(tmp,
                              'return',
                              '.set(b,encodeURIComponent',
                              flags=0)
            for name in tmp:
                printDBG("ITEM: %s" % name)
                name = ph.search(name, self.RE_MAIN)[0]
                if name: return name

        tmp = ph.findall(
            data,
            ('.set(', '));', lambda d, l, s, e: not ph.any(')-";', l, s, e)))
        for name in tmp:
            name = name.split(',', 1)[-1].split('(', 1)[0].strip()
            if name and not any((c in name) for c in ''', '";()'''):
                return name

        name = ph.search(
            data,
            r'(?P<sig>[a-zA-Z0-9$]+)\s*=\s*function\(\s*a\s*\)\s*{\s*a\s*=\s*a\.split\(\s*""\s*\)'
        )[0]
        if name and not any((c in name) for c in ''', '"'''):
            return name.strip()

        return ''
Exemple #7
0
    def exploreItem(self, cItem):
        printDBG("OkGoals.exploreItem")

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

        #reObj = re.compile('<[\s/]*?br[\s/]*?>', re.IGNORECASE)
        titles = []
        tmp = ph.find(data, ('<div', '>', 'video-watch'), ('<div', '>', 'content-box-title'))[1]
        tmp = ph.rfindall(tmp, '</div>', ('<div', '>', 'video-watch'), flags=0)
        for item in tmp:
            #item = reObj.split(item)
            item = item.split('</div>', 1)
            title = self.cleanHtmlStr(item[0])
            desc = self.cleanHtmlStr(item[-1])
            titles.append((title, desc))

        tmp = re.compile('''['"]([^'^"]*?//config\.playwire\.com[^'^"]+?\.json)['"]''').findall(data)
        tmp.extend(re.compile('''<iframe[^>]+?src=['"]([^"]+?)['"]''').findall(data))
        tmp.extend(re.compile('''<a[^>]+?href=['"](https?://[^'^"]*?ekstraklasa.tv[^'^"]+?)['"]''').findall(data))
        tmp.extend(re.compile('''<a[^>]+?href=['"](https?://[^'^"]*?polsatsport.pl[^'^"]+?)['"]''').findall(data))

        for idx in range(len(tmp)):
            url = self.getFullUrl(tmp[idx])
            if not self.cm.isValidUrl(url):
                continue
            if 'playwire.com' not in url and self.up.checkHostSupport(url) != 1:
                continue
            title = cItem['title']
            desc = ''
            if len(titles) > idx:
                if titles[idx][0]:
                    title += ' - ' + titles[idx][0]
                desc = titles[idx][1]

            params = dict(cItem)
            params.update({'good_for_fav': False, 'title': title, 'url': url, 'desc': desc})
            self.addVideo(params)
Exemple #8
0
    def listPopular(self, cItem):
        printDBG('DixMax.listPopular')
        sts, data = self.getPage(cItem['url'])
        if not sts:
            return
        self.setMainUrl(self.cm.meta['url'])
        data = ph.find(data, ('<section', '>', 'content'), '</section>', flags=0)[1]
        titleMap = {}
        tmp = ph.find(data, ('<ul', '>', 'tablist'), '</ul>', flags=0)[1]
        tmp = ph.findall(tmp, ('<a', '>', 'aria-controls'), '</a>', flags=ph.START_S)
        for idx in range(1, len(tmp), 2):
            title = ph.clean_html(tmp[idx])
            key = ph.getattr(tmp[idx - 1], 'aria-controls')
            titleMap[key] = title

        data = ph.rfindall(data, '</div>', ('<div', '>', 'tabpanel'))
        for item in data:
            title = titleMap.get(ph.getattr(item, 'id'), '')
            subItems = self._listItems2(cItem, 'explore_item', item)
            if subItems:
                self.addDir(MergeDicts(cItem, {'title': title,
                 'category': 'sub_items',
                 'sub_items': subItems}))
Exemple #9
0
    def getArticleContent(self, cItem, data=None):
        printDBG("Cinemaxx.getArticleContent [%s]" % cItem)
        retTab = []
        itemsList = []

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

        tmp = ph.find(data, ('<div', '>', 'dle-content'), ('<div', '>', 'fstory-info'), flags=0)[1]
        title = self.cleanHtmlStr(ph.find(tmp, ('<h1', '>'), '</h1>', flags=0)[1])
        icon = self.getFullIconUrl(ph.search(tmp, ph.IMAGE_SRC_URI_RE)[1])
        desc = self.cleanHtmlStr(ph.find(data, ('<div', '>', 'fstory-content'), '</div>', flags=0)[1])

        data = ph.find(data, ('<div', '>', 'finfo'), ('<div', '>', 'fstory-content'), flags=0)[1]
        data = ph.rfindall(data, '</div>', ('<div', '>', 'finfo-block'), flags=0)

        for item in data:
            key = self.cleanHtmlStr(ph.find(item, ('<div', '>', 'title'), '</div>', flags=0)[1])
            if 'current-rating' in item:
                value = self.cleanHtmlStr(ph.find(item, ('<', '>', 'current-rating'), ('</', '>'), flags=0)[1] + '/100')
            else:
                value = self.cleanHtmlStr(ph.find(item, ('<div', '>', 'text'), '</div>', flags=0)[1].rsplit('</ul>', 1)[-1])
            itemsList.append((key, value))

        if title == '':
            title = cItem['title']
        if icon == '':
            icon = cItem.get('icon', self.DEFAULT_ICON_URL)
        if desc == '':
            desc = cItem.get('desc', '')

        return [{'title': self.cleanHtmlStr(title), 'text': self.cleanHtmlStr(desc), 'images': [{'title': '', 'url': self.getFullUrl(icon)}], 'other_info': {'custom_items_list': itemsList}}]
Exemple #10
0
    def getList(self, cItem):
        printDBG("Wiz1NetApi.getChannelsList")

        channelsTab = []
        sts, data = self.getPage(self.MAIN_URL, self.http_params)
        if not sts:
            return []
        #self.setMainUrl(self.cm.meta['url'])
        #self.http_params['header']['Referer'] = self.cm.meta['url']

        printDBG(data)

        frame_url = re.findall("<iframe.*src=\"(.*?)\"", data)
        if frame_url:
            sts, data = self.getPage(self.getFullUrl(frame_url[0]),
                                     self.http_params)
            if not sts:
                return []

            desc = ph.clean_html(
                ph.find(data, ('<h4', '>'), ('<br', '>'), flags=0)[1])

            data = ph.rfindall(data, '</a>', ('<br', '>'), flags=0)
            for item in data:
                title = ph.clean_html(item)
                url = self.getFullUrl(ph.search(item, ph.A)[1])
                channelsTab.append(
                    MergeDicts(cItem, {
                        'type': 'video',
                        'title': title,
                        'url': url,
                        'desc': desc
                    }))
        else:
            printDBG("Iframe source not found!")
        return channelsTab
Exemple #11
0
    def listMain(self, cItem, nextCategory):
        printDBG("Christusvincit.listMain")

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

        data = re.sub("<!--[\s\S]*?-->", "", data)
        sections = ph.rfindall(data, '</table>', ('<td', '>', 'capmain-left'), flags=0)
        for section in sections:
            self.handleSection(cItem, nextCategory, section)

        rtmpUrl = ph.search(data, '''netConnectionUrl['"\s]*?:\s*?['"](rtmp://[^'^"]+?)['"]''')[0]
        # move live to the top
        prevlist = self.currList
        self.currList = []
        for item in prevlist:
            if "na żywo" in item['title']:
                if rtmpUrl:
                    try:
                        rtmpUrl = strwithmeta(rtmpUrl, {'iptv_proto': 'rtmp', 'iptv_livestream': True})
                        params = {'title': '%s [RTMP]' % item['title'], 'url': rtmpUrl, 'type': 'video'}
                        if 'sub_items' in item:
                            item['sub_items'].append(params)
                        else:
                            item['rtmp_item'] = params
                    except Exception:
                        printExc()
                self.currList.insert(0, item)
            else:
                self.currList.append(item)

        MAIN_CAT_TAB = [{'category': 'search', 'title': _('Search'), 'search_item': True},
                        {'category': 'search_history', 'title': _('Search history'), }]
        self.listsTab(MAIN_CAT_TAB, cItem)
Exemple #12
0
    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)
Exemple #13
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 #14
0
    def exploreItem(self, cItem, nextCategory):
        printDBG('InteriaTv.listItems')
        sts, data = self.getPage(cItem['url'])
        if not sts:
            return
        cUrl = data.meta['url']
        if '/serie/' in cUrl and '/saison' in cUrl:
            cUrl = cUrl.split('/saison-', 1)[0]
            sts, data = self.getPage(cUrl)
            if not sts:
                return
            cUrl = data.meta['url']
        self.setMainUrl(cUrl)
        tmp = ph.find(data, ('<div', '>', 'bdetail'), ('<div', '>', 'col-md'),
                      flags=0)[1]
        iTitle = ph.clean_html(ph.find(tmp, ('<h1', '>'), '</h1>', flags=0)[1])
        tmp = ph.find(tmp, ('<div', '>', 'dmovie'), '</div>', flags=0)[1]
        iIcon = self.getFullIconUrl(ph.search(tmp, ph.IMG)[1])
        iTrailer = self.getFullUrl(ph.search(tmp, ph.IFRAME)[1])
        if '/film/' in cUrl:
            if '"players' in data or "'players" in data:
                params = dict(cItem)
                params.update({'priv_has_art': True})
                self.addVideo(params)
        else:
            data = ph.find(data, ('<div', '>', 'panel-heading'),
                           ('<footer', '>'),
                           flags=0)[1]
            data = ph.rfindall(data, '</div>', ('<div', '>', 'col-md'))
            for season in data:
                sTitle = ph.clean_html(
                    ph.find(season, ('<h', '>', 'panel-title'), ('</h', '>'),
                            flags=0)[1])
                printDBG('<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< %s' % sTitle)
                sUrl = self.getFullUrl(ph.search(season, ph.A)[1])
                season = ph.findall(season, ('<div', '>', 'panel-body'),
                                    '</div>',
                                    flags=0)
                episodesTab = []
                for item in season:
                    url = self.getFullUrl(ph.search(item, ph.A)[1])
                    title = ph.clean_html(
                        ph.find(item, ('<a', '>'), '</a>', flags=0)[1])
                    desc = ph.clean_html(
                        ph.find(item, ('<span', '>', 'ddcheck'),
                                '</span>',
                                flags=0)[1])
                    params = {
                        'good_for_fav': True,
                        'priv_has_art': True,
                        'url': url,
                        'title': '%s - %s' % (iTitle, title),
                        'desc': desc,
                        'icon': iIcon
                    }
                    if 'glyphicon-time' in item:
                        params['type'] = 'article'
                    else:
                        params['type'] = 'video'
                    episodesTab.append(params)

                if len(episodesTab):
                    params = {
                        'good_for_fav': False,
                        'priv_has_art': True,
                        'category': nextCategory,
                        'title': sTitle,
                        'url': sUrl,
                        'sub_items': episodesTab,
                        'desc': '',
                        'icon': iIcon
                    }
                    self.addDir(params)

        if iTrailer != '':
            params = {
                'good_for_fav': False,
                'url': iTrailer,
                'title': '%s - %s' % (iTitle, _('trailer')),
                'icon': iIcon
            }
            self.addVideo(params)
    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)
    def listCatalog(self, cItem, nextCategory1, nextCategory2, data=None):
        printDBG("MediasetPlay.listCatalog")
        if not data:
            sts, data = self.getPage(cItem['url'])
            if not sts:
                return
            self.setMainUrl(self.cm.meta['url'])

        exports = {
            "button-special": "_1u_k9 _3Pqi-",
            "wrapper": "C6FJZ",
            "description": "_3XiTc",
            "sub-title-banner": "_1tNlk",
            "title-banner": "_1KV50",
            "airing-time": "_3pYTW",
            "description-wrapper": "glxlH",
            "title-hero": "dTamS",
            "title-hero-small": "_1AN7g"
        }

        data = ph.find(data, ('<article', '>'), '</article>', flags=0)[1]
        data = ph.findall(data, ('<section', '>'), '</section>', flags=0)
        for sectionItem in data:
            sectionItem = sectionItem.split('</header>', 1)
            sIcon = self.getFullUrl(
                ph.search(sectionItem[0], ph.IMAGE_SRC_URI_RE)[1])
            sTitle = ph.clean_html(
                ph.find(sectionItem[0], ('<h2', '>'), '</h2>', flags=0)[1])
            if not sTitle:
                sTitle = ph.clean_html(ph.getattr(sectionItem[0], 'title'))
            subItems = []
            item = ph.rfind(sectionItem[0],
                            '</div>', ('<div', '>', exports['wrapper']),
                            flags=0)[1]
            url = self.getFullUrl(ph.getattr(item, 'href'))
            desc = ph.clean_html(
                ph.find(item, ('<div', '>', exports['description']),
                        '</div>',
                        flags=0)[1])
            title = ph.clean_html(
                ph.find(item, ('<div', '>', exports['button-special']),
                        '</div>',
                        flags=0)[1])
            if url and title:
                subItems.append(
                    MergeDicts(
                        cItem, {
                            'good_for_fav': True,
                            'category': nextCategory2,
                            'url': url,
                            'title': title,
                            'icon': sIcon,
                            'desc': desc
                        }))

            sectionItem = ph.rfindall(sectionItem[-1],
                                      '</div>', ('<a', '>'),
                                      flags=ph.END_S)
            for idx in range(1, len(sectionItem), 2):
                url = self.getFullUrl(ph.getattr(sectionItem[idx - 1], 'href'))
                item = sectionItem[idx]
                icon = self.getFullUrl(ph.search(item, ph.IMAGE_SRC_URI_RE)[1])
                title1 = ph.clean_html(
                    ph.find(item, ('<h3', '>'), '</h3>', flags=0)[1])
                title2 = ph.clean_html(
                    ph.find(item, ('<h4', '>'), '</h4>', flags=0)[1])
                if not title1:
                    title1 = ph.clean_html(
                        ph.find(item, ('<p', '>', exports['title-banner']),
                                '</p>',
                                flags=0)[1])
                if not title2:
                    title2 = ph.clean_html(
                        ph.find(item, ('<p', '>', exports['sub-title-banner']),
                                '</p>',
                                flags=0)[1])
                if not title1:
                    title1 = ph.clean_html(
                        ph.find(item, ('<p', '>', exports['title-hero']),
                                '</p>',
                                flags=0)[1])
                if not title2:
                    title2 = ph.clean_html(
                        ph.find(item, ('<p', '>', exports['title-hero-small']),
                                '</p>',
                                flags=0)[1])
                if not title1:
                    title1 = ph.clean_html(
                        ph.find(item, ('<h2', '>'), '</h2>', flags=0)[1])

                title = []
                if title1:
                    title.append(title1)
                if title2:
                    title.append(title2)
                desc = []
                desc.append(
                    ph.clean_html(
                        ph.find(item, ('<div', '>', exports['airing-time']),
                                '</div>',
                                flags=0)[1]))
                desc.append(
                    ph.clean_html(
                        ph.find(item,
                                ('<div', '>', exports['description-wrapper']),
                                '</div>',
                                flags=0)[1]))
                params = {
                    'good_for_fav': True,
                    'url': url,
                    'title': ' - '.join(title),
                    'icon': icon,
                    'desc': '[/br]'.join(desc)
                }
                if '/diretta/' in url:
                    subItems.append(
                        MergeDicts(params, {
                            'type': 'video',
                            'is_live': True,
                            'desc': _('live')
                        }))
                elif '/video' in url:
                    subItems.append(MergeDicts(params, {'type': 'video'}))
                else:
                    subItems.append(
                        MergeDicts(cItem, params, {'category': nextCategory2}))
            if len(subItems) == 1:
                self.currList.extend(subItems)
            elif len(subItems) > 1:
                self.addDir(
                    MergeDicts(
                        cItem, {
                            'good_for_fav': False,
                            'category': 'sub_items',
                            'title': sTitle,
                            'icon': sIcon,
                            'sub_items': subItems
                        }))

        if len(self.currList) == 1 and self.currList[0].get(
                'category') == 'sub_items':
            self.currList = self.currList[0]['sub_items']

        tab = []
        category = cItem['category']
        cItem = MergeDicts(cItem, {
            'good_for_fav': True,
            'category': nextCategory1
        })
        if category == 'cat_movies':
            tab = [
                {
                    'title': 'Film più visti',
                    'f_ref': 'CWFILMTOPVIEWED'
                },
                {
                    'title': 'Commedia',
                    'f_ref': 'CWFILMCOMEDY'
                },
                {
                    'title': 'Drammatico',
                    'f_ref': 'CWFILMDRAMATIC'
                },
                {
                    'title': 'Thriller, Azione e Avventura',
                    'f_ref': 'CWFILMACTION'
                },
                {
                    'title': 'Documentari',
                    'f_ref': 'CWFILMDOCU'
                },
            ]
        elif category == 'cat_series':
            tab = [
                {
                    'title': 'Poliziesco',
                    'f_ref': 'CWFICTIONPOLICE'
                },
                {
                    'title': 'Sentimentale',
                    'f_ref': 'CWFICTIONSENTIMENTAL'
                },
                {
                    'title': 'Commedia',
                    'f_ref': 'CWFICTIONCOMEDY'
                },
                {
                    'title': 'Thriller, Azione e Avventura',
                    'f_ref': 'CWFICTIONACTION'
                },
                {
                    'title': 'Biografico',
                    'f_ref': 'CWFICTIONBIOGRAPHICAL'
                },
                {
                    'title': 'Sit-Com',
                    'f_ref': 'CWFICTIONSITCOM'
                },
                {
                    'title': 'Drammatico',
                    'f_ref': 'CWFICTIONDRAMATIC'
                },
                {
                    'title': 'Avventura',
                    'f_ref': 'CWFICTIONADVENTURE'
                },
            ]
        self.listsTab(tab, cItem)
    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 getArticleContent(self, cItem, data=None):
        printDBG("Fenixsite.getArticleContent [%s]" % cItem)
        retTab = []

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

        tmp = ph.find(data, ('<div', '>', 'fullstory'), '</div>', flags=0)[1]
        title = self.cleanHtmlStr(
            ph.find(tmp, ('<h1', '>'), '</h1>', flags=0)[1])
        icon = self.getFullIconUrl(ph.search(tmp, ph.IMAGE_SRC_URI_RE)[1])
        desc = self.cleanHtmlStr(
            ph.find(data, ('<div', '>', 'h1'), '</p>', flags=0)[1])

        itemsList = []
        data = ph.find(data, ('<div', '>', 'finfo'), ('<div', '>', 'berrors'),
                       flags=0)[1]
        data = ph.rfindall(data,
                           '</div>', ('<div', '>', 'finfo-block'),
                           flags=0)

        for item in data:
            key = self.cleanHtmlStr(
                ph.find(item, ('<div', '>', 'title'), '</div>', flags=0)[1])
            if 'Pomoc' in key or 'Prijavi' in key: continue
            if 'imdbRatingPlugin' in item:
                url = 'http://p.media-imdb.com/static-content/documents/v1/title/{0}/ratings%3Fjsonp=imdb.rating.run:imdb.api.title.ratings/data.json?u={1}&s={2}'.format(
                    ph.getattr(item, 'data-title'),
                    ph.getattr(item, 'data-user'),
                    ph.getattr(item, 'data-style'))
                try:
                    sts, tmp = self.getPage(url)
                    printDBG(">>" + tmp.strip()[16:-1])
                    tmp = json_loads(tmp.strip()[16:-1])['resource']
                    value = '%s (%s)' % (tmp['rating'], tmp['ratingCount'])
                except Exception:
                    printExc()
                    continue
            else:
                value = self.cleanHtmlStr(
                    ph.find(item, ('<div', '>', 'text'), '</div>',
                            flags=0)[1].rsplit('</ul>', 1)[-1])
            itemsList.append((key, value))

        if title == '': title = cItem['title']
        if icon == '': icon = cItem.get('icon', self.DEFAULT_ICON_URL)
        if desc == '': desc = cItem.get('desc', '')

        return [{
            'title': self.cleanHtmlStr(title),
            'text': self.cleanHtmlStr(desc),
            'images': [{
                'title': '',
                'url': self.getFullUrl(icon)
            }],
            'other_info': {
                'custom_items_list': itemsList
            }
        }]
    def getLinksForVideo(self, cItem):

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

        linksTab = []
        subTrack = ''

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

        # get trailer
        trailerUrl = ''
        tmp = ph.findall(data, ('<script', '>'), '</script>')
        for item in tmp:
            if 'getJSON' in item:
                key = ph.search(
                    item,
                    '''var\s+?keys\s*?=[^;^'^"]*?['"]([^'^"]+?)['"]''')[0]
                item = ph.find(item, 'getJSON(', ',', flags=0)[1].split('+')
                apiLink = ''
                for it in item:
                    it = it.strip()
                    if it.startswith('"') or it.startswith("'"):
                        apiLink += it[1:-1]
                    elif 'key' in it:
                        apiLink += urllib.quote_plus(key)
                    elif 'count' in it:
                        apiLink += '1'
                apiLink = self.getFullUrl(apiLink)
                sts, tmp = self.getPage(apiLink)
                if sts:
                    try:
                        trailerUrl = 'https://www.youtube.com/watch?v=' + json_loads(
                            tmp)['items'][0]['videoId']
                    except Exception:
                        printExc()
                break

        labelsMap = []
        tmp = ph.find(data, ('<ul', '>', 'tablist'), '</ul>', flags=0)[1]
        tmp = ph.findall(tmp, ('<li', '>'), '</li>', flags=0)

        titlesMap = {}
        for item in tmp:
            key = ph.search(item, ph.A_HREF_URI_RE)[1]
            title = self.cleanHtmlStr(item)
            if not key: continue
            titlesMap[key] = title

        data = ph.find(data, ('<div', '>', 'tab-content'),
                       ('<div', '>', 'fstory'),
                       flags=0)[1]
        data = ph.rfindall(data,
                           '</div>', ('<div', '>', 'tab-pane'),
                           flags=ph.END_S)
        for idx in xrange(1, len(data), 2):
            id = ph.getattr(data[idx - 1], 'id')
            item = data[idx]
            title = titlesMap.get('#%s' % id, '')
            url = ph.search(item, ph.IFRAME_SRC_URI_RE)[1]
            if url:
                linksTab.append({
                    'name':
                    '%s | %s' % (title, self.up.getDomain(url)),
                    'url':
                    self.getFullUrl(url),
                    'need_resolve':
                    1
                })
            elif 'gkpluginsphp' in item:
                idx1 = item.find('{')
                idx2 = item.rfind('}')
                if idx1 >= 0 and idx2 >= 0:
                    ret = js_execute('print(JSON.stringify(%s));' %
                                     item[idx1:idx2 + 1])
                    if ret['sts'] and 0 == ret['code']:
                        try:
                            item = json_loads(ret['data'])
                            if item.get('subtitle'):
                                subTrack = self.getFullUrl(item['subtitle'])
                            for it in item['gklist']:
                                if it['link']:
                                    linksTab.append({
                                        'name':
                                        '%s | %s | %s' %
                                        (title, it['title'],
                                         self.up.getDomain(it['link'])),
                                        'url':
                                        self.getFullUrl(it['link']),
                                        'need_resolve':
                                        1
                                    })
                        except Exception:
                            printExc()

        if len(linksTab):
            if subTrack:
                subTrack = [{
                    'title': _('Default'),
                    'url': subTrack,
                    'lang': 'default',
                    'format': 'vtt'
                }]
                for item in linksTab:
                    item['url'] = strwithmeta(item['url'], {
                        'Referer': cUrl,
                        'external_sub_tracks': subTrack
                    })
            self.cacheLinks[cItem['url']] = linksTab

        if trailerUrl:
            linksTab.append({
                'name': _('Trailer'),
                'url': trailerUrl,
                'need_resolve': 1
            })

        return linksTab
Exemple #20
0
    def listItems(self, cItem):
        printDBG("TurcjaTv.listItems")
        page = cItem.get('page', 0)
        post_data = cItem.get('post_data', None)
        nextPage = cItem['url']
        if page == 0:
            sts, data = self.getPage(cItem['url'])
            if not sts: return
            self.setMainUrl(self.cm.meta['url'])

            tmp = ph.find(data, ('<div', '>', 'entry-content'),
                          '<footer')[1].split('page-navigation', 1)
            if len(tmp) == 2:
                template = ph.getattr(tmp[-1], 'data-template')
                playlist = ph.getattr(tmp[-1], 'id_post_playlist')

                np = ph.search(
                    data.split('<body', 1)[-1],
                    'var\s+?cactus_ajax_paging\s*?=\s*?(\{[^>]+\})')[0]
                printDBG(">> \n%s" % np)
                try:
                    np = json_loads(np)
                    nextPage = self.getFullUrl(np['ajaxurl'])
                    post_data = {
                        'vars': np['query_vars'],
                        'action': 'load_more',
                        'template': template,
                        'id_playlist': playlist
                    }
                    printDBG(post_data)
                except Exception:
                    printExc()
            data = tmp[0]
        else:
            post_data['page'] = page
            sts, data = self.getPage(
                cItem['url'], post_data=self.cm.buildHTTPQuery(post_data))
            if not sts: return
            printDBG("++++++++++++++++++++++++++++++++++++++++++")
            printDBG(data)
            printDBG("++++++++++++++++++++++++++++++++++++++++++")

        data = ph.rfindall(data,
                           '</div>', ('<div', '>', 'entry-content'),
                           flags=0)
        for item in data:
            url = self.getFullUrl(ph.search(item, ph.A_HREF_URI_RE)[1])
            icon = self.getFullIconUrl(ph.search(item, ph.IMAGE_SRC_URI_RE)[1])
            item = item.split('</h3>', 1)
            title = self.cleanHtmlStr(item[0])
            desc = []
            tmp = ph.findall(item[-1], ('<div', '>'), '</div>', flags=0)
            for t in tmp:
                t = self.cleanHtmlStr(t)
                if t: desc.append(t)

            params = {
                'good_for_fav': True,
                'title': title,
                'url': url,
                'icon': icon,
                'desc': ' | '.join(desc)
            }
            if '/channel/' in url or '/playlist/' in url:
                params.update({
                    'name': 'category',
                    'category': cItem['category']
                })
                self.addDir(params)
            else:
                self.addVideo(params)

        if post_data:
            post_data['page'] = page + 1
            sts, data = self.getPage(
                nextPage, post_data=self.cm.buildHTTPQuery(post_data))
            if not sts: return
            if data.count('entry-content'):
                self.addDir(
                    MergeDicts(
                        cItem, {
                            'url': nextPage,
                            'title': _('Next page'),
                            'post_data': post_data,
                            'page': page + 1
                        }))