Couldn't take my 6 year daughter nagging me anymore so I've fixed the missing programs issue.
If you replace the current ShowEpisodes function with the following 2 functions it should then work, it basically scrapes for all series and then uses the existing functionality to scrape for individual episodes.
If the series scrape finds nothing then it does exactly what it used to do.
Code:
def ShowEpisodes( showId, showTitle ):
# Get the page with episodes for this show
print "Looking for episodes for: " + showTitle
url = "http://www.channel5.com" + showId + "/episodes"
html = geturllib.GetURL( url, 20000 ) # ~6 hrs
epsInfo = re.findall( 'episodes\?season=(.*?)">(.*?)</a>', html, re.DOTALL )
for season, series in epsInfo:
ParseEpisodes(url+"?season="+season, showTitle, series)
if len(epsInfo) == 0:
ParseEpisodes(url, showTitle)
xbmcplugin.endOfDirectory( handle=gPluginHandle, succeeded=True )
def ParseEpisodes(url, showTitle, series = ""):
print "URL: " + url
html = geturllib.GetURL( url, 20000 ) # ~6 hrs
listItems = []
# Does this show have multiple episodes?
x = re.search( '<ul class="resource_list episodes">(.*?)<!-- /#contents -->', html, re.DOTALL)
if ( x != None ):
# Extract the section with the episode list
html = x.groups()[0]
# Parse out the episodes
epsInfo = re.findall( '<li class="clearfix">.*?<a href="(.*?)".*?<img .*?src="(.*?)".*?<h3><a.*?>(.*?)</a>.*?<p class="description">(.*?)</p>(.*?)</div>', html, re.DOTALL )
for epInfo in epsInfo:
href = epInfo[0]
thumbnail = epInfo[1]
title = epInfo[2]
description = epInfo[3]
x = epInfo[4]
title = title.replace( '&', '&' )
title = title.replace( """, '"' )
title = title.replace( "£", '£' )
fn = showTitle + " - " + title
if ( re.search( 'vod_availability', x, re.DOTALL) ):
fullTitle = title
if series != "":
fullTitle = series + ": " + fullTitle
newListItem = xbmcgui.ListItem(fullTitle)
newListItem.setThumbnailImage(thumbnail)
newListItem.setInfo('video', {'Title': title, 'Plot': description, 'PlotOutline': description})
url = gBaseURL + '?ep=' + mycgi.URLEscape(href) + "&title=" + mycgi.URLEscape(title) + "&fn=" + mycgi.URLEscape(fn)
listItems.append( (url,newListItem,False) )
else:
title = re.search( '<h3 class="episode_header"><span class="sifr_grey_light">(.*?)</span></h3>', html, re.DOTALL ).groups()[0]
description = re.search( 'property="og:description" content="(.*?)"', html, re.DOTALL ).groups()[0]
thumbnail = re.search( 'property="og:image" content="(.*?)"', html, re.DOTALL ).groups()[0]
href = re.search( 'property="og:url" content="(.*?)"', html, re.DOTALL ).groups()[0]
href = re.search( '(/shows.*)', href ).groups()[0]
thumbnail = thumbnail.replace( 'facebook_with_play', 'large_size' )
if ( title <> showTitle ):
fn = showTitle + " - " + title
else:
fn = showTitle
url = gBaseURL + '?ep=' + mycgi.URLEscape(href) + "&title=" + mycgi.URLEscape(title) + "&fn=" + mycgi.URLEscape(fn)
newListItem = xbmcgui.ListItem(title)
newListItem.setThumbnailImage(thumbnail)
newListItem.setInfo('video', {'Title': title, 'Plot': description, 'PlotOutline': description})
listItems.append( (url,newListItem,False) )
xbmcplugin.addDirectoryItems( handle=gPluginHandle, items=listItems )
#xbmcplugin.endOfDirectory( handle=gPluginHandle, succeeded=True )