Página 34 de 95

Re: Italian channels issues and development

Publicado: 26 Ago 2015, 20:11
por robalo
zanzibar1982 escribió:Sometimes I look around into all pelisalacarta system files looking for that "El fichero ha sido borrado" or "No hay nada para reproducir". Where are they?
Hola.
That kind of information is written to the connector in the 'test_video_exists' function. Not all connectors have this feature.

When the connector fails and there is no such function or exists but does not control some of the messages returned by the web page then displays a message "Se ha producido un error en....".
This message is in the servertools.py file

Código: Seleccionar todo

            return video_urls,False,"Se ha producido un error en<br/>el conector con "+server
If there is an error in the connector of syntax or connector is not the server list will then display a message "No hay nada para reproducir".
This message is in the launcher.py file

Código: Seleccionar todo

                            ok = ventana_error.ok ("plugin", "No hay nada para reproducir")

Re: Italian channels issues and development

Publicado: 26 Ago 2015, 22:16
por fenice82
I'm trying to get a connector for Altadefinizione.click... this site use Cloudflare, so I used the connector of italianstreaming as base.

I was able to create the tree of the folders but I don't have any movie.

could you explain me where I'm wrong?

Código: Seleccionar todo

# -*- coding: utf-8 -*-
# ------------------------------------------------------------
# pelisalacarta - XBMC Plugin

# Canal para altadefinizioneclick
# http://blog.tvalacarta.info/plugin-xbmc/pelisalacarta/
# ------------------------------------------------------------
import urlparse, urllib2, urllib, re
import os, sys
import urllib2
import urlparse
import re
import sys
import binascii
import time

from core import logger
from core import config
from core import scrapertools
from core.item import Item
from servers import servertools

__channel__ = "altadefinizioneclick"
__category__ = "F,S,A"
__type__ = "generic"
__title__ = "AltaDefinizioneclick"
__language__ = "IT"

sito = "http://www.altadefinizione.click/"

headers = [
    ['User-Agent', 'Mozilla/5.0 (Windows NT 10.0; WOW64; rv:40.0) Gecko/20100101 Firefox/40.0'],
    ['Accept-Encoding', 'gzip, deflate'],
    ['Referer', 'http://altadefinizione.click/'],
    ['Connection', 'keep-alive']
]

DEBUG = config.get_setting("debug")


def isGeneric():
    return True


def mainlist(item):
    logger.info("pelisalacarta.altadefinizioneclick mainlist")

    itemlist = [Item(channel=__channel__,
                     title="[COLOR azure]Al Cinema[/COLOR]",
                     action="peliculas",

                     url=sito+"al-cinema/",
                     thumbnail="http://dc584.4shared.com/img/XImgcB94/s7/13feaf0b538/saquinho_de_pipoca_01"),
				Item(channel=__channel__,
                     title="[COLOR azure]Nuove Uscite[/COLOR]",
                     action="peliculas",
                     url=sito+"nuove-uscite/",
                     thumbnail="http://i.imgur.com/Jsw7Abj.png"),
                Item(channel=__channel__,
                     title="[COLOR azure]Film Sub-Ita[/COLOR]",
                     action="peliculas",
                     url=sito+"sub-ita/",
                     thumbnail="http://i.imgur.com/qUENzxl.png"),
                Item(channel=__channel__,
                     title="[COLOR azure]Categorie film[/COLOR]",
                     action="categorias1",
                     url=sito,
                     thumbnail="http://xbmc-repo-ackbarr.googlecode.com/svn/trunk/dev/skin.cirrus%20extended%20v2/extras/moviegenres/All%20Movies%20by%20Genre.png"),
				Item(channel=__channel__,
                     title="[COLOR azure]Anno[/COLOR]",
                     action="categorias2",
                     url=sito,
                     thumbnail="http://xbmc-repo-ackbarr.googlecode.com/svn/trunk/dev/skin.cirrus%20extended%20v2/extras/moviegenres/All%20Movies%20by%20Genre.png"),	 
				Item(channel=__channel__,
                     title="[COLOR azure]Qualità[/COLOR]",
                     action="categorias3",
                     url=sito,
                     thumbnail="http://xbmc-repo-ackbarr.googlecode.com/svn/trunk/dev/skin.cirrus%20extended%20v2/extras/moviegenres/All%20Movies%20by%20Genre.png"),	 
				Item(channel=__channel__,
                     title="[COLOR yellow]Cerca...[/COLOR]",
                     action="search",
                     thumbnail="http://dc467.4shared.com/img/fEbJqOum/s7/13feaf0c8c0/Search")]

    return itemlist


def peliculas(item):
    logger.info("pelisalacarta.altadefinizioneclick peliculas")
    itemlist = []

    # Descarga la pagina
    data = anti_cloudflare(item.url)
	
	    ## ------------------------------------------------
    cookies = ""
    matches = re.compile( '(.altadefinizione.click.*?)\n', re.DOTALL ).findall( config.get_cookie_data() )
    for cookie in matches:
        name = cookie.split( '\t' )[5]
        value = cookie.split( '\t' )[6]
        cookies+= name + "=" + value + ";"
    headers.append( ['Cookie',cookies[:-1]] )
    import urllib
    _headers = urllib.urlencode( dict( headers ) )
    ## ------------------------------------------------

    # Extrae las entradas (carpetas)
    patron = '<a\s+href="([^"]+)">\s+<img\s+width="[^"]*"\s+height="[^"]*"\s+src="([^"]+)"\s+class="[^"]*"\s+alt="([^"]+)"'
    matches = re.compile(patron, re.DOTALL).findall(data)
    scrapertools.printMatches(matches)

    for scrapedurl, scrapedthumbnail, scrapedtitle in matches:
        html = scrapertools.cache_page(scrapedurl)
        start = html.find("<div class=\"aciklama\">")
        end = html.find("<div class=\'bMavi\'>Titolo originale:", start)
        scrapedplot = html[start:end]
        scrapedtitle = scrapertools.decodeHtmlentities(scrapedtitle.replace("Streaming", ""))
        scrapedplot = re.sub(r'<[^>]*>', '', scrapedplot)
        scrapedplot = scrapertools.decodeHtmlentities(scrapedplot)
        if DEBUG: logger.info("title=[" + scrapedtitle + "], url=[" + scrapedurl + "], thumbnail=[" + scrapedthumbnail + "]")
		
		 ## ------------------------------------------------
        scrapedthumbnail+= "|" + _headers
        ## ------------------------------------------------
		
        itemlist.append(
            Item(channel=__channel__,
                 action="findvid",
                 title="[COLOR azure]" + scrapedtitle + "[/COLOR]",
                 url=scrapedurl,
                 viewmode="movie_with_plot",
                 thumbnail=scrapedthumbnail,
                 plot=scrapedplot,
                 folder=True))

    # Extrae el paginador
    patronvideos = 'class="nextpostslink" rel="next" href="([^"]+)">&raquo;'
    matches = re.compile(patronvideos, re.DOTALL).findall(data)
    scrapertools.printMatches(matches)

    if len(matches) > 0:
        scrapedurl = urlparse.urljoin(item.url, matches[0])
        itemlist.append(
            Item(channel=__channel__,
                 action="peliculas",
                 title="[COLOR orange]Successivo >>[/COLOR]",
                 url=scrapedurl,
                 thumbnail="http://2.bp.blogspot.com/-fE9tzwmjaeQ/UcM2apxDtjI/AAAAAAAAeeg/WKSGM2TADLM/s1600/pager+old.png",
                 folder=True))

    return itemlist


def categorias1(item):
    logger.info("pelisalacarta.altadefinizioneclick categorias")
    itemlist = []

    data = anti_cloudflare(item.url)
    logger.info(data)

    # Narrow search by selecting only the combo
    bloque = scrapertools.get_match(data, '<ul class="listSubCat" id="Film">(.*?)</ul>')

    # The categories are the options for the combo  
    patron = '<li><a href="([^"]+)">([^<]+)</a></li>'
    matches = re.compile(patron, re.DOTALL).findall(bloque)
    scrapertools.printMatches(matches)

    for url, titulo in matches:
        scrapedtitle = titulo
        scrapedurl = urlparse.urljoin(item.url, url)
        scrapedthumbnail = ""
        scrapedplot = ""
        if DEBUG: logger.info("title=[" + scrapedtitle + "], url=[" + scrapedurl + "], thumbnail=[" + scrapedthumbnail + "]")
        itemlist.append(
            Item(channel=__channel__,
                 action="peliculas",
                 title="[COLOR azure]" + scrapedtitle + "[/COLOR]",
                 url=scrapedurl,
                 thumbnail=scrapedthumbnail,
                 plot=scrapedplot))

    return itemlist

def categorias2(item):
    logger.info("pelisalacarta.altadefinizioneclick categorias")
    itemlist = []

    data = anti_cloudflare(item.url)
    logger.info(data)

    # Narrow search by selecting only the combo
    bloque = scrapertools.get_match(data, '<ul class="listSubCat" id="Anno">(.*?)</ul>')

    # The categories are the options for the combo  
    patron = '<li><a href="([^"]+)">([^<]+)</a></li>'
    matches = re.compile(patron, re.DOTALL).findall(bloque)
    scrapertools.printMatches(matches)

    for url, titulo in matches:
        scrapedtitle = titulo
        scrapedurl = urlparse.urljoin(item.url, url)
        scrapedthumbnail = ""
        scrapedplot = ""
        if DEBUG: logger.info("title=[" + scrapedtitle + "], url=[" + scrapedurl + "], thumbnail=[" + scrapedthumbnail + "]")
        itemlist.append(
            Item(channel=__channel__,
                 action="peliculas",
                 title="[COLOR azure]" + scrapedtitle + "[/COLOR]",
                 url=scrapedurl,
                 thumbnail=scrapedthumbnail,
                 plot=scrapedplot))

    return itemlist

def categorias3(item):
    logger.info("pelisalacarta.altadefinizioneclick categorias")
    itemlist = []

    data = anti_cloudflare(item.url)
    logger.info(data)

    # Narrow search by selecting only the combo
    bloque = scrapertools.get_match(data, '<ul class="listSubCat" id="Qualita">(.*?)</ul>')

    # The categories are the options for the combo  
    patron = '<li><a href="([^"]+)">([^<]+)</a></li>'
    matches = re.compile(patron, re.DOTALL).findall(bloque)
    scrapertools.printMatches(matches)

    for url, titulo in matches:
        scrapedtitle = titulo
        scrapedurl = urlparse.urljoin(item.url, url)
        scrapedthumbnail = ""
        scrapedplot = ""
        if DEBUG: logger.info("title=[" + scrapedtitle + "], url=[" + scrapedurl + "], thumbnail=[" + scrapedthumbnail + "]")
        itemlist.append(
            Item(channel=__channel__,
                 action="peliculas",
                 title="[COLOR azure]" + scrapedtitle + "[/COLOR]",
                 url=scrapedurl,
                 thumbnail=scrapedthumbnail,
                 plot=scrapedplot))

    return itemlist
	
def search(item, texto):
    logger.info("[altadefinizioneclick.py] " + item.url + " search " + texto)
    item.url = "%s?s=%s" % (sito, texto)
    try:
        return peliculas(item)
    # Se captura la excepción, para no interrumpir al buscador global si un canal falla
    except:
        import sys
        for line in sys.exc_info():
            logger.error("%s" % line)
        return []


def findvid(item):
    logger.info("[altadefinizioneclick.py] findvideos")

    ## Descarga la página
    data = scrapertools.cache_page(item.url)
    data = scrapertools.find_single_match(data, "(eval.function.p,a,c,k,e,.*?)\s*</script>")
    if data != "":
        from lib.jsbeautifier.unpackers import packer
        data = packer.unpack(data).replace(r'\\/', '/')
        itemlist = servertools.find_video_items(data=data)

        for videoitem in itemlist:
            videoitem.title = "".join([item.title, videoitem.title])
            videoitem.fulltitle = item.fulltitle
            videoitem.thumbnail = item.thumbnail
            videoitem.channel = __channel__
    else:
        itemlist = servertools.find_video_items(item=item)

    return itemlist
	
def anti_cloudflare(url):
    # global headers

    try:
        resp_headers = scrapertools.get_headers_from_response(url, headers=headers)
        resp_headers = {v[0]: v[1] for v in resp_headers}
    except urllib2.HTTPError, e:
        resp_headers = e.headers

    if 'refresh' in resp_headers:
        time.sleep(int(resp_headers['refresh'][:1]))

        # dict_headers = {v[0]: v[1] for v in headers}
        # dict_headers['cookie'] = resp_headers['set-cookie'].split(';')[0]

        # resp_headers = scrapertools.get_headers_from_response(sito + resp_headers['refresh'][7:], headers=[[k, v] for k, v in dict_headers.iteritems()])
        scrapertools.get_headers_from_response(sito + resp_headers['refresh'][7:], headers=headers)
        # resp_headers = {v[0]: v[1] for v in resp_headers}

        # dict_headers['cookie'] = dict_headers['cookie'] + resp_headers['set-cookie'].split(';')[0]
        # headers = [[k, v] for k, v in dict_headers.iteritems()]

    return scrapertools.cache_page(url, headers=headers)

Re: Italian channels issues and development

Publicado: 26 Ago 2015, 23:34
por fenice82
about italiastreaming.co there aren't playable links

Re: Italian channels issues and development

Publicado: 26 Ago 2015, 23:44
por zanzibar1982
fenice82 escribió:I'm trying to get a connector for Altadefinizione.click... this site use Cloudflare, so I used the connector of italianstreaming as base.

I was able to create the tree of the folders but I don't have any movie.

could you explain me where I'm wrong?

Código: Seleccionar todo

# -*- coding: utf-8 -*-
# ------------------------------------------------------------
# pelisalacarta - XBMC Plugin

# Canal para altadefinizioneclick
# http://blog.tvalacarta.info/plugin-xbmc/pelisalacarta/
# ------------------------------------------------------------
import urlparse, urllib2, urllib, re
import os, sys
import urllib2
import urlparse
import re
import sys
import binascii
import time

from core import logger
from core import config
from core import scrapertools
from core.item import Item
from servers import servertools

__channel__ = "altadefinizioneclick"
__category__ = "F,S,A"
__type__ = "generic"
__title__ = "AltaDefinizioneclick"
__language__ = "IT"

sito = "http://www.altadefinizione.click/"

headers = [
    ['User-Agent', 'Mozilla/5.0 (Windows NT 10.0; WOW64; rv:40.0) Gecko/20100101 Firefox/40.0'],
    ['Accept-Encoding', 'gzip, deflate'],
    ['Referer', 'http://altadefinizione.click/'],
    ['Connection', 'keep-alive']
]

DEBUG = config.get_setting("debug")


def isGeneric():
    return True


def mainlist(item):
    logger.info("pelisalacarta.altadefinizioneclick mainlist")

    itemlist = [Item(channel=__channel__,
                     title="[COLOR azure]Al Cinema[/COLOR]",
                     action="peliculas",

                     url=sito+"al-cinema/",
                     thumbnail="http://dc584.4shared.com/img/XImgcB94/s7/13feaf0b538/saquinho_de_pipoca_01"),
				Item(channel=__channel__,
                     title="[COLOR azure]Nuove Uscite[/COLOR]",
                     action="peliculas",
                     url=sito+"nuove-uscite/",
                     thumbnail="http://i.imgur.com/Jsw7Abj.png"),
                Item(channel=__channel__,
                     title="[COLOR azure]Film Sub-Ita[/COLOR]",
                     action="peliculas",
                     url=sito+"sub-ita/",
                     thumbnail="http://i.imgur.com/qUENzxl.png"),
                Item(channel=__channel__,
                     title="[COLOR azure]Categorie film[/COLOR]",
                     action="categorias1",
                     url=sito,
                     thumbnail="http://xbmc-repo-ackbarr.googlecode.com/svn/trunk/dev/skin.cirrus%20extended%20v2/extras/moviegenres/All%20Movies%20by%20Genre.png"),
				Item(channel=__channel__,
                     title="[COLOR azure]Anno[/COLOR]",
                     action="categorias2",
                     url=sito,
                     thumbnail="http://xbmc-repo-ackbarr.googlecode.com/svn/trunk/dev/skin.cirrus%20extended%20v2/extras/moviegenres/All%20Movies%20by%20Genre.png"),	 
				Item(channel=__channel__,
                     title="[COLOR azure]Qualità[/COLOR]",
                     action="categorias3",
                     url=sito,
                     thumbnail="http://xbmc-repo-ackbarr.googlecode.com/svn/trunk/dev/skin.cirrus%20extended%20v2/extras/moviegenres/All%20Movies%20by%20Genre.png"),	 
				Item(channel=__channel__,
                     title="[COLOR yellow]Cerca...[/COLOR]",
                     action="search",
                     thumbnail="http://dc467.4shared.com/img/fEbJqOum/s7/13feaf0c8c0/Search")]

    return itemlist


def peliculas(item):
    logger.info("pelisalacarta.altadefinizioneclick peliculas")
    itemlist = []

    # Descarga la pagina
    data = anti_cloudflare(item.url)
	
	    ## ------------------------------------------------
    cookies = ""
    matches = re.compile( '(.altadefinizione.click.*?)\n', re.DOTALL ).findall( config.get_cookie_data() )
    for cookie in matches:
        name = cookie.split( '\t' )[5]
        value = cookie.split( '\t' )[6]
        cookies+= name + "=" + value + ";"
    headers.append( ['Cookie',cookies[:-1]] )
    import urllib
    _headers = urllib.urlencode( dict( headers ) )
    ## ------------------------------------------------

    # Extrae las entradas (carpetas)
    patron = '<a\s+href="([^"]+)">\s+<img\s+width="[^"]*"\s+height="[^"]*"\s+src="([^"]+)"\s+class="[^"]*"\s+alt="([^"]+)"'
    matches = re.compile(patron, re.DOTALL).findall(data)
    scrapertools.printMatches(matches)

    for scrapedurl, scrapedthumbnail, scrapedtitle in matches:
        html = scrapertools.cache_page(scrapedurl)
        start = html.find("<div class=\"aciklama\">")
        end = html.find("<div class=\'bMavi\'>Titolo originale:", start)
        scrapedplot = html[start:end]
        scrapedtitle = scrapertools.decodeHtmlentities(scrapedtitle.replace("Streaming", ""))
        scrapedplot = re.sub(r'<[^>]*>', '', scrapedplot)
        scrapedplot = scrapertools.decodeHtmlentities(scrapedplot)
        if DEBUG: logger.info("title=[" + scrapedtitle + "], url=[" + scrapedurl + "], thumbnail=[" + scrapedthumbnail + "]")
		
		 ## ------------------------------------------------
        scrapedthumbnail+= "|" + _headers
        ## ------------------------------------------------
		
        itemlist.append(
            Item(channel=__channel__,
                 action="findvid",
                 title="[COLOR azure]" + scrapedtitle + "[/COLOR]",
                 url=scrapedurl,
                 viewmode="movie_with_plot",
                 thumbnail=scrapedthumbnail,
                 plot=scrapedplot,
                 folder=True))

    # Extrae el paginador
    patronvideos = 'class="nextpostslink" rel="next" href="([^"]+)">&raquo;'
    matches = re.compile(patronvideos, re.DOTALL).findall(data)
    scrapertools.printMatches(matches)

    if len(matches) > 0:
        scrapedurl = urlparse.urljoin(item.url, matches[0])
        itemlist.append(
            Item(channel=__channel__,
                 action="peliculas",
                 title="[COLOR orange]Successivo >>[/COLOR]",
                 url=scrapedurl,
                 thumbnail="http://2.bp.blogspot.com/-fE9tzwmjaeQ/UcM2apxDtjI/AAAAAAAAeeg/WKSGM2TADLM/s1600/pager+old.png",
                 folder=True))

    return itemlist


def categorias1(item):
    logger.info("pelisalacarta.altadefinizioneclick categorias")
    itemlist = []

    data = anti_cloudflare(item.url)
    logger.info(data)

    # Narrow search by selecting only the combo
    bloque = scrapertools.get_match(data, '<ul class="listSubCat" id="Film">(.*?)</ul>')

    # The categories are the options for the combo  
    patron = '<li><a href="([^"]+)">([^<]+)</a></li>'
    matches = re.compile(patron, re.DOTALL).findall(bloque)
    scrapertools.printMatches(matches)

    for url, titulo in matches:
        scrapedtitle = titulo
        scrapedurl = urlparse.urljoin(item.url, url)
        scrapedthumbnail = ""
        scrapedplot = ""
        if DEBUG: logger.info("title=[" + scrapedtitle + "], url=[" + scrapedurl + "], thumbnail=[" + scrapedthumbnail + "]")
        itemlist.append(
            Item(channel=__channel__,
                 action="peliculas",
                 title="[COLOR azure]" + scrapedtitle + "[/COLOR]",
                 url=scrapedurl,
                 thumbnail=scrapedthumbnail,
                 plot=scrapedplot))

    return itemlist

def categorias2(item):
    logger.info("pelisalacarta.altadefinizioneclick categorias")
    itemlist = []

    data = anti_cloudflare(item.url)
    logger.info(data)

    # Narrow search by selecting only the combo
    bloque = scrapertools.get_match(data, '<ul class="listSubCat" id="Anno">(.*?)</ul>')

    # The categories are the options for the combo  
    patron = '<li><a href="([^"]+)">([^<]+)</a></li>'
    matches = re.compile(patron, re.DOTALL).findall(bloque)
    scrapertools.printMatches(matches)

    for url, titulo in matches:
        scrapedtitle = titulo
        scrapedurl = urlparse.urljoin(item.url, url)
        scrapedthumbnail = ""
        scrapedplot = ""
        if DEBUG: logger.info("title=[" + scrapedtitle + "], url=[" + scrapedurl + "], thumbnail=[" + scrapedthumbnail + "]")
        itemlist.append(
            Item(channel=__channel__,
                 action="peliculas",
                 title="[COLOR azure]" + scrapedtitle + "[/COLOR]",
                 url=scrapedurl,
                 thumbnail=scrapedthumbnail,
                 plot=scrapedplot))

    return itemlist

def categorias3(item):
    logger.info("pelisalacarta.altadefinizioneclick categorias")
    itemlist = []

    data = anti_cloudflare(item.url)
    logger.info(data)

    # Narrow search by selecting only the combo
    bloque = scrapertools.get_match(data, '<ul class="listSubCat" id="Qualita">(.*?)</ul>')

    # The categories are the options for the combo  
    patron = '<li><a href="([^"]+)">([^<]+)</a></li>'
    matches = re.compile(patron, re.DOTALL).findall(bloque)
    scrapertools.printMatches(matches)

    for url, titulo in matches:
        scrapedtitle = titulo
        scrapedurl = urlparse.urljoin(item.url, url)
        scrapedthumbnail = ""
        scrapedplot = ""
        if DEBUG: logger.info("title=[" + scrapedtitle + "], url=[" + scrapedurl + "], thumbnail=[" + scrapedthumbnail + "]")
        itemlist.append(
            Item(channel=__channel__,
                 action="peliculas",
                 title="[COLOR azure]" + scrapedtitle + "[/COLOR]",
                 url=scrapedurl,
                 thumbnail=scrapedthumbnail,
                 plot=scrapedplot))

    return itemlist
	
def search(item, texto):
    logger.info("[altadefinizioneclick.py] " + item.url + " search " + texto)
    item.url = "%s?s=%s" % (sito, texto)
    try:
        return peliculas(item)
    # Se captura la excepción, para no interrumpir al buscador global si un canal falla
    except:
        import sys
        for line in sys.exc_info():
            logger.error("%s" % line)
        return []


def findvid(item):
    logger.info("[altadefinizioneclick.py] findvideos")

    ## Descarga la página
    data = scrapertools.cache_page(item.url)
    data = scrapertools.find_single_match(data, "(eval.function.p,a,c,k,e,.*?)\s*</script>")
    if data != "":
        from lib.jsbeautifier.unpackers import packer
        data = packer.unpack(data).replace(r'\\/', '/')
        itemlist = servertools.find_video_items(data=data)

        for videoitem in itemlist:
            videoitem.title = "".join([item.title, videoitem.title])
            videoitem.fulltitle = item.fulltitle
            videoitem.thumbnail = item.thumbnail
            videoitem.channel = __channel__
    else:
        itemlist = servertools.find_video_items(item=item)

    return itemlist
	
def anti_cloudflare(url):
    # global headers

    try:
        resp_headers = scrapertools.get_headers_from_response(url, headers=headers)
        resp_headers = {v[0]: v[1] for v in resp_headers}
    except urllib2.HTTPError, e:
        resp_headers = e.headers

    if 'refresh' in resp_headers:
        time.sleep(int(resp_headers['refresh'][:1]))

        # dict_headers = {v[0]: v[1] for v in headers}
        # dict_headers['cookie'] = resp_headers['set-cookie'].split(';')[0]

        # resp_headers = scrapertools.get_headers_from_response(sito + resp_headers['refresh'][7:], headers=[[k, v] for k, v in dict_headers.iteritems()])
        scrapertools.get_headers_from_response(sito + resp_headers['refresh'][7:], headers=headers)
        # resp_headers = {v[0]: v[1] for v in resp_headers}

        # dict_headers['cookie'] = dict_headers['cookie'] + resp_headers['set-cookie'].split(';')[0]
        # headers = [[k, v] for k, v in dict_headers.iteritems()]

    return scrapertools.cache_page(url, headers=headers)
I'll check this as soon as I get to my pc and report back.

for itastreaming.co they might be updating the links (i hope) as other sites suddenly removed all the links. cineblog01.fm and hubberfilm if my mind doesn't trick me.

EDIT: @fenice82 I see you opened a thread for this, good job! Anyways, a cloudflare-protected website is the
hardest way to learn to edit channels for pelisalacarta :D I suggest to go on easier sites.

Regarding filmsubito.tv, I was able to page everything worth on the site, the problem now is extracting
the embed videos. can anybody help me here? viewtopic.php?f=23&t=6920
Thanks in advance

Re: Italian channels issues and development

Publicado: 27 Ago 2015, 17:40
por fenice82
zanzibar1982 escribió:
I'll check this as soon as I get to my pc and report back.

for itastreaming.co they might be updating the links (i hope) as other sites suddenly removed all the links. cineblog01.fm and hubberfilm if my mind doesn't trick me.

EDIT: @fenice82 I see you opened a thread for this, good job! Anyways, a cloudflare-protected website is the
hardest way to learn to edit channels for pelisalacarta :D I suggest to go on easier sites.

Regarding filmsubito.tv, I was able to page everything worth on the site, the problem now is extracting
the embed videos. can anybody help me here? viewtopic.php?f=23&t=6920
Thanks in advance
I think so... however, we can use robalo connector for Antadefinizione.click. Just consider that the move a lot of movie on ok.ru server, could someone fix it?

Re: Italian channels issues and development

Publicado: 27 Ago 2015, 21:25
por DrZ3r0
Hi,
I add altadefinizione.click on github.
I started from the robalo's file and I made some changes so that the videos work.

I also added the server ok.ru because all videos are hosted there.

The channel is located in the dev section because it lacks the menus to the video categories (there is only 'Al Cinema').

@fenice82 start from this file and add the missing menu: as first job is more than enough.

Bye.

Re: Italian channels issues and development

Publicado: 27 Ago 2015, 21:27
por fenice82
Thk DrZ3ro :)

Re: Italian channels issues and development

Publicado: 27 Ago 2015, 22:40
por robalo
DrZ3r0 very good job with the channel and thank you very much for the connector 'okru', a very clean and effective.

As information note on channel 'altadefinizioneclick' they have been placed for the film 'San Andreas' a different format url for 'okru' -> 'http://ok.ru/video/ <id>' which is also a url valid. I think they should adapt 'patronvideos' from 'find_videos' to prevent if both continue in this line 'altadefinizione.click' as other websites.

Thank you very much again

Re: Italian channels issues and development

Publicado: 28 Ago 2015, 00:04
por zanzibar1982
Great job DrZ3r0!

Yep, for San Andreas only Youtube server comes out.

@fenice82
I'd like to give my contribute passing you something you can work on for understanding.

You should create a new voice in main menù (def mainlist) like for genres:

Código: Seleccionar todo

itemlist.append( Item( channel=__channel__, title="Film per genere", action="genere", url=host ) )
then anywhere create a new defined command like:

Código: Seleccionar todo

def genere(item):
    logger.info("[altadefinizioneclick.py] genere")
    itemlist = []

    data = anti_cloudflare( item.url )

    ## ------------------------------------------------
    cookies = ""
    matches = re.compile( '(.altadefinizione.click.*?)\n', re.DOTALL ).findall( config.get_cookie_data() )
    for cookie in matches:
        name = cookie.split( '\t' )[5]
        value = cookie.split( '\t' )[6]
        cookies+= name + "=" + value + ";"
    headers.append( ['Cookie',cookies[:-1]] )
    import urllib
    _headers = urllib.urlencode( dict( headers ) )
    ## ------------------------------------------------

    data = scrapertools.find_single_match(data,'<option value="http://altadefinizione.click">Seleziona Categoria Film</option>(.*?)</form>')

    patron  = '<option value="(.*?)">(.*?)</option>'
    matches = re.compile(patron,re.DOTALL).findall(data)
    scrapertools.printMatches(matches)

    for scrapedurl,scrapedtitle in matches:
        itemlist.append( Item(channel=__channel__, action="fichas", title=scrapedtitle, url=scrapedurl, folder=True))

    return itemlist
where this defines the access to the site:

Código: Seleccionar todo

 data = anti_cloudflare( item.url )

    ## ------------------------------------------------
    cookies = ""
    matches = re.compile( '(.altadefinizione.click.*?)\n', re.DOTALL ).findall( config.get_cookie_data() )
    for cookie in matches:
        name = cookie.split( '\t' )[5]
        value = cookie.split( '\t' )[6]
        cookies+= name + "=" + value + ";"
    headers.append( ['Cookie',cookies[:-1]] )
    import urllib
    _headers = urllib.urlencode( dict( headers ) )
    ## ------------------------------------------------
this defines where in between you need to extract matches from:

Código: Seleccionar todo

    data = scrapertools.find_single_match(data,'<option value="http://altadefinizione.click">Seleziona Categoria Film</option>(.*?)</form>')
there you individuate the matches composing a single object you need, in this case it's a title you
want to display and the url to the page it will bring you to in case of selection:

Código: Seleccionar todo

    patron  = '<option value="(.*?)">(.*?)</option>'
    matches = re.compile(patron,re.DOTALL).findall(data)
    scrapertools.printMatches(matches)
then you define what is the operation to do with the extracted objects (in this case: action="fichas")

Código: Seleccionar todo

    for scrapedurl,scrapedtitle in matches:
        itemlist.append( Item(channel=__channel__, action="fichas", title=scrapedtitle, url=scrapedurl, folder=True))

    return itemlist
One thing that might be obvious but I recomend to pay attention to anyways, as a general rule,
is that when you define a "patron" as example:

Código: Seleccionar todo

patron  = '<option value="(.*?)">(.*?)</option>'
with (.*?) you define the entries (more properly "matches") you need to extract,
in this case respectively an url link and a title.
So when you edit:

Código: Seleccionar todo

    for scrapedurl,scrapedtitle in matches:
        itemlist.append( Item(channel=__channel__, action="fichas", title=scrapedtitle, url=scrapedurl, folder=True))

    return itemlist
you must put "scrapedurl" and "scrapedtitle" respectively too, to respect the syntax (sorry for being silly).

Re: Italian channels issues and development

Publicado: 28 Ago 2015, 02:38
por zanzibar1982
I am editing a channel for italian site seriehd.org, that really looks like

guardaserie.net so I am using this one's channel as template.

here is the work I've been able to do until now, my problem now

is extracting the videos... a server for hdpass.link might be required?

Código: Seleccionar todo

# -*- coding: utf-8 -*-
#------------------------------------------------------------
# pelisalacarta - XBMC Plugin
# Canal para seriehd - based on guardaserie channel
# http://blog.tvalacarta.info/plugin-xbmc/pelisalacarta/
#------------------------------------------------------------
import urlparse,urllib2,urllib,re
import os, sys

from core import logger
from core import config
from core import scrapertools
from core.item import Item
from servers import servertools

__channel__ = "seriehd"
__category__ = "S"
__type__ = "generic"
__title__ = "Serie HD"
__language__ = "IT"

headers = [
    ['Host','www.seriehd.org'],
    ['User-Agent','Mozilla/5.0 (Windows NT 6.1; WOW64; rv:39.0) Gecko/20100101 Firefox/39.0'],
    ['Accept-Encoding','gzip, deflate']
]

host = "http://www.seriehd.org"

def isGeneric():
    return True

def mainlist( item ):
    logger.info( "pelisalacarta.channels.seriehd mainlist" )

    itemlist = []

    itemlist.append( Item( channel=__channel__, action="fichas", title="Serie TV", url=host ) )
    itemlist.append( Item( channel=__channel__, action="search", title="Cerca..." ) )


    return itemlist

def search( item,texto ):
    logger.info("pelisalacarta.channels.seriehd search")

    item.url=host + "/?s=" + texto

    try:
        ## Se tiene que incluir aquí el nuevo scraper o crear una nueva función para ello
        return fichas( item )

    ## Se captura la excepción, para no interrumpir al buscador global si un canal falla.
    except:
        import sys
        for line in sys.exc_info():
            logger.error( "%s" % line )
        return []

def fichas( item ):
    logger.info( "pelisalacarta.channels.seriehd fichas" )
    itemlist = []

    if item.url == "":
        item.url = host

    data = scrapertools.cache_page( item.url )
    logger.info(data)

    patron  = '<h2>(.*?)</h2>\s*'
    patron += '<img src="(.*?)" alt=".*?"/>\s*'
    patron += '<A HREF="(.*?)"><span class="player"></span></A>'
    matches = re.compile( patron, re.DOTALL ).findall( data )

    for scrapedtitle, scrapedthumbnail, scrapedurl in matches:

        itemlist.append( Item( channel=__channel__, action="episodios", title="[COLOR azure]" + scrapedtitle + "[/COLOR]", fulltitle=scrapedtitle, url=scrapedurl, show=scrapedtitle, thumbnail=scrapedthumbnail ) )

    return itemlist

def cerca( item ):
    logger.info( "pelisalacarta.channels.seriehd fichas" )
    itemlist = []

    if item.url == "":
        item.url = host

    data = scrapertools.cache_page( item.url )
    logger.info(data)

    patron  = '<h2>(.*?)</h2>\s*'
    patron += '<img src="(.*?)" alt=".*?" pagespeed_url_hash=".*?"/>\s*'
    patron += '<A HREF="(.*?)"><span class="player"><span class="cp-title">.*?</span></span></A>'
    matches = re.compile( patron, re.DOTALL ).findall( data )

    for scrapedtitle, scrapedthumbnail, scrapedurl in matches:

        itemlist.append( Item( channel=__channel__, action="episodios", title="[COLOR azure]" + scrapedtitle + "[/COLOR]", fulltitle=scrapedtitle, url=scrapedurl, show=scrapedtitle, thumbnail=scrapedthumbnail ) )

    return itemlist

def episodios(item):
    logger.info("pelisalacarta.channels.seriehd episodios")

    itemlist = []

    data = scrapertools.cache_page( item.url )

    serie_id = scrapertools.get_match( data, '?idFilm=(\d+)" allowfullscreen>' ) 

    data = scrapertools.get_match( data, '<select name="puntata" class="selEp">(.*?)</select>' )

    seasons_episodes = re.compile( '<option data-id="(\d+)" value=".*?">(.*?)</option>', re.DOTALL ).findall( data )

    for scrapedseason, scrapedepisodes in seasons_episodes:

        episodes = re.compile( 'data-id="(\d+)"', re.DOTALL ).findall( scrapedepisodes )
        for scrapedepisode in episodes:

            season = str ( int( scrapedseason ) + 1 )
            episode = str ( int( scrapedepisode ) + 1 )
            if len( episode ) == 1: episode = "0" + episode

            title = season + "x" + episode + " - " + item.title

            ## Le pasamos a 'findvideos' la url con tres partes divididas por el caracter "?"
            ## [host+path]?[argumentos]?[Referer]
            url = host + "/wp-admin/admin-ajax.php?action=get_episode&id=" + serie_id + "&season=" + scrapedseason + "&episode=" + scrapedepisode + "?" + item.url 

            itemlist.append( Item( channel=__channel__, action="findvideos", title=title, url=url, fulltitle=item.title, show=item.title ) )

    return itemlist

def findvideos( item ):
    logger.info("pelisalacarta.channels.seriehd findvideos")

    itemlist = []

    url = item.url.split( '?' )[0]
    post = item.url.split( '?' )[1]
    referer = item.url.split( '?' )[2]

    headers.append( [ 'Referer', referer ] )

    data = scrapertools.cache_page( url, post=post, headers=headers )

    url = scrapertools.get_match( data.lower(), 'src="([^"]+)"' )
    url = re.sub( r'embed\-|\-607x360\.html', '', url)

    server = url.split( '/' )[2].split( '.' )
    server = server[1] if len( server ) == 3 else server[0]

    title = "[" + server + "] " + item.title

    itemlist.append( Item( channel=__channel__, action="play",title=title, url=url, server=server , fulltitle=item.fulltitle, show=item.show, folder=False ) )

    return itemlist
I opened a thread viewtopic.php?f=23&t=6934