<?PHP
error_reporting(E_ALL ^ E_NOTICE);
//display the properties containing video information? true or false
$displayProperties = true;
//include video information scraped from hulu's video page? true or false
$includePage = true;
//include video information from hulu's public site maps? true or false
//Warning, only set this to true if the public site maps have been downloaded into the video data folder
//otherwise the script will fail.
$includeHulu = true;
//manage form submission for browser history
if( !empty($_REQUEST['formSubmitted']) ){
header('location: example.php?videoID='.$_REQUEST['videoID']);
}
include('hulu.class.php');
$hulu = new hulu;
$hulu->videoID = ( empty($_REQUEST['videoID']) ) ? '' : $_REQUEST['videoID'];
if( !empty($hulu->videoID) ){
if( empty($hulu->setData($_REQUEST['videoID'],$includePage,$includeHulu)) ){
$error = 'There was a problem processing your request, script reported:<br>'.$hulu->error;
}
}
?>
<html>
<head>
<title>Hulu Embed Example</title>
<style>
a {
color: black;
text-decoration: none;
}
a:hover {
color: red;
}
</style>
</head>
<body>
<form method="post">
<div>
Video ID: <input type="text" name="videoID" value="<?PHP echo (!empty($_REQUEST['videoID'])) ? $_REQUEST['videoID'] : '';?>"><br>
<em>(https://www.hulu.com/watch/<span style="color:red;">142476</span>)</em>
</div>
<div style="margin-top:10px;"><input type="hidden" name="formSubmitted" value="1"><input type="submit" value="Get Video"> [<a href="example.php">Start Over</a>]</div>
</form>
<?PHP
if( !empty($error) ){
?>
<div style="margin-top:10px; padding:10px; border: solid thin black; color:red;"><?PHP echo $error;?></div>
<?PHP
}
if( empty($error) AND !empty($hulu->videoID) ){
?>
<div><?PHP echo $hulu->embedData['html'];?></div>
<?PHP
if( !empty($hulu->videoData) ){
?>
<div style="margin-top:10px;">
<?PHP echo ( empty($hulu->videoData['season_number']) ) ? '' : 'Season: '.$hulu->videoData['season_number'].' ';?>
<?PHP echo ( empty($hulu->videoData['episode_number']) ) ? '' : 'Episode: '.$hulu->videoData['episode_number'].' ';?>
<?PHP echo ( empty($hulu->videoData['original_premiere_date']) ) ? '' : 'Premiered: '.$hulu->showDate($hulu->videoData['original_premiere_date']).' ';?>
<?PHP echo $hulu->videoData['title'];?> - Video Rated: <?PHP echo $hulu->videoData['content_rating'];?><?PHP echo ( empty($hulu->videoData['content_rating_reason']) ) ? '' : ' ('.$hulu->videoData['content_rating_reason'].')';?>
</div>
<div style="margin-top:10px; padding:10px; border: solid thin black;"><?PHP echo $hulu->videoData['description'];?></div>
<?PHP
}
if( !empty($hulu->videoData['video_game']) ){
?>
<div style="margin-top:10px;">
<img src="<?PHP echo $hulu->videoData['video_game']['key_art_url'];?>" alt="<?PHP echo $hulu->videoData['video_game']['title'];?>" width="400"><br>
Game Rated: <?PHP echo $hulu->videoData['video_game']['rating'];?> - <?PHP echo $hulu->videoData['video_game']['content_descriptor'];?>
</div>
<div style="margin-top:10px; padding:10px; border: solid thin black;"><?PHP echo $hulu->videoData['video_game']['description'];?></div>
<?PHP
}
?>
<div style="margin-top:10px;">
<?PHP
if( !empty($hulu->videoData['poster_url']) ){
?>
<img src="<?PHP echo $hulu->videoData['poster_url'];?>" alt="<?PHP echo $hulu->videoData['title'];?>">
<?PHP
}
if( !empty($hulu->videoData['company']['key_art_url']) ){
?>
<img src="<?PHP echo $hulu->videoData['company']['key_art_url'];?>" alt="<?PHP echo $hulu->videoData['company']['name'];?>" width="400">
<?PHP
}
?>
</div>
<?PHP
if( !empty($displayProperties) ){
?>
<hr>
embedData[]<br>
<?PHP var_dump($hulu->embedData);?>
<hr>
videoData[]<br>
<?PHP var_dump($hulu->videoData);?>
<hr>
huluResult[]<br>
<?PHP var_dump($hulu->huluResult);?>
<?PHP
}
}
?>
</body>
</html>
|