ok holy crap im finally getting a grasp
# PMS plugin framework<br />
from PMS import *<br />
from PMS.Objects import *<br />
from PMS.Shortcuts import *<br />
<br />
####################################################################################################<br />
<br />
VBS_PREFIX = "/video/vbs2"<br />
<br />
VBS_URL = "http://www.vbs.tv/"<br />
VBS_FULL_EPISODES_SHOW_LIST = "http://www.vbs.tv/shows/label/All/"<br />
VBS_IMAGE_THUMB_URL = "http://assets.vbs.tv/%s_small.jpg"<br />
CACHE_INTERVAL = 3600<br />
DEBUG = True<br />
ART = 'art-default.png'<br />
ICON = 'icon-default.png'<br />
<br />
####################################################################################################<br />
<br />
def Start():<br />
Plugin.AddPrefixHandler(VBS_PREFIX, MainMenu, L("VBS"), VBS_IMAGE_THUMB_URL)<br />
Plugin.AddViewGroup("InfoList", viewMode="InfoList", mediaType="items")<br />
<br />
####################################################################################################<br />
def MainMenu():<br />
dir = MediaContainer(mediaType='video')<br />
dir.Append(<br />
Function(<br />
DirectoryItem(<br />
all_shows, "Shows",<br />
"",<br />
pageUrl = VBS_FULL_EPISODES_SHOW_LIST,<br />
summary="Browse Show List"<br />
)<br />
)<br />
)<br />
return dir<br />
<br />
####################################################################################################<br />
def all_shows(sender, url=None):<br />
dir = MediaContainer(title2=sender.itemTitle)<br />
content = XML.ElementFromURL(pageUrl, True)<br />
for item in content.xpath('//ul[@class="covers covers-wide"]//ul/h4'):<br />
titleUrl = item.xpath("a")[0].get('href')<br />
image = item.xpath("a/img")[0].get('src')<br />
title = item.xpath("a")[0].get('title')<br />
Log(titleUrl)<br />
dir.Append(Function(DirectoryItem(VideoPage, title), pageUrl = titleUrl))<br />
return dir <br />
<br />
<br />
####################################################################################################<br />
def VideoPage(sender, titleUrl):<br />
dir = MediaContainer(title2=sender.itemTitle)<br />
content = XML.ElementFromURL(pageUrl, True)<br />
for item2 in content.xpath('//div[@class="group-list"]//ul/li'):<br />
vidUrl = item2.xpath("a")[0].get('href')<br />
if vidUrl.count("http://") == 0:<br />
vidUrl=VBS_URL+vidUrl <br />
Log(vidUrl)<br />
thumb2 = item2.xpath("a/img")[0].get('src')<br />
title2 = item2.xpath("a")[0].get('title')<br />
Log(title2)<br />
dir.Append(WebVideoItem(vidUrl, title=title2, thumb=thumb2))<br />
return dir
so let me explain what im seeing here, and let me know if im right.
Def "all shows" ( still working on this part of the tag, as i get this error "TypeError: all_shows() takes exactly 2 non-keyword arguments (1 given)" )
but so the content.xpath and everything under that im finally getting.
this is what i was looking for clarification on, and when checking back and forth between 3 websites and 3 plugins. i think i figured it out.
so in the content.xpath for all shows, its saying
def all_shows(sender, url=None):still unsure of this tag
dir = MediaContainer(title2=sender.itemTitle) - still unsure of this tag "title2=sender.itemTitle"
content = XML.ElementFromURL(pageUrl, True) - still unsure of this tag "pageUrl, True" and what should be there. but i understand that pageUrl needs to be called. but its just calling the base URL for the show list
for item in content.xpath('//ul[@class="covers covers-wide"]//ul/h4'): - ok this is where i started to go "YEAH... thats IT!" so here the xpath is saying watch for a html class callout for "ul" with the name "cover cover-wide" which is the start of the show list. then it says once you found "
the place for it to start looking for data. then look for "ul" then "h4" which has the title name and link ( but im not sure if it knows its a link at that point, but i think that doesnt matter as it will populate the link on its own )its telling the "python script to read and find those tags. then grab the info after it. not sure how to stop it though
titleUrl = item.xpath("a")[0].get('href') - this is where it became more clear to me. this is stating the "titleUrl" will = the information that item.xpath grabbed starting at ("a")[0]not sure what that means .get means grab this part starting with ('href') of the code. or the Url for the video.... ok makes sense
image = item.xpath("a/img")[0].get('src') - Then its saying, also grab the image, look for the code that starts with "a/img" meaning the line starts with a, but dont gran anything till you see img. then .get the image url..... makes sense
title = item.xpath("a")[0].get('title') - then we see this one, might be a bit out of order i think. but you the get the title name, when xpath searches in that string again, for "a" the start of the line of code, then look threw the code till youy see "title" and then .get the title name.....makes sense
Log(titleUrl) - still unsure of this tag, i know its logging the url, but not sure why, or if its necessary
dir.Append(Function(DirectoryItem(VideoPage, title), pageUrl = titleUrl)) - still unsure of these tags, i know they are calling out and back to the other functions, but not sure why
return dir
just to explain I am still in the middle of coding, so some stuff is still like the NBC pluging/ Daily show plugin/ Justin.tv plugin. I am tayloring it to the VBS site now.
but if im getting this right, the order that you tell xpath to search and grab the data is dependent on the structure of the page you are grabbing from.
like below, its different that the NBC code.
<div class="item-list group-full-eps"> <br />
<div class="group-list" id="full_episodes"><br />
<ul> <br />
<br />
<li><br />
<a href="/friday-night-lights/video/the-lights-of-carroll-park/1237173/" title="The Lights of Carroll Park" class="img-wrap"><img src="http://video.nbc.com/nbcrewind2/thumb/946ac07a039c04f40089cc5e9defe741_large.jpg" alt="The Lights of Carroll Park" width="80" height="45" /></a><br />
<p><strong><em>Friday Night Lights</em><br />The Lights of Carroll Park</strong></p><br />
<br />
</li><br />
so you can see, the xpath saying, find "div class "item-list group-full-eps" which would be "
" then its saying, right after skip the other div tag. then you will see a ul tag, skip that, then you will see another ul tag ( which truthfully looks like a typo since there is NOT another ul tag in the html source ) and then start when you get to il. the end of the xpath statement start.
<ul class="covers covers-wide"><br />
<br />
<li id="show_poster_94"><br />
<h4><a href="/watch/far-out--2">Far Out</a></h4><br />
<br />
<h5><a href="/watch/far-out--2">Series</a></h5><br />
for reference from the VBS site html source
this is only for the First menu. the second show menu for episodes is similar ( as the posted one above ) but is different as the structure is slightly different on that page source
but I think im getting an idea of what this all means