예제 #1
0
파일: support.py 프로젝트: iz8mbw/addon
def filterLang(item, itemlist):
    # import channeltools
    list_language = channeltools.get_lang(item.channel)
    if len(list_language) > 1:
        from specials import filtertools
        itemlist = filtertools.get_links(itemlist, item, list_language)
    return itemlist
예제 #2
0
def episodios(item):
    ##    import web_pdb; web_pdb.set_trace()
    support.log("episodios")
    itemlist = []

    # Carica la pagina
    data = httptools.downloadpage(item.url).data
    #========
    if 'clicca qui per aprire' in data.lower():
        item.url = scrapertoolsV2.find_single_match(data, '"go_to":"([^"]+)"')
        item.url = item.url.replace("\\", "")
        # Carica la pagina
        data = httptools.downloadpage(item.url).data
    elif 'clicca qui</span>' in data.lower():
        item.url = scrapertoolsV2.find_single_match(
            data, '<h2 style="text-align: center;"><a href="([^"]+)">')
        # Carica la pagina
        data = httptools.downloadpage(item.url).data
    #=========
    patron = r'(?:<\/span>\w+ STAGIONE\s\d+ (?:\()?(ITA|SUB ITA)(?:\))?<\/div>'\
             '<div class="su-spoiler-content su-clearfix" style="display:none">|'\
             '(?:\s|\Wn)?(?:<strong>)?(\d+&#.*?)(?:|–)?<a\s(.*?)<\/a><br\s\/>)'
    ##    '(?:<\/span>\w+ STAGIONE\s\d+ (?:\()?(ITA|SUB ITA)(?:\))?'\
    ##             '<\/div><div class="su-spoiler-content su-clearfix" style="display:none">|'\
    ##             '(?:\s|\Wn)?(?:<strong>)?(\d[&#].*?)(?:–|\W)?<a\s(.*?)<\/a><br\s\/>)'
    ##    '(?:<\/span>\w+ STAGIONE\s\d+ (?:\()?(ITA|SUB ITA)(?:\))?<\/div>'\
    ##             '<div class="su-spoiler-content su-clearfix" style="display:none">|'\
    ##             '\s(?:<strong>)?(\d[&#].*?)–<a\s(.*?)<\/a><br\s\/>)'
    listGroups = ['lang', 'title', 'url']
    itemlist = support.scrape(item,
                              data=data,
                              patron=patron,
                              listGroups=listGroups,
                              action='findvideos')

    # Permette la configurazione della videoteca senza andare nel menu apposito
    # così si possono Attivare/Disattivare le impostazioni direttamente dalla
    # pagina delle puntate
    itemlist.append(
        Item(
            channel='setting',
            action="channel_config",
            title=support.typo("Configurazione Videoteca color lime"),
            plot=
            'Filtra per lingua utilizzando la configurazione della videoteca.\
                     Escludi i video in sub attivando "Escludi streams... " e aggiungendo sub in Parole',
            config='videolibrary',  #item.channel,
            folder=False,
            thumbnail=channelselector.get_thumb('setting_0.png')))

    itemlist = filtertools.get_links(itemlist, item, list_language)
    return itemlist
예제 #3
0
def findvideos(item):
    logger.info("%s mainlist findvideos_film log: %s" % (__channel__, item))
    itemlist = []

    # scarico la pagina
    data = httptools.downloadpage(item.url, headers=headers).data
    # da qui fare le opportuni modifiche
    patron = '<a href="#" data-link="(.*?)">'
    matches = scrapertools.find_multiple_matches(data, patron)

    for scrapedurl in matches:
        logger.info("altadefinizione01_club scrapedurl log: %s" % scrapedurl)
        try:
            itemlist = servertools.find_video_items(data=data)

            for videoitem in itemlist:
                logger.info("Videoitemlist2: %s" % videoitem)
                videoitem.title = "%s [%s]" % (item.contentTitle,
                                               videoitem.title)
                videoitem.show = item.show
                videoitem.contentTitle = item.contentTitle
                videoitem.contentType = item.contentType
                videoitem.channel = item.channel
                videoitem.year = item.infoLabels['year']
                videoitem.infoLabels['plot'] = item.infoLabels['plot']
        except AttributeError:
            logger.error("data doesn't contain expected URL")

    # Controlla se i link sono validi
    if checklinks:
        itemlist = servertools.check_list_links(itemlist, checklinks_number)

    # Requerido para FilterTools
    itemlist = filtertools.get_links(itemlist, item, list_language)

    # Requerido para AutoPlay
    autoplay.start(itemlist, item)

    # Aggiunge alla videoteca
    if item.extra != 'findvideos' and item.extra != "library" and config.get_videolibrary_support(
    ) and len(itemlist) != 0:
        support.videolibrary(itemlist, item)

    return itemlist
예제 #4
0
    def wrapper(*args):
        function = func.__name__
        itemlist = []

        args = func(*args)

        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
        if 'pagination' in args:
            pagination = args['pagination'] if args['pagination'] else 20
        else:
            pagination = ''
        list_language = func.__globals__[
            'list_language'] if 'list_language' in func.__globals__ 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('>\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)
                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']
                        it.title = it.title + typo(bl['quality'],
                                                   '_ [] 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)

        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:
            itemlist.append(
                Item(channel=item.channel,
                     action=item.action,
                     contentType=item.contentType,
                     title=typo(config.get_localized_string(30992),
                                'color kod bold'),
                     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)

        if anime:
            from specials import autorenumber
            if function == 'episodios' or item.action == 'episodios':
                autorenumber.renumber(itemlist, item, 'bold')
            else:
                autorenumber.renumber(itemlist)

        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 == 'finvideos'):
            download(itemlist, item, function=function)

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

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

        filterLang = False
        for item in itemlist:
            if item.contentLanguage:
                filterLang = True
                break

        if list_language and filterLang:
            log('Lista Lingue = ', list_language)
            from specials import filtertools
            return filtertools.get_links(itemlist, item, list_language)
        else:
            return itemlist