New Plugin for TV Land

Beginner Questions Regarding xpath
I am currently attempting to develop a plugin for the TV Land site and am having some problems with xpath. I have developed a rough site config file which will play the videos from TV Land and have also written the code for the first menu of the plugin (I have been able to get the information from the www.tvland.com/fullepisodes page using xpath). However the issue I am running in to is that when I try to get the path for the individual episodes, thumbs and info the python script doesn't seem to be able to find it. The following is an example of a generic issue that I am running into. When on the episodes page for Everybody Loves Raymond using xpath checker I try an generic xpath of //img which should return all of the images on the url (see screenshot) which it does. However when using the same line in the python script:

for indshows in XML.ElementFromURL(EPISODE_PREFIX + showpath, isHTML=True, headers=HEADERS).xpath('//img'):
Log(indshows.get('src'))

all of the thumbnails except for 4-8 are returned in the log file. 4-8 being the thumbnails for each episode. This is the same issue I have when attempting to access the video path (href). Being very new to python and plugins I am struggling with why xpath cannot extract the information for the video files, obviously I am missing something here. I would greatly appreciate any input or tips to try and overcome this issue. The plugin works great when manually entering the paths just can't access them from the webpage. Please let me know if there is any other information which I could provide to help. Thanks.

ok, you’re looking at the episode buttons right under the player on http://www.tvland.com/prime/fullepisodes/everybody_loves_raymond/ right?



the xpath for the thumbnail images is “//div[@class=‘carousel’]//img/@src

the xpath for the individual episode page urls is “//div[@class=‘carousel’]//a/@href

and the xpath for the episode titles is “//div[@class=‘title_small’]//text()”



note that here as in most cases the links returned are relative, you’ll have to add the prefix before plex can use them for anything.



This is probably the best xpath intro/guide i’ve found: http://www.zvon.org/xxl/XPathTutorial/General/examples.html

ok, so it seems its more complicated than that… i just grabbed that from what i could see in firebug/xpather, but… it seems that bit of the DOM is all generated client side by a nasty little bit of javascript, and as the plugin framework is just dumping the raw http response and not running the scripts on the page, that bit of html doesnt exist when your plugin sees it. that section instead looks like:


<script type="text/javascript"><br />
<br />
var hsrcarousel_itemList = [<br />
<br />
{url: "index.jhtml?episodeId=25278", title: "Debra's Sick", <br />
<br />
thumbNail: "/video/thumbnails/everybody_loves_raymond/full_episodes_everybody_loves_raymond_013.jpg", caption: ""<br />
<br />
},<br />
<br />
{url: "index.jhtml?episodeId=25276", title: "Turkey or Fish", <br />
<br />
thumbNail: "/video/thumbnails/everybody_loves_raymond/full_episodes_everybody_loves_raymond_010.jpg", caption: ""<br />
<br />
},<br />
<br />
{url: "index.jhtml?episodeId=25277", title: "Captain Nemo", <br />
<br />
thumbNail: "/video/thumbnails/everybody_loves_raymond/full_episodes_everybody_loves_raymond_011.jpg", caption: ""<br />
<br />
},<br />
<br />
{url: "index.jhtml?episodeId=25275", title: "Win, Lose or Draw", <br />
<br />
thumbNail: "/video/thumbnails/everybody_loves_raymond/full_episodes_everybody_loves_raymond_009.jpg", caption: ""<br />
<br />
},<br />
<br />
{url: "index.jhtml?episodeId=25269", title: "Pilot", <br />
<br />
thumbNail: "/video/thumbnails/everybody_loves_raymond/full_episodes_everybody_loves_raymond_001.jpg", caption: ""<br />
<br />
}<br />
<br />
];<br />



which means easily grabbing it with xpath is out, the data you want IS still there (lucky you, that's not often the case), but you'll need to resort to regex or some other messier method to grab it.

Thanks for the help (i was really struggling with this), regex worked perfectly. Now with a little TLC the plugin should be ready for some initial testing

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