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

        type = 'tv' if cItem['f_isserie'] else 'movie'
        url = 'https://api.themoviedb.org/3/%s/%s/videos?api_key=%s' % (type, cItem['f_id'], apiKey)

        sts, data = self.getPage(url)
        if not sts: return
        try:
            data = json_loads(data)
            for item in data['results']:
                if item['site'].lower() == 'youtube':
                    title = '[%s][%s] %s ' % (item['iso_3166_1'], item['size'], item['name'])
                    url = 'https://www.youtube.com/watch?v=%s' % item['key']
                    self.addVideo(MergeDicts(cItem, {'good_for_fav': True, 'title':title, 'url':url}))
        except Exception:
            printExc()

        if type == 'tv':
            url = self.getFullUrl('/serie/%s' % cItem['f_id'])
            sts, data = self.getPage(url)
            if not sts: return
            try:
                data = ph.find(data, 'gotoFuchaCrazy', '</script>', flags=0)[1]
                data = data[data.find('{'):data.rfind('}')+1]
                data = json_loads(data)
                sTitle = data['result']['info']['title']
                sIcon = self.getFullIconUrl(data['result']['info']['cover'])

                for seasonData in data['result']['episodes']:
                    sNum = str(seasonData['season'])
                    sEpisodes = ''
                    subItems = []
                    for item in seasonData['episodesList']:
                        eNum = str(item['episode'])
                        sEpisodes = str(item['episodes'])

                        icon = self.getFullIconUrl(item['cover'])
                        if not icon: icon = sIcon

                        title = '%s: s%se%s %s' % (sTitle, sNum.zfill(2), eNum.zfill(2), item['name'])
                        type = _('Episode')
                        desc = [type]
                        desc.append(item['dateText'])
                        desc = ' | '.join(desc) + '[/br]' + item['sinopsis']

                        params = {'f_type':type, 'f_isepisode':1, 'f_date':item['dateText'], 'f_sinopsis':item['sinopsis'], 'f_season':sNum, 'f_episode':eNum}
                        params = MergeDicts(cItem, {'good_for_fav':True, 'type':'video', 'title':title, 'icon':icon, 'desc':desc, 'f_eid':item['id']}, params) 
                        params.pop('f_seasons')
                        params.pop('f_episodes')

                        key =  '%sx%sx%s' % (cItem['f_id'], params['f_episode'].zfill(2), params['f_season'].zfill(2))
                        subItems.append( params )

                    if len(subItems):
                        params = {'f_type':_('Season'), 'f_isseason':1, 'f_season':sNum}
                        params = MergeDicts(cItem, {'good_for_fav':False, 'category':nextCategory, 'sub_items':subItems, 'title':_('Season %s (%s)') % (sNum.zfill(2), sEpisodes), 'icon':sIcon}, params) 
                        self.addDir( params )
            except Exception:
                printExc()
        else:
            self.addVideo( MergeDicts(cItem) )
    def getVideoLinks(self, videoUrl):
        printDBG('Movs4uCOM.getVideoLinks [%s]' % videoUrl)
        videoUrl = strwithmeta(videoUrl)
        urlTab = []
        orginUrl = str(videoUrl)
        if len(self.cacheLinks.keys()):
            for key in self.cacheLinks:
                for idx in range(len(self.cacheLinks[key])):
                    if videoUrl in self.cacheLinks[key][idx]['url']:
                        if not self.cacheLinks[key][idx]['name'].startswith(
                                '*'):
                            self.cacheLinks[key][idx][
                                'name'] = '*' + self.cacheLinks[key][idx][
                                    'name']
                        break

        if '#_' in videoUrl:
            post_data = MergeDicts(videoUrl.meta['link_data'],
                                   {'action': 'doo_player_ajax'})
            if 'url' in post_data:
                post_data['curl'] = post_data.pop('url')
            url = self.getFullUrl('/wp-admin/admin-ajax.php')
            sts, data = self.getPage(url, post_data=post_data)
            if not sts:
                return urlTab
            tmp = ph.IFRAME.findall(data)
            for item in tmp:
                url = self.getFullUrl(item[1])
                if 1 == self.up.checkHostSupport(url):
                    urlTab.extend(self.up.getVideoLinkExt(url))
                else:
                    printDBG('>> SKIPPED: %s' % url)

            return urlTab
        sts, data = self.cm.getPage(videoUrl, self.defaultParams)
        videoUrl = self.cm.meta.get('url', videoUrl)
        if self.up.getDomain(
                self.getMainUrl()) in videoUrl or self.up.getDomain(
                    videoUrl) == self.up.getDomain(orginUrl):
            if not sts:
                return []
            found = False
            printDBG(data)
            tmp = re.compile('<iframe[^>]+?src=[\'"]([^"^\']+?)[\'"]',
                             re.IGNORECASE).findall(data)
            for url in tmp:
                if 1 == self.up.checkHostSupport(url):
                    videoUrl = url
                    found = True
                    break

            if not found or 'flashx' in videoUrl:
                tmp = self.cm.ph.getAllItemsBeetwenMarkers(
                    data, 'embedFrame', '</a>')
                for urlItem in tmp:
                    url = self.cm.ph.getSearchGroups(
                        urlItem, 'href=[\'"](https?://[^\'^"]+?)[\'"]')[0]
                    if 1 == self.up.checkHostSupport(url):
                        videoUrl = url
                        found = True
                        break

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