mgandalf Wrote:Regarding missing season episodes due to how the plugin grabs the rss feed which seems to only have 20 entries, I've created a short script to parse out all the episodes based on a given season. I'm not at all familiar with Python, so I wrote this as a proof of concept in Perl.
Maybe someone can adapt this to Python?
Mark,
A few weeks ago I ran into this same issue and learned enough python to write the below code (with bits of the original python function in-tact). I posted it in the other thread, but I don't think it has been implemented in the plug-in yet (or perhaps rwparris2 has another method in mind to take care of this issue).
PHP Code:
def addEpisodeList( self ):
#initialize variables
p=re.compile('(\d+)')#gets last number from "season ##"
currentSeason=p.findall(common.args.name)[0]
html = common.getHTML(common.args.url)
# Get Ajax URL for all seasons
ajaxMatches = re.finditer('http://www.hulu.com/videos/season_expander',html)
for match in ajaxMatches:
endPos = html.find(""",match.start())
nextUrl = html[match.start():endPos].replace("&","&")
# Determine Season
startPos = nextUrl.find('season_number=')
seasonNum = nextUrl[(startPos+14):(startPos+16)].replace('&','')
if seasonNum == currentSeason:
#Read the Ajax for this season
ajax = common.getHTML(nextUrl)
ajax = ajax.replace('\\"','"').replace('\\076','>').replace('\\074','<')
soup = BeautifulSoup(ajax)
episodeData = soup.findAll("td", { "class" : re.compile('^c[0-13-6]') })
for episode in episodeData:
if str(episode).find('class="c0"') > -1: # Episode Number
episodeNum = episode.renderContents()
elif str(episode).find('class="c1"') > -1: # Link and Title
episodeLink = episode.renderContents()
tmp = BeautifulSoup(episodeLink).find('a')
url = tmp['href'].split('#')[0]
episodeName = tmp.renderContents()
elif str(episode).find('class="c3"') > -1: # Duration
episodeDuration = episode.renderContents()
duration=episodeDuration.split(':')
duration=(int(duration[0])*60)+int(duration[1])
elif str(episode).find('class="c4"') > -1: # Air Date
airdate = episode.renderContents()
elif str(episode).find('class="c6"') > -1: # Queue and icon link?
if len(seasonNum)<2:seasonNum='0'+seasonNum
if len(episodeNum)<2:episodeNum='0'+episodeNum
name = 's'+seasonNum+'e'+episodeNum+' '+episodeName
thumb = ''
plot = ''
common.addDirectory(name, url,'TV_play', thumb, thumb, common.args.fanart, plot, 'genre')
If you put that into the _tv.py file, replacing the existing addEpisodeList, set the "flat_season" variable in your settings.xml to default of 1, and delete the _ty.pyo file (which will automatically be re-gen'ed next time you run the Hulu plug-in), then this will do what you are looking for.
Oh - Caveats of this code:
1. No thumbnails of the episodes themselves
2. No plot descriptions
3. It was written by someone completely new to Python, so I'm sure there are more pythony ways to do things.