Created
January 11, 2012 21:20
-
-
Save raytiley/1596826 to your computer and use it in GitHub Desktop.
A simple php script for printing a html table of links to On Demand Programming from Cablecast Servers
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* | |
This script prints an html table of all shows that are availalbe for VOD on the server | |
The shows must have valid event dates that are in the past | |
*/ | |
//SETUP | |
date_default_timezone_set('America/New_York'); //Probably doesn't really matter. A few hours shouldn't make a difference | |
$serverAddress = "http://pittsfieldtv.dyndns.org/"; //This will be where you can publically log onto front door. Rembember to leave off trailing slash | |
$channelID = 1; //One will work for most stations unless you've deleted channels in the past | |
//END SETUP | |
//Sorting function for table rows. Sorts by alphabet and EventDate | |
function cmp($a, $b) { | |
$score = strcmp($a["title"], $b["title"]); | |
if($score == 0) { | |
return strtotime($a["date"]) < strtotime($b["date"]) ? 1 : -1; | |
} | |
else { | |
return $score; | |
} | |
} | |
$client = new SoapClient($serverAddress . "/CablecastWS/CablecastWS.asmx?WSDL", array('cache_wsdl' => 0)); // Creates New SOAP client using WSDL file | |
$searchDate = date("Y-m-d")."T12:00:00"; | |
// Search for all shows that have an event date less than now that are available for VOD | |
$result = $client->AdvancedShowSearch( | |
array( | |
'ChannelID' => $channelID, | |
'searchString' => '', | |
'eventDate' => $searchDate, | |
'dateComparator' => '<', | |
'restrictToCategoryID' => 0, | |
'restrictToProducerID' => 0, | |
'restrictToProjectID' => 0, | |
'displayStreamingShowsOnly' => 1, | |
'searchOtherSites' => 0,) | |
); | |
if($result->AdvancedShowSearchResult->SiteSearchResult->Shows->ShowInfo) { | |
if($result->AdvancedShowSearchResult->SiteSearchResult->ShowInfo->ShowInfo->ShowID) { | |
$result->AdvancedShowSearchResult->SiteSearchResult->ShowInfo = array($result->AdvancedShowSearch->SiteSearchResult->ShowInfo); // Get single results into an array so they can be processed the same | |
} | |
echo "<table border ='0'><tr>\n"; | |
echo "<th>Program Title</th><th>Link</th></tr>\n"; | |
//Create an Array for Sorting | |
$tableRows = array(); | |
foreach($result->AdvancedShowSearchResult->SiteSearchResult->Shows->ShowInfo as $show) { | |
$tableRows[] = array("title" => $show->Title, "date" => $show->EventDate, "row" => "<tr><td>" . $show->Title . "</td><td><a href='" . $show->StreamingFileURL . "'>Watch Now</a></td></tr>\n"); | |
} | |
//Sort the Array | |
usort($tableRows, "cmp"); | |
//Print out the rows from the sorted array | |
foreach($tableRows as $row) { | |
echo$row["row"]; | |
} | |
echo "</table>\n"; | |
} | |
else { | |
//There is probably something wrong if this shows up. | |
echo "There are no Shows currently available for on demand viewing."; | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment