Página 1 de 2

Help needed to add new channels to pelisalacarta

Publicado: 16 Jul 2009, 06:18
por jesus
please help how to add new website for your plugin:(

Re: Help needed to add new channels to pelisalacarta

Publicado: 16 Jul 2009, 06:19
por jesus
I soon will publish some documentation. What site are you thinking about? Maybe i can help…

Re: Help needed to add new channels to pelisalacarta

Publicado: 16 Jul 2009, 06:19
por jesus

Re: Help needed to add new channels to pelisalacarta

Publicado: 16 Jul 2009, 06:20
por jesus
my mail piogrys@hotmail.com maybe you can send for mi something help how modified your code .and with one script must be modified

Re: Help needed to add new channels to pelisalacarta

Publicado: 16 Jul 2009, 06:40
por jesus
I promise to write a tutorial for adding new channels to tvalacarta and pelisalacarta. Soon you will see why i delayed this so much, but meanwhile these are the steps for pelisalacarta and the channels you need.

1) Add the new channel in channelselector.py. This script shows the channel list, and you will see the actual channels this way:

Código: Seleccionar todo

addfolder("Pintadibujos","pintadibujos","mainlist")
addfolder("DeLaTV","delatv","mainlist")
addfolder("Yotix.tv","yotix","mainlist")
Note that the first parameter is the "visual" name, and the second parameter is the internal name. This internal name is very important. The third parameter is the function in each channel who starts the proccess (see above)

In your case this will be:

Código: Seleccionar todo

addfolder("tvfilmy.pl","tvfilmy","mainlist")
2) Create and put a logo for the new channel in the "resources/images" directory, with the internal name as file name and PNG extension.

Código: Seleccionar todo

tvfilmy.png
3) Create a new file for your channel in the channels directory, with the internal name as file name. It's better to use an existing channel as reference. Copy and paste pintadibujos.py, for example, one of the newest and easiest channels.

Código: Seleccionar todo

tvfilmy.py
4) In the begining of the file, change the startup variable CHANNELNAME with the name of your channel

Código: Seleccionar todo

CHANNELNAME = "tvfilmy"
5) And now the hardest part. The first function "mainlist" gets the first page to show when you enter the channel. It's called from channelselector, so you have to start the process here. Change the starting URL.

Código: Seleccionar todo

url = "http://www.tvfilmy.pl/"
Change the regular expression, in order to extract the video list.

Código: Seleccionar todo

patron  = '<div class="item">[^<]+'
matches = re.compile(patron,re.DOTALL).findall(data)

Re: Help needed to add new channels to pelisalacarta

Publicado: 16 Jul 2009, 06:55
por jesus
In the first site, you can see from the page that each movie present this HTML block:

Código: Seleccionar todo

<div class="middle"><div class="text">
    <p><a href="index.php?p=ogladaj&id=1551"  title="Tsotsi / Thug [2005] Lektor" ><img src="images/1240658045_Tsotsi (2005) lektor.jpg" 
Here you have all you need. Link to movie page ("index.php?p=ogladaj&id=1551"), title ("Tsotsi / Thug [2005] Lektor") and thumbnail ("images/1240658045_Tsotsi (2005) lektor.jpg").

Your regular expression should be something like this

Código: Seleccionar todo

patron='<div class="middle"><div class="text">[^<]+<p><a href="([^"]+)"  title="([^"]+)" ><img src="([^"]+)" 
I can't make this a regular expression tutorial, but here is a few tricks:
  • The fragment [^<]+ means continue until you find the character <
    The fragment [^"]+ means continue until you find the character "
    When you put somethig between "(" and ")", you mark it as something you need to extract later
6) Now the extraction part: There are 4 variables you need to fill, using the results from the above expression. All the results for each movie are stored in an array named match, so you only need to give each one the correct value. match[0] is the first value between parenthesis, match[1] the second, etc. In the case of tvfilmy:

Código: Seleccionar todo

# Title of the movie in the list
scrapedtitle = match[1]

# URL for the detail page of the movie (in the example is relative to the actual URL)
scrapedurl = urlparse.urljoin(url,match[0])

# Thumbnail for the movie (in the example is relative to the actual URL)
scrapedthumbnail = urlparse.urljoin(url,match[2])

# Plot for the movie
scrapedplot = ""
7) Adding to the list. If you have find a movie, the last point is adding it to the list. Use the function "xbmctools.addnewfolder" and specify where to go if the user selects this movie. In this case you can have a second function "detail" as in the case of the pintadibujos channel.

Código: Seleccionar todo

xbmctools.addthumbnailfolder( CHANNELNAME , scrapedtitle , scrapedurl , scrapedthumbnail, "detail" )

Re: Help needed to add new channels to pelisalacarta

Publicado: 16 Jul 2009, 07:08
por jesus
8) The rest of the process for tvfilmy is easy. The same detail function used by pintadibujos should make the work for tvfilmy, because it uses the video connectors of pelisalacarta. They sould locate all the videos in the page:

Código: Seleccionar todo

listavideos = servertools.findvideos(data)
9) All the vídeos it can find are added to the list, with the function "play" as the next step when a user selects one.

Código: Seleccionar todo

xbmctools.addvideo( CHANNELNAME , "Megavideo - "+video[0] , video[1] , category , video[2] )
10) The play function launches the player:

Código: Seleccionar todo

xbmctools.playvideo(CHANNELNAME,server,url,category,title,thumbnail,plot)

Re: Help needed to add new channels to pelisalacarta

Publicado: 16 Jul 2009, 07:11
por jesus
From this point, you only need to do a lot of tests :)

When i develop my plugins, i change the resolution of xbmc to 640x480 in Windowed mode. This way i can navigate in the plugin while i watch the log seeing what is happening.

Good luck, and return here with any question.

Re: Help needed to add new channels to pelisalacarta

Publicado: 16 Jul 2009, 21:57
por piogrys
jesus please .. can you write for my file for this schannel tvfilmy.pl ?i can see evryfing diferent.sorry for my english

Re: Help needed to add new channels to pelisalacarta

Publicado: 17 Jul 2009, 01:19
por piogrys
# -*- coding: iso-8859-1 -*-
#------------------------------------------------------------
# pelisalacarta - XBMC Plugin
# Canal para pintadibujos
# http://blog.tvalacarta.info/plugin-xbmc/pelisalacarta/
#------------------------------------------------------------
import urlparse,urllib2,urllib,re
import os
import sys
import xbmc
import xbmcgui
import xbmcplugin
import scrapertools
import megavideo
import servertools
import binascii
import xbmctools

CHANNELNAME = "tvfilmy"

# Esto permite su ejecución en modo emulado
try:
pluginhandle = int( sys.argv[ 1 ] )
except:
pluginhandle = ""

# Traza el inicio del canal
xbmc.output("[tvfilmy.py] init")

DEBUG = True

def mainlist(params,url,category):
xbmc.output("[tvfilmy.py.] mainlist")

url = "http://www.tvfilmy.pl/"

# Descarga la página
data = scrapertools.cachePage(url)
#xbmc.output(data)

# Extrae las entradas (carpetas)
patronvideos = '<div class="item">[^<]+'
patronvideos ='<div class="middle"><div class="text">[^<]+<p><a href="([^"]+)" title="([^"]+)" ><img src="([^"]+)"'
matches = re.compile(patronvideos,re.DOTALL).findall(data)
scrapertools.printMatches(matches)


for match in matches:
# Titulo
scrapedtitle = match[1]

# URL
scrapedurl = urlparse.urljoin(url,match[0])

# Thumbnail
scrapedthumbnail = urlparse.urljoin(url,match[2])

# procesa el resto
scrapedplot = ""

# Depuracion
if (DEBUG):
xbmc.output("scrapedtitle="+scrapedtitle)
xbmc.output("scrapedurl="+scrapedurl)
xbmc.output("scrapedthumbnail="+scrapedthumbnail)
xbmc.output("scrapedplot="+scrapedplot)

# Añade al listado de XBMC
xbmctools.addthumbnailfolder( CHANNELNAME , scrapedtitle , scrapedurl , scrapedthumbnail, "detail" )

# Label (top-right)...
xbmcplugin.setPluginCategory( handle=pluginhandle, category=category )

# Disable sorting...
xbmcplugin.addSortMethod( handle=pluginhandle, sortMethod=xbmcplugin.SORT_METHOD_NONE )

# End of directory...
xbmcplugin.endOfDirectory( handle=pluginhandle, succeeded=True )

def detail(params,url,category):
xbmc.output("[tvfilmy.py] detail")

title = params.get("title")
thumbnail = params.get("thumbnail")
xbmc.output("[tvfilmy.py] title="+title)
xbmc.output("[tvfilmy.py] thumbnail="+thumbnail)

# Descarga la página
data = scrapertools.cachePage(url)
#xbmc.output(data)

# ------------------------------------------------------------------------------------
# Busca los enlaces a los videos
# ------------------------------------------------------------------------------------
listavideos = servertools.findvideos(data)

for video in listavideos:
xbmctools.addvideo( CHANNELNAME , "Megavideo - "+video[0] , video[1] , category , video[2] )
# ------------------------------------------------------------------------------------

# Label (top-right)...
xbmcplugin.setPluginCategory( handle=pluginhandle, category=category )

# Disable sorting...
xbmcplugin.addSortMethod( handle=pluginhandle, sortMethod=xbmcplugin.SORT_METHOD_NONE )

# End of directory...
xbmcplugin.endOfDirectory( handle=pluginhandle, succeeded=True )

def play(params,url,category):
xbmc.output("[tvfilmy.py] play")

title = unicode( xbmc.getInfoLabel( "ListItem.Title" ), "utf-8" )
thumbnail = xbmc.getInfoImage( "ListItem.Thumb" )
plot = unicode( xbmc.getInfoLabel( "ListItem.Plot" ), "utf-8" )
server = params["server"]
xbmc.output("[tvfilmy.py] thumbnail="+thumbnail)
xbmc.output("[tvfilmy.py] server="+server)

xbmctools.playvideo(CHANNELNAME,server,url,category,title,thumbnail,plot)

#mainlist(None,"","mainlist")
#detail(None,"http://impresionante.tv/ponyo.html","play")