# lib-rf-iplayer.pl # by Gav Ford # revford@blueyonder.co.uk # http://revford.pwp.blueyonder.co.uk # 2008-04-17, updated 2008-07-06 # subroutines for dealing with the BBC iPlayer sub iplayersearch # search the iPlayer and return a list of result URLs { $searchterm = $_[0]; @resultspage = split(/\n/, get('http://www.bbc.co.uk/iplayer/search/?q=' . $searchterm)); @results = grep {/tr\ class\=\"episode/} @resultspage; foreach (@results) { @thisresult = split(/\>/, $_); ($thisresulturlline) = grep {/class\=\"uid\ url/} @thisresult; @thisresulturlsplit = split(/\ /, $thisresulturlline); ($thisresulturl) = grep {/href/} @thisresulturlsplit; ($null, $thisresulturl) = split(/\"/, $thisresulturl); push(@resultlist, 'http://www.bbc.co.uk' . $thisresulturl); } return (@resultlist); } sub iplayertitle # take an iPlayer URL and find some program information { $pageurl = $_[0]; @showpage = split(/\n/, get($pageurl)); ($showtitle) = grep {/h1/} @showpage; $showtitle =~ s/\ \ /\ /g; $showtitle =~ s/\<[^\<]+\>//g; $showtitle =~ s/\t|\n|//g; return ($showtitle); } 1;