Beispiel #1
0
 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
    def listItems(self, cItem):
        printDBG("FilmyNaDzis.listItems %s" % cItem)
        page = cItem.get('page', 1)

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


        # page style categories
        tmp = ph.find(data, ('<div', '>', 'listing-wrap'), ('<div','>', 'main-bottom-sidebar-wrap'), flags=0)[1]
        items = self.cm.ph.getAllItemsBeetwenMarkers(tmp, ('<article', '>'), '</article>')
        
        if not items:
            printDBG("FilmyNaDzis.listItems: No items found! Check HTML")
            printDBG("--------------------------------")
            printDBG(data)
            printDBG("--------------------------------")
            
        
        for item in items:
            #printDBG("----------------------------")
            #printDBG(item)
            
            url = ph.search(item, ph.A)[1]
            if url:
                url = self.getFullUrl(url, self.MAIN_URL)
            
            
            icon = self.cm.ph.getSearchGroups(item, '''data-src=['"]([^"^']+?)['"]''')[0]
            if icon:
                icon = self.getFullUrl(icon, self.MAIN_URL)
            
            title = ph.clean_html(ph.find(item, ('h3', '>'), '</h', flags=0)[1])
            desc = ph.clean_html(ph.find(item, ('<div', '>', 'excerpt'), '</div', flags=0)[1])

            params = dict(cItem)
            params.update({'good_for_fav':True, 'title':title, 'url':url, 'desc':desc, 'icon':icon})
            printDBG(str(params))
            self.addVideo(params)


        #nextpage
        nextPage = ph.find(data, ('<div', '>', 'pagenavi'), '</div>', flags=0)[1]
        nextPage = ph.rfind(nextPage, '>%s</a>' % (page + 1), '<a')[1]
        nextPage = self.getFullUrl(ph.getattr(nextPage, 'href'), cUrl)

        if nextPage and self.currList:
            params = dict(cItem)
            params.update({'good_for_fav':False, 'title':_('Next page'), 'url':nextPage, 'page':page + 1})
            self.addMore(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}))
    def listItems(self, cItem, nextCategory):
        printDBG('SeriesBlanco.listMoviesItems %s' % cItem)
        page = cItem.get('page', 1)
        sts, data = self.getPage(cItem['url'])
        if not sts:
            return
        cUrl = self.cm.meta['url']
        self.setMainUrl(cUrl)
        nextPage = ph.find(data, ('<ul', '>', 'pagination'), '</ul>',
                           flags=0)[1]
        nextPage = ph.rfind(nextPage, '>%s</a>' % (page + 1), '<a')[1]
        nextPage = self.getFullUrl(ph.getattr(nextPage, 'href'), cUrl)
        data = ph.find(data, ('<div', '>', 'panel-body'), '</ul>', flags=0)[1]
        data = ph.findall(data.rsplit('pagination-wrap', 1)[0], ('<li', '>'),
                          '</li>',
                          flags=0)
        for item in data:
            icon = ph.find(item, '<img', '>')[1]
            url = self.getFullUrl(ph.search(item, ph.A)[1], cUrl)
            title = ph.clean_html(
                ph.find(item, ('<p', '>'), '</p>', flags=0)[1])
            if not title:
                title = ph.clean_html(ph.getattr(icon, 'title'))
            if not title:
                title = ph.clean_html(ph.getattr(icon, 'alt'))
            icon = self.getFullIconUrl(ph.search(icon, ph.IMG)[1], cUrl)
            self.addDir({
                'good_for_fav': True,
                'category': nextCategory,
                'title': title,
                'url': url,
                'icon': icon
            })

        if nextPage:
            self.addDir(
                MergeDicts(cItem, {
                    'title': _('Next page'),
                    'url': nextPage,
                    'page': page + 1
                }))
 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 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 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)