Tvolucion - Xpath Problem

Hi my name is Juan Carlos is my first post but in this moment I develop a plugin for Plex!!! :slight_smile:

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:







  • Teresa



    Listos para la boda



    Duración: 00:43:53



    Capítulo: 90







  • 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.esmas.com/telenovelas/drama/teresa/091281/teresa-capitulo-90/ipad



    How i get with xpath.



    Thanks so much

    JC

    try:


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


    Jonny

    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, <br />
    1 = http://tvolucion.esmas.com/telenovelas/drama/teresa/091281/teresa-capitulo-90/ipad<br />
    2 = );
    
    

    So use this:

    
    urlCapitulo = forElementos.xpath('./img').get('onClick')<br />
    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

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

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


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

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


    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
    
    <br />
    vidUrl = vidUrl.split(",")[1]<br />
    
    
    

    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.com/player/player.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 + "
    
    " + duracionCapitulo, thumb=imagenCapitulo, title=numeroCapitulo + ". " + tituloCapitulo))
    
    

    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.




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





    Thanks

    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

    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 :)!

    Sorry I forgot upload the file.

    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

    no funciona el plug in o es que lo instalo mal???

    This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.