Plex Forums: Tvolucion - Xpath Problem - Plex Forums

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Tvolucion - Xpath Problem

#1 User is offline   JC-Avila 

  • Newbie
  • Pip
  • Group: Members
  • Posts: 9
  • Joined: 07-December 10

Posted 07 December 2010 - 04:32 AM

Hi my name is Juan Carlos is my first post but in this moment I develop a plugin for Plex!!! :)
All plugin is finished but I have problem with a xpath, look is this the code...

urlCapitulo = forElementos.xpath('./img[@onClick]').text

I want parse from this line:

<li>
<img src="http://flash.tvolucion.com/img/tln/t1-c090-teres.jpg" onClick="GoLink(this, 'http://tvolucion.esmas.com/telenovelas/drama/teresa/091281/teresa-capitulo-90/ipad');">
<h2>Teresa</h2>
<h3>Listos para la boda</h3>
<h3>Duración: 00:43:53</h3>
<h3>Capítulo: 90</h3>
</li>

I need get the content from onClick
onClick="GoLink(this, 'http://tvolucion.esmas.com/telenovelas/drama/teresa/091281/teresa-capitulo-90/ipad');"
the link: http://tvolucion.esm...apitulo-90/ipad

How i get with xpath.

Thanks so much
JC
0

#2 User is offline   Jonny Wray 

  • Dedicated Member
  • PipPipPip
  • Group: Castle Keeper
  • Posts: 1,322
  • Joined: 27-February 09
  • Gender:Male
  • Location:Oxford

Posted 07 December 2010 - 05:12 AM

try:

urlCapitulo = forElementos.xpath('./img').get('onClick')


Jonny
1

#3 User is offline   sander1 

  • Plugin Developer/Admin
  • PipPipPip
  • Group: Castle Keeper
  • Posts: 1,246
  • Joined: 02-February 09
  • Gender:Male
  • Location:The Netherlands

Posted 07 December 2010 - 05:41 PM

And after the xpath you'd need to extract the url from the returned string. You can of course use a regular expression for this, but in this case you can also use a simple split and split the string on the single quote. This will return a list with 3 elements:

0 = GoLink(this, 
1 = http://tvolucion.esmas.com/telenovelas/drama/teresa/091281/teresa-capitulo-90/ipad
2 = );

So use this:

urlCapitulo = forElementos.xpath('./img').get('onClick')
urlCapitulo = urlCapitulo.split("'")[1]

0

#4 User is offline   JC-Avila 

  • Newbie
  • Pip
  • Group: Members
  • Posts: 9
  • Joined: 07-December 10

Posted 12 December 2010 - 10:22 AM

View Postsander1, on 07 December 2010 - 05:41 PM, said:

And after the xpath you'd need to extract the url from the returned string. You can of course use a regular expression for this, but in this case you can also use a simple split and split the string on the single quote. This will return a list with 3 elements:

0 = GoLink(this, 
1 = http://tvolucion.esmas.com/telenovelas/drama/teresa/091281/teresa-capitulo-90/ipad
2 = );

So use this:

urlCapitulo = forElementos.xpath('./img').get('onClick')
urlCapitulo = urlCapitulo.split("'")[1]



Thanks for the answers, look I have another trouble, that is my last line to get finish the plugin!!!
urlCapitulo = forElementos.xpath('//img')[0].get('onClick')
urlCapitulo = urlCapitulo[0]

If don't use the [0] in forElementos.xpath('//img')[0].get('onClick') don't run, but if use this code, the second line urlCapitulo = urlCapitulo.split("'")[1] doesn't works

Please help me, thank you

The error code is:
12/12/10 04:21:44 [0x0-0x783783].com.plexapp.plexmediaserver[12929] File "/Users/JC/Library/Application Support/Plex Media Server/Plug-ins/Tvolucion.bundle/Contents/Code/__init__.py", line 121, in videoIpad
0

#5 User is offline   Jonny Wray 

  • Dedicated Member
  • PipPipPip
  • Group: Castle Keeper
  • Posts: 1,322
  • Joined: 27-February 09
  • Gender:Male
  • Location:Oxford

Posted 12 December 2010 - 05:52 PM

It looks like the xpath isn't returning a string that can be split into three pieces. Couple of things; first, the xpath predicate in your last message
//img
is different from that suggested
 ./img
. The one you posted will get all img tags in the whole document.The other will get children of forElementos.

Second, try using Log to print out the string returned from get to see if it can be split.

Jonny
0

#6 User is offline   JC-Avila 

  • Newbie
  • Pip
  • Group: Members
  • Posts: 9
  • Joined: 07-December 10

Posted 13 December 2010 - 12:08 AM

View PostJonny Wray, on 12 December 2010 - 05:52 PM, said:

It looks like the xpath isn't returning a string that can be split into three pieces. Couple of things; first, the xpath predicate in your last message
//img
is different from that suggested
 ./img
. The one you posted will get all img tags in the whole document.The other will get children of forElementos.

Second, try using Log to print out the string returned from get to see if it can be split.

Jonny


Hi I try with the ./img but is the same problem, because when I put the log the fetch is none. Any suggest?

    MediaContainer.art = (arte)
    dir = MediaContainer(programa=sender.itemTitle)
    dir.viewGroup = 'InfoList'
    contenidos = XML.ElementFromURL(urlCapitulo, True)
    for forElementos in contenidos.xpath('//div[@id="grid_cont"]/ul/li'):
      vidUrl = contenidos.xpath('./img').get('onClick')
      Log(tituloCapitulo)
      vidUrl = tituloCapitulo.split("'")[1]
      Log(tituloCapitulo)
      imagenCapitulo = forElementos.xpath('./img')[0].get('src')
      numeroCapitulo = forElementos.xpath('./h3')[2].text[10:]
      tituloCapitulo = forElementos.xpath('./h3')[0].text
      sumarioCapitulo = forElementos.xpath('//h3')[0].text
      duracionCapitulo = forElementos.xpath('./h3')[1].text
      dir.Append(WebVideoItem(PREFIJO_FLASH, summary=vidUrl + sumarioCapitulo + "\n\n" + duracionCapitulo, thumb=imagenCapitulo, title=numeroCapitulo + ". " + tituloCapitulo))
    return dir

0

#7 User is offline   Jonny Wray 

  • Dedicated Member
  • PipPipPip
  • Group: Castle Keeper
  • Posts: 1,322
  • Joined: 27-February 09
  • Gender:Male
  • Location:Oxford

Posted 13 December 2010 - 01:36 AM

There's a number of things in that code that look a little odd.

vidUrl = contenidos.xpath('./img').get('onClick')

should be operating on the current iterator element, no? i.e.
vidUrl = forElementos.xpath('./img').get('onClick')


Then, both your Log statements are working on a variable that hasn't been initialized - it happens later in the loop - so will be None

And the split is also operating on the same non-initialized variable, and you should be splitting the string with a comma not an apostrophe
vidUrl = vidUrl.split(",")[1]

and then your WebVideoItem is using the same video URL for every entry, PREFIJO_FLASH. Don't you want vidUrl there?



Jonny
0

#8 User is offline   JC-Avila 

  • Newbie
  • Pip
  • Group: Members
  • Posts: 9
  • Joined: 07-December 10

Posted 13 December 2010 - 01:45 AM

View PostJonny Wray, on 13 December 2010 - 01:36 AM, said:

There's a number of things in that code that look a little odd.

vidUrl = contenidos.xpath('./img').get('onClick')

should be operating on the current iterator element, no? i.e.
vidUrl = forElementos.xpath('./img').get('onClick')


Then, both your Log statements are working on a variable that hasn't been initialized - it happens later in the loop - so will be None

And the split is also operating on the same non-initialized variable, and you should be splitting the string with a comma not an apostrophe
vidUrl = vidUrl.split(",")[1]

and then your WebVideoItem is using the same video URL for every entry, PREFIJO_FLASH. Don't you want vidUrl there?



Jonny


Hey Jonny I fixed the error this is the most stupid error
urlVideo = forElementos.xpath("./img")[0].get('onclick')
urlVideo = urlVideo.split("'")[1]

I write onClick and the correct is onclick

well I finished :) in some hours I will upload the plugin, but I have a question, how I insert the video when the format is mp4, you need the: http://www.plexapp.c...layer.php?clip=
?

Thanks!
0

#9 User is offline   Dbl_A 

  • Dedicated Member
  • PipPipPip
  • Group: Members
  • Posts: 288
  • Joined: 26-January 10
  • Gender:Male
  • Location:College Station, TX

Posted 13 December 2010 - 03:36 AM

View PostJC-Avila, on 13 December 2010 - 01:45 AM, said:

Hey Jonny I fixed the error this is the most stupid error
urlVideo = forElementos.xpath("./img")[0].get('onclick')
urlVideo = urlVideo.split("'")[1]

I write onClick and the correct is onclick

well I finished :) in some hours I will upload the plugin, but I have a question, how I insert the video when the format is mp4, you need the: http://www.plexapp.c...layer.php?clip=
?

Thanks!


If it's an .mp4 video file, you don't need to use WebVideoItem or www.plexapp.com/player.php... (those are used for Flash/Silverlight content)

try this:
dir.Append(VideoItem(PREFIJO_FLASH, summary=vidUrl + sumarioCapitulo + "\n\n" + duracionCapitulo, thumb=imagenCapitulo, title=numeroCapitulo + ". " + tituloCapitulo))

Developed Plug-ins:
CBS / ESPN 3 / Nick Jr. / PBS Kids / MTV Shows / MTVMusic.com / Nickelodeon / Crackle
Helped with:
ABC / TNT / GreatTV.ca
Donate
0

#10 User is offline   Jonny Wray 

  • Dedicated Member
  • PipPipPip
  • Group: Castle Keeper
  • Posts: 1,322
  • Joined: 27-February 09
  • Gender:Male
  • Location:Oxford

Posted 13 December 2010 - 03:38 AM

Glad you got it.

Is the video URL you have directly to an mp4 file? If so, they are the easiest to deal with. Just use VideoItem instead of WebVideoItem with the mp4 URL as the target.


View PostJC-Avila, on 13 December 2010 - 01:45 AM, said:

Hey Jonny I fixed the error this is the most stupid error
urlVideo = forElementos.xpath("./img")[0].get('onclick')
urlVideo = urlVideo.split("'")[1]

I write onClick and the correct is onclick

well I finished :) in some hours I will upload the plugin, but I have a question, how I insert the video when the format is mp4, you need the: http://www.plexapp.c...layer.php?clip=
?

Thanks!

0

#11 User is offline   davoram 

  • Newbie
  • Pip
  • Group: Members
  • Posts: 2
  • Joined: 29-December 10

Posted 29 December 2010 - 08:01 PM

Is this plugin ready ? Did you get to finish it ?


Thanks
0

#12 User is offline   JC-Avila 

  • Newbie
  • Pip
  • Group: Members
  • Posts: 9
  • Joined: 07-December 10

Posted 01 January 2011 - 09:43 AM

Sorry for the time, just only I have some issues because Tvolucion, change some lines of code and this plugin is parsing html.

Please give me some days I recode the plugin.

Only some issues from this plugin:
- Some section (or maybe all) have a problem with the "In your country you don't play this video". Is possible just USA, because have an agreement with Telemundo.
- Only works 4 of 15:
The most recent
iPad Version (HD)
Foro TV (Discussion Threads)
News
Talk Soups


If I upload the plugin could get feedback, ideas, bug fixes, and for the Plex Online
0

#13 User is offline   JC-Avila 

  • Newbie
  • Pip
  • Group: Members
  • Posts: 9
  • Joined: 07-December 10

Posted 01 January 2011 - 11:29 AM

Ok it's the first version of TVolucion's Plugin, some sections don't have data because some videos was coded with a propietary format and any type of app wasn't played, the format is QVT.

Well plz take ma back a feedback is my first app, not only on Plex, is on Phyton :)!
0

#14 User is offline   JC-Avila 

  • Newbie
  • Pip
  • Group: Members
  • Posts: 9
  • Joined: 07-December 10

Posted 01 January 2011 - 11:33 AM

Sorry I forgot upload the file.

Attached File(s)


0

#15 User is offline   briankno 

  • Newbie
  • Pip
  • Group: Members
  • Posts: 1
  • Joined: 13-March 12

Posted 13 March 2012 - 03:45 AM

disculpa juan carlos soy nuevo en plex mac, como le puedo hacer para ver netflix en plex no encuentro algun tutorial o manera de instalar los plugins crees que sea molestia me expliques que hacer?
gracias :brian cano
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users