Skip to content

Instantly share code, notes, and snippets.

@dbaines
Created July 31, 2012 05:57
Show Gist options
  • Save dbaines/3214115 to your computer and use it in GitHub Desktop.
Save dbaines/3214115 to your computer and use it in GitHub Desktop.
List CouchPotatoServer coming theatre and dvd release dates
<style>
body, table, td {font-family: Arial, sans-serif; font-size: 14px;}
.nodate {font-style: italic;}
td {padding: 5px 10px;}
tr:hover td {background: #eee;}
th {font-weight: bold; text-align: left; padding: 10px; border-bottom: 2px solid #ccc;}
</style>
<table border="0" cellspacing="0" class="tablesorter">
<thead>
<tr>
<th>Title</th>
<th>Theatre Date</th>
<th>DVD Date</th>
</tr>
</thead>
<tbody>
<?php
// Configuring our API call
$host = "http://localhost:5050";
$apikey = "123456";
$movielist = json_decode(file_get_contents($host."/api/".$apikey."/movie.list/"));
// Run through each wanted movie from the API call
foreach($movielist->{movies} as $movie){
// Get basic information about this movie
$title = $movie->{library}->{info}->{titles}[0];
$year = $movie->{library}->{year};
$getTheatre = $movie->{library}->{info}->{released};
$getDVDDate = $movie->{library}->{info}->{release_date}->{dvd};
$theatre = date("d/m/Y", strtotime($getTheatre));
$dvd = date("d/m/Y", $getDVDDate);
// Convert Unknown Dates
if($getTheatre == ""){
$theatre = "<em>-</em>";
}
if($getDVDDate == "" or $getDVDDate == "0"){
$dvd = "<em>-</em>";
}
// Build our table row
echo "<tr>";
/*
// Alternate formatting for titles without a date
if($date != ""){
echo "<td class='title'>".$title."</td><td class='date'>".$newDate."</td>";
} else {
echo "<td class='title nodate'>".$title."</td><td class='date nodate'>Unknown Date</td>";
}
*/
echo "<td class='title'>".$title."</td><td class='tdate'>".$theatre."</td><td class='ddate'>".$dvd."</td></tr>";
echo "</tr>";
}
?>
</tbody>
</table>
<script src="jquery.js"></script>
<script src="jquery.tablesorter.min.js"></script>
<script>
$(function(){
$(".tablesorter").tablesorter({dateFormat: "uk"});
});
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment