示例#1
0
文件: vvvvid.py 项目: 4l3x87/addon
def episodios(item):
    itemlist = []
    json_file = current_session.get(item.url, headers=headers,
                                    params=payload).json()
    show_id = str(json_file['data'][0]['show_id'])
    season_id = str(json_file['data'][0]['season_id'])
    episodes = []
    support.log('SEASON ID= ', season_id)
    for episode in json_file['data']:
        episodes.append(episode['episodes'])
    for episode in episodes:
        for key in episode:
            if 'stagione' in encode(key['title']).lower():
                match = support.match(
                    encode(key['title']),
                    patron=r'[Ss]tagione\s*(\d+) - [Ee]pisodio\s*(\d+)').match
                title = match[0] + 'x' + match[1] + ' - ' + item.fulltitle
                make_item = True
            elif int(key['season_id']) == int(season_id):
                try:
                    title = 'Episodio ' + key['number'] + ' - ' + key[
                        'title'].encode('utf8')
                except:
                    title = 'Episodio ' + key['number'] + ' - ' + key['title']
                make_item = True
            else:
                make_item = False
            if make_item == True:
                if type(title) == tuple: title = title[0]
                itemlist.append(
                    Item(channel=item.channel,
                         title=title,
                         fulltitle=item.fulltitle,
                         show=item.show,
                         url=host + show_id + '/season/' +
                         str(key['season_id']) + '/',
                         action='findvideos',
                         video_id=key['video_id'],
                         thumbnail=item.thumbnail,
                         fanart=item.fanart,
                         plot=item.plot,
                         contentType=item.contentType))
    autorenumber.renumber(itemlist, item, 'bold')
    if autorenumber.check(item) == True \
        or support.match(itemlist[0].title, patron=r"(\d+x\d+)").match:
        support.videolibrary(itemlist, item)
    return itemlist
示例#2
0
文件: support.py 项目: iz8mbw/addon
    def wrapper(*args):
        itemlist = []

        args = func(*args)
        function = func.__name__ if not 'actLike' in args else args['actLike']
        # log('STACK= ',inspect.stack()[1][3])

        item = args['item']

        action = args['action'] if 'action' in args else 'findvideos'
        anime = args['anime'] if 'anime' in args else ''
        addVideolibrary = args[
            'addVideolibrary'] if 'addVideolibrary' in args else True
        search = args['search'] if 'search' in args else ''
        blacklist = args['blacklist'] if 'blacklist' in args else []
        data = args['data'] if 'data' in args else ''
        patron = args['patron'] if 'patron' in args else args[
            'patronMenu'] if 'patronMenu' in args else ''
        if 'headers' in args:
            headers = args['headers']
        elif 'headers' in func.__globals__:
            headers = func.__globals__['headers']
        else:
            headers = ''
        patronNext = args['patronNext'] if 'patronNext' in args else ''
        patronBlock = args['patronBlock'] if 'patronBlock' in args else ''
        typeActionDict = args[
            'typeActionDict'] if 'typeActionDict' in args else {}
        typeContentDict = args[
            'typeContentDict'] if 'typeContentDict' in args else {}
        debug = args['debug'] if 'debug' in args else False
        debugBlock = args['debugBlock'] if 'debugBlock' in args else False
        if 'pagination' in args and inspect.stack()[1][3] not in [
                'add_tvshow', 'get_episodes', 'update', 'find_episodes'
        ]:
            pagination = args['pagination'] if args['pagination'] else 20
        else:
            pagination = ''
        lang = args['deflang'] if 'deflang' in args else ''
        pag = item.page if item.page else 1  # pagination
        matches = []

        log('PATRON= ', patron)
        if not data:
            page = httptools.downloadpage(item.url,
                                          headers=headers,
                                          ignore_response_code=True,
                                          session=item.session)
            # if url may be changed and channel has findhost to update
            if (not page.data or scrapertools.get_domain_from_url(
                    page.url) != scrapertools.get_domain_from_url(item.url)
                ) and 'findhost' in func.__globals__:
                host = func.__globals__['findhost']()
                parse = list(urlparse.urlparse(item.url))
                from core import jsontools
                jsontools.update_node(host,
                                      func.__module__.split('.')[-1], 'url')
                parse[1] = scrapertools.get_domain_from_url(host)
                item.url = urlparse.urlunparse(parse)
                page = httptools.downloadpage(item.url,
                                              headers=headers,
                                              ignore_response_code=True,
                                              session=item.session)
            data = page.data.replace("'", '"')
            data = re.sub('\n|\t', ' ', data)
            data = re.sub(r'>\s+<', '> <', data)
            # replace all ' with " and eliminate newline, so we don't need to worry about

        if patronBlock:
            if debugBlock:
                regexDbg(item, patronBlock, headers, data)
            blocks = scrapertools.find_multiple_matches_groups(
                data, patronBlock)
            block = ""
            for bl in blocks:
                # log(len(blocks),bl)
                if 'season' in bl and bl['season']:
                    item.season = bl['season']
                blockItemlist, blockMatches = scrapeBlock(
                    item, args, bl['block'], patron, headers, action,
                    pagination, debug, typeContentDict, typeActionDict,
                    blacklist, search, pag, function, lang)
                for it in blockItemlist:
                    if 'lang' in bl:
                        it.contentLanguage, it.title = scrapeLang(
                            bl, it.contentLanguage, it.title)
                    if 'quality' in bl and bl['quality']:
                        it.quality = bl['quality'].strip()
                        it.title = it.title + typo(bl['quality'].strip(),
                                                   '_ [] color kod')
                itemlist.extend(blockItemlist)
                matches.extend(blockMatches)
        elif patron:
            itemlist, matches = scrapeBlock(item, args, data, patron, headers,
                                            action, pagination, debug,
                                            typeContentDict, typeActionDict,
                                            blacklist, search, pag, function,
                                            lang)

        if 'itemlistHook' in args:
            itemlist = args['itemlistHook'](itemlist)

        if (pagination and len(matches) <= pag * pagination
            ) or not pagination:  # next page with pagination
            if patronNext and inspect.stack()[1][3] != 'newest':
                nextPage(itemlist, item, data, patronNext, function)

        # next page for pagination
        if pagination and len(matches) > pag * pagination and not search:
            if inspect.stack()[1][3] != 'get_newest':
                itemlist.append(
                    Item(channel=item.channel,
                         action=item.action,
                         contentType=item.contentType,
                         title=typo(config.get_localized_string(30992),
                                    'color kod bold'),
                         fulltitle=item.fulltitle,
                         show=item.show,
                         url=item.url,
                         args=item.args,
                         page=pag + 1,
                         thumbnail=thumb()))

        if action != 'play' and function != 'episodios' and 'patronMenu' not in args:
            tmdb.set_infoLabels_itemlist(itemlist, seekTmdb=True)

        from specials import autorenumber
        if anime:
            if function == 'episodios' or item.action == 'episodios':
                autorenumber.renumber(itemlist, item, 'bold')
            else:
                autorenumber.renumber(itemlist)
        if anime and autorenumber.check(
                item) == False and not scrapertools.find_single_match(
                    itemlist[0].title, r'(\d+.\d+)'):
            pass
        else:
            if addVideolibrary and (item.infoLabels["title"]
                                    or item.fulltitle):
                # item.fulltitle = item.infoLabels["title"]
                videolibrary(itemlist, item, function=function)
            if config.get_setting('downloadenabled') and (
                    function == 'episodios' or function == 'findvideos'):
                download(itemlist, item, function=function)

        if 'patronMenu' in args and itemlist:
            itemlist = thumb(itemlist, genre=True)

        if 'fullItemlistHook' in args:
            itemlist = args['fullItemlistHook'](itemlist)

        # itemlist = filterLang(item, itemlist)   # causa problemi a newest

        return itemlist
示例#3
0
    def wrapper(*args):
        function = func.__name__
        itemlist = []

        args = func(*args)
        # log('STACK= ',inspect.stack()[1][3])

        item = args['item']

        action = args['action'] if 'action' in args else 'findvideos'
        anime = args['anime'] if 'anime' in args else ''
        addVideolibrary = args[
            'addVideolibrary'] if 'addVideolibrary' in args else True
        search = args['search'] if 'search' in args else ''
        blacklist = args['blacklist'] if 'blacklist' in args else []
        data = args['data'] if 'data' in args else ''
        patron = args['patron'] if 'patron' in args else args[
            'patronMenu'] if 'patronMenu' in args else ''
        if 'headers' in args:
            headers = args['headers']
        elif 'headers' in func.__globals__:
            headers = func.__globals__['headers']
        else:
            headers = ''
        patronNext = args['patronNext'] if 'patronNext' in args else ''
        patronBlock = args['patronBlock'] if 'patronBlock' in args else ''
        typeActionDict = args[
            'type_action_dict'] if 'type_action_dict' in args else {}
        typeContentDict = args[
            'type_content_dict'] if 'type_content_dict' in args else {}
        debug = args['debug'] if 'debug' in args else False
        log('STACK= ', inspect.stack()[1][3])
        if 'pagination' in args and inspect.stack()[1][3] not in [
                'add_tvshow', 'get_episodes', 'update', 'find_episodes'
        ]:
            pagination = args['pagination'] if args['pagination'] else 20
        else:
            pagination = ''
        lang = args['deflang'] if 'deflang' in args else ''
        pag = item.page if item.page else 1  # pagination
        matches = []

        log('PATRON= ', patron)
        if not data:
            data = httptools.downloadpage(
                item.url, headers=headers,
                ignore_response_code=True).data.replace("'", '"')
            data = re.sub('\n|\t', ' ', data)
            data = re.sub(r'>\s+<', '> <', data)
            # replace all ' with " and eliminate newline, so we don't need to worry about
            log('DATA =', data)

        if patronBlock:
            blocks = scrapertoolsV2.find_multiple_matches_groups(
                data, patronBlock)
            block = ""
            for bl in blocks:
                blockItemlist, blockMatches = scrapeBlock(
                    item, args, bl['block'], patron, headers, action,
                    pagination, debug, typeContentDict, typeActionDict,
                    blacklist, search, pag, function, lang)
                for it in blockItemlist:
                    if 'lang' in bl:
                        it.contentLanguage, it.title = scrapeLang(
                            bl, it.contentLanguage, it.title)
                    if 'quality' in bl and bl['quality']:
                        it.quality = bl['quality'].strip()
                        it.title = it.title + typo(bl['quality'].strip(),
                                                   '_ [] color kod')
                log('BLOCK ', '=', block)
                itemlist.extend(blockItemlist)
                matches.extend(blockMatches)
        elif patron:
            itemlist, matches = scrapeBlock(item, args, data, patron, headers,
                                            action, pagination, debug,
                                            typeContentDict, typeActionDict,
                                            blacklist, search, pag, function,
                                            lang)

        checkHost(item, itemlist)

        if 'itemlistHook' in args:
            itemlist = args['itemlistHook'](itemlist)

        if patronNext:
            nextPage(itemlist, item, data, patronNext, 2)

        # next page for pagination
        if pagination and len(matches) >= pag * pagination:
            if inspect.stack()[1][3] != 'get_newest':
                itemlist.append(
                    Item(channel=item.channel,
                         action=item.action,
                         contentType=item.contentType,
                         title=typo(config.get_localized_string(30992),
                                    'color kod bold'),
                         fulltitle=item.fulltitle,
                         show=item.show,
                         url=item.url,
                         args=item.args,
                         page=pag + 1,
                         thumbnail=thumb()))

        if action != 'play' and function != 'episodios' and 'patronMenu' not in args:
            tmdb.set_infoLabels_itemlist(itemlist, seekTmdb=True)

        from specials import autorenumber
        if anime:
            if function == 'episodios' or item.action == 'episodios':
                autorenumber.renumber(itemlist, item, 'bold')
            else:
                autorenumber.renumber(itemlist)
        if anime and autorenumber.check(item) == False:
            pass
        else:
            if addVideolibrary and (item.infoLabels["title"]
                                    or item.fulltitle):
                # item.fulltitle = item.infoLabels["title"]
                videolibrary(itemlist, item, function=function)
            if config.get_setting('downloadenabled') and (
                    function == 'episodios' or function == 'findvideos'):
                download(itemlist, item, function=function)

        if 'patronMenu' in args:
            itemlist = thumb(itemlist, genre=True)

        if 'fullItemlistHook' in args:
            itemlist = args['fullItemlistHook'](itemlist)

        # itemlist = filterLang(item, itemlist)   # causa problemi a newest

        return itemlist