コード例 #1
0
def findvideos(item):
    logger.info()

    itemlist = list()
    content_id = scrapertools.find_single_match(item.url, "/(\d+)")

    soup = create_soup(item.url)
    try:
        enc_url = soup.find("a",
                            href=re.compile("http://acortaenlace"))["href"]
        url = generictools.convert_url_base64(enc_url)
        itemlist.append(
            Item(channel=item.channel,
                 title="Torrent",
                 url=url,
                 server="torrent",
                 action="play",
                 language="LAT",
                 infoLabels=item.infoLabels))
    except:
        pass

    strm_url = "%swp-json/elifilms/movies/?id=%s" % (host, content_id)

    json_data = httptools.downloadpage(strm_url).json
    for v_data in json_data["data"]["server_list"]:
        url = v_data["link"]
        server = v_data["name"].lower()

        itemlist.append(
            Item(channel=item.channel,
                 title=server.capitalize(),
                 url=url,
                 action="play",
                 language="LAT",
                 infoLabels=item.infoLabels))

    itemlist = servertools.get_servers_itemlist(itemlist)

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

    # Requerido para AutoPlay

    autoplay.start(itemlist, item)

    if item.contentType == 'movie':
        if config.get_videolibrary_support(
        ) and len(itemlist) > 0 and item.extra != 'findvideos':
            itemlist.append(
                Item(
                    channel=item.channel,
                    title=
                    '[COLOR yellow]Añadir esta pelicula a la videoteca[/COLOR]',
                    url=item.url,
                    action="add_pelicula_to_library",
                    extra="findvideos",
                    contentTitle=item.contentTitle))

    return itemlist
コード例 #2
0
ファイル: cinecalidad.py プロジェクト: jswxjj/addon
def findvideos(item):

    logger.info()
    itemlist = []
    duplicados = []

    if 'cinemaqualidade' in item.url:
        lang = 'portugues'
    elif 'espana' in item.url:
        lang = 'castellano'
    elif 'cinecalidad' in item.url:
        lang = 'latino'
    
    data = httptools.downloadpage(item.url).data
    patron = 'target=_blank.*? service=.*? data="(.*?)"><li>(.*?)<\/li>'
    matches = re.compile(patron, re.DOTALL).findall(data)

    patronk = '<a href="(/vip/v.php\?i=.*?")'
    matchesk = re.compile(patronk, re.DOTALL).findall(data)

    server_url = {'yourupload': 'https://www.yourupload.com/embed/%s',
                  'trailer': 'https://www.youtube.com/embed/%s',
                  'bittorrent': '',
                  'mega': 'https://mega.nz/file/%s',
                  'fembed': 'https://www.fembed.com/v/%s',
                  'gounlimited': 'https://gounlimited.to/embed-%s.html',
                  'clipwatching': 'https://clipwatching.com/embed-%s.html',
                  'vidcloud': 'https://vidcloud.co/embed/%s',
                  'jetload': 'https://jetload.net/e/%s',
                  'evoload': 'https://evoload.io/e/%s'}
    
    dec_value = scrapertools.find_single_match(data, 'String\.fromCharCode\(parseInt\(str\[i\]\)-(\d+)\)')
    torrent_link = scrapertools.find_single_match(data, '<a href=".*?/protect/v\.php\?i=([^"]+)"')
    if not torrent_link: torrent_link = scrapertools.find_single_match(data, '<a\s*href="[^"]*?s=([^"]+)"\s*target=[^>]*service=BitTorrent>')
    if not torrent_link: 
        torrent_link = scrapertools.find_single_match(data, '<a\s*href="[^"]*\/go\.php\?u=([^"]+)"\s*target=[^>]*service=BitTorrent>')
        if torrent_link:
            from lib.generictools import convert_url_base64
            torrent_link = convert_url_base64(torrent_link)
    subs = scrapertools.find_single_match(data, '<a id=subsforlink href=(.*?) ')

    for scrapedurl in matchesk:
        
        base_url = host + scrapedurl
        
        headers={'Cookie': 'codigovip=100734121;'}
        protect = httptools.downloadpage(base_url, headers=headers).data
        
        url = scrapertools.find_single_match(protect, 'font-size:1.05em"><a href="([^"]+)')
        server = servertools.get_server_from_url(url)

        title = '(%s)' % server.capitalize()
        quality = '4K'
        language = IDIOMAS[lang]
        if url:
            new_item = Item(channel=item.channel,
                            action='play',
                            title=title,
                            contentTitle=item.contentTitle,
                            url=url,
                            language=language,
                            thumbnail=item.thumbnail,
                            quality=quality,
                            server=server
                            )
            itemlist.append(new_item)
    
    if torrent_link != '':
        headers = {'Referer': item.url}
        """
        base_url = '%s/protect/v.php' % host
        post = {'i': torrent_link, 'title': item.title}
        post = urllib.urlencode(post)
        protect = httptools.downloadpage(base_url + '?' + post, headers=headers).data
        """
        base_url = torrent_link
        if '/protect/v' not in torrent_link: base_url = '%s/protect/v.php?i=%s' % (host, torrent_link)
        protect = httptools.downloadpage(base_url, headers=headers).data
        url = scrapertools.find_single_match(protect, 'value="(magnet.*?)"')
        server = 'torrent'

        title = item.contentTitle + ' (%s)' % server
        quality = '1080p'
        language = IDIOMAS[lang]

        new_item = Item(channel=item.channel,
                        action='play',
                        title=title,
                        contentTitle=item.contentTitle,
                        url=url,
                        language=language,
                        thumbnail=item.thumbnail,
                        quality=quality,
                        server=server
                        )
        itemlist.append(new_item)

    for video_cod, server_id in matches:
        thumbnail = item.thumbnail
        server = server_id.lower()
        if server in server_url and server not in duplicados:
            video_id = dec(video_cod, dec_value)

            url = server_url.get(server, '')
            
            title = '(%s)' % server.capitalize()
            quality = '1080p'
            language = IDIOMAS[lang]
            if url:
                url = url % video_id
                new_item = Item(channel=item.channel,
                                action='play',
                                title=server.capitalize(),
                                contentTitle=item.contentTitle,
                                url=url,
                                language=language,
                                thumbnail=thumbnail,
                                quality=quality,
                                server=server,
                                subtitle=subs
                                )
                itemlist.append(new_item)
                duplicados.append(server)


    # Requerido para FilterTools

    itemlist = filtertools.get_links(itemlist, item, list_language)

    # Requerido para AutoPlay

    autoplay.start(itemlist, item)

    # itemlist.append(trailer_item)
    if config.get_videolibrary_support() and len(itemlist) > 0 and item.extra != 'findvideos':
        itemlist.append(
            Item(channel=item.channel,
                 title='[COLOR yellow]Añadir esta pelicula a la videoteca[/COLOR]',
                 url=item.url,
                 action="add_pelicula_to_library",
                 extra="findvideos",
                 contentTitle=item.contentTitle,
                 ))

    return itemlist
コード例 #3
0
def findvideos(item):
    logger.info()

    itemlist = []
    itemlist_t = []  #Itemlist total de enlaces
    itemlist_f = []  #Itemlist de enlaces filtrados
    matches = []
    data = ''
    response = {'data': data, 'sucess': False, 'code': 0}
    response = type('HTTPResponse', (), response)

    torrent_params = {
        'url': item.url,
        'torrents_path': None,
        'local_torr': item.torrents_path,
        'lookup': False,
        'force': True,
        'data_torrent': True,
        'subtitles': True,
        'file_list': True
    }

    #logger.debug(item)

    #Bajamos los datos de la página
    patron = '<a\s*class="torrent_download[^"]*"\s*href="([^"]+)"'

    if not item.matches:
        data, response, item, itemlist = generictools.downloadpage(
            item.url,
            timeout=timeout,
            canonical=canonical,
            headers=item.headers,
            s2=False,
            patron=patron,
            item=item,
            itemlist=itemlist)  # Descargamos la página

    #Verificamos si se ha cargado una página, y si además tiene la estructura correcta
    if (not data and not item.matches) or response.code == 999:
        if item.emergency_urls and not item.videolibray_emergency_urls:  # Hay urls de emergencia?
            if len(item.emergency_urls) > 1:
                matches = item.emergency_urls[
                    1]  # Restauramos matches de vídeos
            elif len(item.emergency_urls) == 1 and item.emergency_urls[0]:
                matches = item.emergency_urls[
                    0]  # Restauramos matches de vídeos - OLD FORMAT
            item.armagedon = True  # Marcamos la situación como catastrófica
        else:
            if item.videolibray_emergency_urls:  # Si es llamado desde creación de Videoteca...
                return item  # Devolvemos el Item de la llamada
            else:
                return itemlist  # si no hay más datos, algo no funciona, pintamos lo que tenemos

    if not item.armagedon:
        if not item.matches:
            matches = re.compile(patron, re.DOTALL).findall(data)
        else:
            matches = item.matches

    #logger.debug("PATRON: " + patron)
    #logger.debug(matches)
    #logger.debug(data)

    if not matches:  # error
        return itemlist

    # Si es un lookup para cargar las urls de emergencia en la Videoteca...
    if item.videolibray_emergency_urls:
        item.emergency_urls = []  # Iniciamos emergency_urls
        item.emergency_urls.append(
            [])  # Reservamos el espacio para los .torrents locales
        matches_list = []  # Convertimos matches-tuple a matches-list
        for tupla in matches:
            if isinstance(tupla, tuple):
                matches_list.append(list(tupla))
        if matches_list:
            item.emergency_urls.append(
                matches_list)  # Salvamnos matches de los vídeos...
        else:
            item.emergency_urls.append(matches)

    # Llamamos al método para crear el título general del vídeo, con toda la información obtenida de TMDB
    if not item.videolibray_emergency_urls:
        item, itemlist = generictools.post_tmdb_findvideos(item, itemlist)

    # Ahora tratamos los enlaces .torrent con las diferentes calidades
    for x, (scrapedurl) in enumerate(matches):
        scrapedpassword = ''

        #Generamos una copia de Item para trabajar sobre ella
        item_local = item.clone()

        item_local.url = generictools.convert_url_base64(
            scrapedurl, host_torrent)
        if item.videolibray_emergency_urls and item_local.url != scrapedurl:
            item.emergency_urls[1][x][0] = item_local.url

        # Buscamos el enlace definitivo, si es necesario
        if not item_local.url.startswith(
                'magnet') and not item_local.url.endswith('.torrent'):
            patron = '<a\s*id="link"[^>]*href="([^"]+)"'
            data, response, item, itemlist = generictools.downloadpage(
                item_local.url,
                timeout=timeout,
                canonical=canonical,
                s2=False,
                patron=patron,
                item=item,
                itemlist=itemlist)
            item_local.url = scrapertools.find_single_match(data, patron)
            if not item_local.url: continue

        # Restauramos urls de emergencia si es necesario
        local_torr = ''
        if item.emergency_urls and not item.videolibray_emergency_urls:
            try:  # Guardamos la url ALTERNATIVA
                if item.emergency_urls[0][0].startswith(
                        'http') or item.emergency_urls[0][0].startswith('//'):
                    item_local.torrent_alt = generictools.convert_url_base64(
                        item.emergency_urls[0][0], host_torrent)
                else:
                    item_local.torrent_alt = generictools.convert_url_base64(
                        item.emergency_urls[0][0])
            except:
                item_local.torrent_alt = ''
                item.emergency_urls[0] = []
            from core import filetools
            if item.contentType == 'movie':
                FOLDER = config.get_setting("folder_movies")
            else:
                FOLDER = config.get_setting("folder_tvshows")
            if item.armagedon and item_local.torrent_alt:
                item_local.url = item_local.torrent_alt  # Restauramos la url
                if not item.torrent_alt.startswith('http'):
                    local_torr = filetools.join(config.get_videolibrary_path(),
                                                FOLDER, item_local.url)
            if len(item.emergency_urls[0]) > 1:
                del item.emergency_urls[0][0]

        #Buscamos tamaño en el archivo .torrent
        size = ''
        if item_local.torrent_info:
            size = item_local.torrent_info
        if not size and not item.videolibray_emergency_urls and not item_local.url.startswith(
                'magnet:'):
            if not item.armagedon:
                torrent_params['url'] = item_local.url
                torrent_params[
                    'local_torr'] = local_torr or item_local.torrents_path
                torrent_params = generictools.get_torrent_size(
                    item_local.url,
                    torrent_params=torrent_params,
                    item=item_local)
                size = torrent_params['size']
                if torrent_params['torrents_path']:
                    item_local.torrents_path = torrent_params['torrents_path']

                if 'ERROR' in size and item.emergency_urls and not item.videolibray_emergency_urls:
                    item_local.armagedon = True
                    try:  # Restauramos la url
                        if item.emergency_urls[0][0].startswith(
                                'http'
                        ) or item.emergency_urls[0][0].startswith('//'):
                            item_local.url = generictools.convert_url_base64(
                                item.emergency_urls[0][0], host_torrent)
                        else:
                            item_local.url = generictools.convert_url_base64(
                                item.emergency_urls[0][0])
                            if not item.url.startswith('http'):
                                local_torr = filetools.join(
                                    config.get_videolibrary_path(), FOLDER,
                                    item_local.url)
                    except:
                        item_local.torrent_alt = ''
                        item.emergency_urls[0] = []
                    torrent_params['url'] = item_local.url
                    torrent_params['local_torr'] = local_torr
                    torrent_params = generictools.get_torrent_size(
                        item_local.url,
                        torrent_params=torrent_params,
                        item=item_local)
                    size = torrent_params['size']
                    if torrent_params['torrents_path']:
                        item_local.torrents_path = torrent_params[
                            'torrents_path']
        if size:
            size = size.replace('GB', 'G·B').replace('Gb', 'G·b').replace('MB', 'M·B')\
                        .replace('Mb', 'M·b').replace('.', ',')
            item_local.torrent_info = '%s, ' % size  #Agregamos size
        if item_local.url.startswith(
                'magnet:') and not 'Magnet' in item_local.torrent_info:
            item_local.torrent_info += ' Magnet'
        if item_local.torrent_info:
            item_local.torrent_info = item_local.torrent_info.strip().strip(
                ',')
            if item.videolibray_emergency_urls:
                item.torrent_info = item_local.torrent_info
            if not item.unify:
                item_local.torrent_info = '[%s]' % item_local.torrent_info

        # Guadamos la password del RAR
        password = scrapedpassword
        # Si tiene contraseña, la guardamos y la pintamos
        if password or item.password:
            if not item.password: item.password = password
            item_local.password = item.password
            itemlist.append(
                item.clone(
                    action="",
                    title="[COLOR magenta][B] Contraseña: [/B][/COLOR]'" +
                    item_local.password + "'",
                    folder=False))

        # Guardamos urls de emergencia si se viene desde un Lookup de creación de Videoteca
        if item.videolibray_emergency_urls:
            item.emergency_urls[0].append(
                item_local.url)  #guardamos la url y nos vamos
            continue

        if item_local.armagedon:
            item_local.quality = '[COLOR hotpink][E][/COLOR] [COLOR limegreen]%s[/COLOR]' % item_local.quality

        #Ahora pintamos el link del Torrent
        item_local.title = '[[COLOR yellow]?[/COLOR]] [COLOR yellow][Torrent][/COLOR] ' \
                        + '[COLOR limegreen][%s][/COLOR] [COLOR red]%s[/COLOR] %s' % \
                        (item_local.quality, str(item_local.language), \
                        item_local.torrent_info)

        #Preparamos título y calidad, quitando etiquetas vacías
        item_local.title = re.sub(r'\s?\[COLOR \w+\]\[\[?\s?\]?\]\[\/COLOR\]',
                                  '', item_local.title)
        item_local.title = re.sub(r'\s?\[COLOR \w+\]\s?\[\/COLOR\]', '',
                                  item_local.title)
        item_local.title = item_local.title.replace("--", "").replace("[]", "")\
                        .replace("()", "").replace("(/)", "").replace("[/]", "")\
                        .replace("|", "").strip()
        item_local.quality = re.sub(
            r'\s?\[COLOR \w+\]\[\[?\s?\]?\]\[\/COLOR\]', '',
            item_local.quality)
        item_local.quality = re.sub(r'\s?\[COLOR \w+\]\s?\[\/COLOR\]', '',
                                    item_local.quality)
        item_local.quality = item_local.quality.replace("--", "").replace("[]", "")\
                        .replace("()", "").replace("(/)", "").replace("[/]", "")\
                        .replace("|", "").strip()

        if not item_local.torrent_info or 'Magnet' in item_local.torrent_info:
            item_local.alive = "??"  #Calidad del link sin verificar
        elif 'ERROR' in item_local.torrent_info and 'Pincha' in item_local.torrent_info:
            item_local.alive = "ok"  #link en error, CF challenge, Chrome disponible
        elif 'ERROR' in item_local.torrent_info and 'Introduce' in item_local.torrent_info:
            item_local.alive = "??"  #link en error, CF challenge, ruta de descarga no disponible
            item_local.channel = 'setting'
            item_local.action = 'setting_torrent'
            item_local.unify = False
            item_local.folder = False
            item_local.item_org = item.tourl()
        elif 'ERROR' in item_local.torrent_info:
            item_local.alive = "no"  #Calidad del link en error, CF challenge?
        else:
            item_local.alive = "ok"  #Calidad del link verificada
        if item_local.channel != 'setting':
            item_local.action = "play"  #Visualizar vídeo
            item_local.server = "torrent"  #Seridor Torrent

        itemlist_t.append(
            item_local.clone())  #Pintar pantalla, si no se filtran idiomas

        # Requerido para FilterTools
        if config.get_setting(
                'filter_languages',
                channel) > 0:  #Si hay idioma seleccionado, se filtra
            itemlist_f = filtertools.get_link(
                itemlist_f, item_local,
                list_language)  #Pintar pantalla, si no está vacío

        #logger.debug("TORRENT: " + scrapedurl + " / title gen/torr: " + item.title + " / " + item_local.title + " / calidad: " + item_local.quality + " / content: " + item_local.contentTitle + " / " + item_local.contentSerieName)
        #logger.debug(item_local)

    #Si es un lookup para cargar las urls de emergencia en la Videoteca...
    if item.videolibray_emergency_urls:
        return item  #... nos vamos

    if len(itemlist_f) > 0:  #Si hay entradas filtradas...
        itemlist.extend(itemlist_f)  #Pintamos pantalla filtrada
    else:
        if config.get_setting('filter_languages', channel) > 0 and len(
                itemlist_t) > 0:  #Si no hay entradas filtradas ...
            thumb_separador = get_thumb(
                "next.png")  #... pintamos todo con aviso
            itemlist.append(
                Item(
                    channel=item.channel,
                    url=host,
                    title=
                    "[COLOR red][B]NO hay elementos con el idioma seleccionado[/B][/COLOR]",
                    thumbnail=thumb_separador,
                    folder=False))

        if len(itemlist_t) == 0:
            if len(itemlist) == 0 or (len(itemlist) > 0
                                      and itemlist[-1].server != 'torrent'):
                return []
        itemlist.extend(
            itemlist_t)  #Pintar pantalla con todo si no hay filtrado

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

    return itemlist