I’m trying to create a plugin for the Notre Dame All Access website (http://www.und.com/allaccess), which shows various sports highlights, interviews, and some games. It is part of the CBS Sports College Network, so I think a plugin could easily be adjusted to work with other college sites.
First, I have no background with Python, so this is pretty new to me. My programming background is pretty much limited to HTML, XML, and VBA. I am starting with the CBS Sports plugin, since I initially assumed that site was similar.
The main page has a player window and then media is sorted by 5 different categories: Most Recent, Sport, Channel, Featured, and Live Events. At some point, I will use those for the main menu in the plugin, but for now I’m just starting with the Channel category. Clicking Channel brings up a list of 6 groups. I was able to find the correct xpath for this, so now the plugin shows up has a first menu. Here is the code for that:
<br />
def MainMenuVideo():<br />
dir = MediaContainer(mediaType='video') <br />
#for item in XML.ElementFromURL(BASE_URL+"/video/player", True, errors='ignore').xpath('//div[@id="channelList"]/ul/li/a'):<br />
for item in XML.ElementFromURL(BASE_URL, True, errors='ignore').xpath('//div[@id="channel"]/ul/li/a'):<br />
title = item.text<br />
if(title != None):<br />
url = item.get('href')<br />
dir.Append(Function(DirectoryItem(VideoSection, title=title.strip(), thumb=R(ICON)), url=url))<br />
for child in item.xpath('../ul/li/a'):<br />
if child.text != None:<br />
Log("Child:"+str(child.text))<br />
childTitle = title + ": "+child.text<br />
#childTitle = title<br />
childUrl = child.get('href')<br />
Log(childUrl)<br />
dir.Append(Function(DirectoryItem(VideoSection, title=childTitle.strip(), thumb=R(ICON)), url=childUrl))<br />
return dir<br />
My first question is how to get a list of video files now after selecting a group. The CBS Sports plugin uses:
<br />
def VideoSection(sender, url):<br />
dir = MediaContainer(viewGroup='Details', mediaType='video') <br />
content = HTTP.Request(BASE_URL+"/"+url)<br />
Log(content)<br />
index = 25 + content.find("CBSi.app.VideoPlayer.Data")<br />
start = 1 + content.find("[", index)<br />
end = content.find("]", start)<br />
items = content[start:end].split("},{")<br />
for item in items:<br />
pieces = item.split(",")<br />
metaData = dict()<br />
for piece in pieces:<br />
tokens = piece.split('":"')<br />
if(len(tokens) > 1):<br />
metaData[tokens[0].replace('"','')] = tokens[1].replace('"','')<br />
<br />
if(metaData.has_key('title')):<br />
title = metaData['title'].replace('}','')<br />
thumb = metaData['large_thumbnail']<br />
summary = metaData['description']<br />
durationStr = metaData['duration']<br />
duration = convert(durationStr)<br />
pid = metaData['pid']<br />
dir.Append(Function(VideoItem(Video, title, thumb=thumb, summary=summary, duration=duration), pid=pid))<br />
return dir<br />
My guess is that this searches the HTML file for "CBSi.app.VideoPlayer.Data" and finds individual files after that. The xpath "//div[@id='video_content']/div" will give me a list of files visible on that page, but I'm not sure where to start placing that.