diff --git a/api.php b/api.php index 7a9563382696741408c76994bc44e0e6c6a0d2a4..a542715b11bee0cb58e3cce7ad05067de2cd9818 100644 --- a/api.php +++ b/api.php @@ -15,8 +15,8 @@ if ($_GET['get'] == 'shows' && $_GET['limit'] && isset($_GET['offset'])) { } array_push($output, array( "id" => $show['id'], - "name" => $show['name'], - "folder" => str_replace($showsPath.'/', '', $show['location']), + "name" => $show['name'], + "folder" => str_replace($showsPath.'/', '', $show['location']), "thumb" => cleanName($show['name']), "seasons" => $seasons )); @@ -24,19 +24,20 @@ if ($_GET['get'] == 'shows' && $_GET['limit'] && isset($_GET['offset'])) { } echo json_encode($output); die; - + } + if ($_GET['get'] == 'movies' && $_GET['limit'] && isset($_GET['offset'])) { $cpdb = new PDO('sqlite:'.$cpPath.'/couchpotato.db'); $cpdb->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); - $movies = $cpdb->query("SELECT l.identifier AS imdb, lt.title, l.year, l.tagline, l.plot, s.label AS status FROM library AS l - JOIN librarytitle AS lt ON l.id=lt.libraries_id - JOIN movie AS m on l.id=m.library_id + $movies = $cpdb->query("SELECT l.identifier AS imdb, lt.title, l.year, l.tagline, l.plot, s.label AS status FROM library AS l + JOIN librarytitle AS lt ON l.id=lt.libraries_id + JOIN movie AS m on l.id=m.library_id JOIN status AS s ON m.status_id=s.id - WHERE m.status_id = 3 AND `default` = 1 + WHERE m.status_id = 3 AND `default` = 1 ORDER BY title ASC LIMIT ".$_GET['limit']." OFFSET ".$_GET['offset'].";"); $output = array(); foreach ($movies as $movie) { @@ -51,7 +52,7 @@ if ($_GET['get'] == 'movies' && $_GET['limit'] && isset($_GET['offset'])) { } echo json_encode($output); die; - + } @@ -63,23 +64,23 @@ if ($_GET['get'] == 'poster' && (!empty($_GET['show']) || !empty($_GET['movie']) $poster = get_absolute_path('poster/'.cleanName($_GET['show']).'.jpg'); else $poster = get_absolute_path('poster/'. cleanName($_GET['movie']).'.jpg'); - + if(!file_exists($poster)) { - + if($_GET['show'] && $_GET['season']) - $source = '/'.get_absolute_path($showsPath.'/'.$_GET['show'].'/season'.$_GET['season'].'-poster.jpg'); + $source = '/'.get_absolute_path($showsPath.'/'.cleanName($_GET['show'], false).'/season'.$_GET['season'].'-poster.jpg'); elseif($_GET['show']) - $source = '/'.get_absolute_path($showsPath.'/'.$_GET['show'].'/poster.jpg'); + $source = '/'.get_absolute_path($showsPath.'/'.cleanName($_GET['show'], false).'/poster.jpg'); else - $source = '/'.get_absolute_path($moviesPath.'/'.$_GET['movie'].'/'.$_GET['movie'].'-poster.jpg'); - + $source = '/'.get_absolute_path($moviesPath.'/'.cleanName($_GET['movie'], false).'/'.cleanName($_GET['movie'], false).'-poster.jpg'); + if(file_exists($source)) { $img = new Imagick(); $img->setOption('jpeg:size', '800x532'); $img->readImage($source); $img->thumbnailImage(0, 220); $img->setImageCompression(Imagick::COMPRESSION_JPEG); - $img->setImageCompressionQuality(80); + $img->setImageCompressionQuality(80); $img->writeImage($poster); }elseif($_GET['season'] != '') { header("HTTP/1.0 404 Not Found"); @@ -88,28 +89,29 @@ if ($_GET['get'] == 'poster' && (!empty($_GET['show']) || !empty($_GET['movie']) $poster = 'img/no_poster.jpg'; } } - + header('Content-type: image/jpeg'); header('Content-length: '.filesize($poster)); readfile($poster); die; } + if ($_GET['get'] == 'fanart' && (!empty($_GET['show']) || !empty($_GET['movie']))) { if($_GET['show']) $fanart = get_absolute_path('fanart/'. cleanName($_GET['show']).'.jpg'); else $fanart = get_absolute_path('fanart/'. cleanName($_GET['movie']).'.jpg'); - - + + if(!file_exists($fanart)) { - + if($_GET['show']) - $source = '/'.get_absolute_path($showsPath.'/'.$_GET['show'].'/fanart.jpg'); + $source = '/'.get_absolute_path($showsPath.'/'.cleanName($_GET['show'], false).'/fanart.jpg'); else - $source = '/'.get_absolute_path($moviesPath.'/'.$_GET['movie'].'/'.$_GET['movie'].'-fanart.jpg'); - + $source = '/'.get_absolute_path($moviesPath.'/'.cleanName($_GET['movie'], false).'/'.cleanName($_GET['movie'], false).'-fanart.jpg'); + if(file_exists($source)) { $img = new Imagick(); $img->setOption('jpeg:size', '1024x576'); @@ -121,33 +123,34 @@ if ($_GET['get'] == 'fanart' && (!empty($_GET['show']) || !empty($_GET['movie']) $overlay->setImageOpacity(0.80); $img->compositeImage($overlay, imagick::COMPOSITE_OVER, 0, 0); $img->setImageCompression(Imagick::COMPRESSION_JPEG); - $img->setImageCompressionQuality(75); + $img->setImageCompressionQuality(75); $img->writeImage($fanart); }else{ $fanart = 'img/no_fanart.jpg'; } } - + header('Content-type: image/jpeg'); header('Content-length: '.filesize($fanart)); readfile($fanart); die; } + if ($_GET['get'] == 'logo' && (!empty($_GET['show']) || !empty($_GET['movie']))) { if($_GET['show']) $logo = get_absolute_path('logo/'.cleanName($_GET['show']).'.png'); else $logo = get_absolute_path('logo/'.cleanName($_GET['movie']).'.png'); - + if(!file_exists($logo)) { - + if($_GET['show']) - $source = '/'.get_absolute_path($showsPath.'/'.$_GET['show'].'/clearlogo.png'); + $source = '/'.get_absolute_path($showsPath.'/'.cleanName($_GET['show'], false).'/clearlogo.png'); else - $source = '/'.get_absolute_path($moviesPath.'/'.$_GET['movie'].'/'.$_GET['movie'].'-clearlogo.png'); - + $source = '/'.get_absolute_path($moviesPath.'/'.cleanName($_GET['movie'], false).'/'.cleanName($_GET['movie'], false).'-clearlogo.png'); + if(file_exists($source)) { $img = new Imagick(); $img->readImage($source); @@ -158,13 +161,14 @@ if ($_GET['get'] == 'logo' && (!empty($_GET['show']) || !empty($_GET['movie']))) die; } } - + header('Content-type: image/png'); header('Content-length: '.filesize($logo)); readfile($logo); die; } + if ($_GET['get'] == 'episodes' && !empty($_GET['show']) && isset($_GET['season'])) { $sbdb = new PDO('sqlite:'.$sbPath.'/sickbeard.db'); $episodes = $sbdb->query("SELECT episode, name, airdate, status FROM tv_episodes WHERE showid = '".$_GET['show']."' AND season = '".$_GET['season']."' ORDER BY episode ASC;"); @@ -178,6 +182,7 @@ if ($_GET['get'] == 'episodes' && !empty($_GET['show']) && isset($_GET['season'] die; } + if ($_GET['get'] == 'latest' && $_GET['type'] == 'shows') { $sbdb = new PDO('sqlite:'.$sbPath.'/sickbeard.db'); $eps = $sbdb->query("SELECT s.show_name, ep.name, ep.episode, ep.season, ep.airdate FROM tv_episodes AS ep JOIN tv_shows AS s ON ep.showid=s.tvdb_id WHERE ep.status LIKE '%4' ORDER BY ep.airdate DESC LIMIT 10;"); @@ -192,10 +197,14 @@ if ($_GET['get'] == 'latest' && $_GET['type'] == 'shows') { } -function cleanName($show) { - return preg_replace("/[^a-zA-Z0-9]/", "_", $show); +function cleanName($name, $strict = true) { + if($strict == true) + return preg_replace("/[^a-zA-Z0-9]/", "_", $name); + else + return preg_replace("/:/", "", $name); } + function get_absolute_path($path) { $path = str_replace(array('/', '\\'), DIRECTORY_SEPARATOR, $path); $parts = array_filter(explode(DIRECTORY_SEPARATOR, $path), 'strlen'); diff --git a/css/mediarack.css b/css/mediarack.css index 897971d9d429540e9f92284311a9936f3480702c..87d8f41097784f4f28339c3fcb3694211eb31edd 100644 --- a/css/mediarack.css +++ b/css/mediarack.css @@ -1,13 +1,18 @@ html { overflow: -moz-scrollbars-vertical; overflow: scroll; - /* overflow-y: scroll; *doesn�t work with firefox*/ + /* overflow-y: scroll; *doesn�t work with firefox*/ } body { padding-top: 70px; } +.navbar-brand { + padding-top: 0; + padding-bottom: 0; +} + .show { margin-bottom: 50px; min-height: 200px; diff --git a/img/logo.png b/img/logo.png new file mode 100644 index 0000000000000000000000000000000000000000..4f729e9126847c6db3c419e19504582a06125642 Binary files /dev/null and b/img/logo.png differ diff --git a/img/opengraph.jpg b/img/opengraph.jpg new file mode 100644 index 0000000000000000000000000000000000000000..413e4f289b741892faee00e57e501f928ee220f1 Binary files /dev/null and b/img/opengraph.jpg differ diff --git a/index.php b/index.php index 134b6f80e37791c32cef0c59d6ee93be2908600d..733facc424ccc39dd2228a881bbcf333c5f1f5bd 100644 --- a/index.php +++ b/index.php @@ -9,6 +9,12 @@ <link rel="shortcut icon" href="img/favicon.png"> <title>MediaRack</title> + + <meta property="og:title" content="MediaRack" /> + <meta property="og:description" content="My TV Show and Movie library" /> + <meta property="og:type" content="website" /> + <meta property="og:url" content="http://<?php echo $_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"]; ?>" /> + <meta property="og:image" content="http://<?php echo $_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"]; ?>img/opengraph.jpg" /> <link href="css/bootstrap.min.css" rel="stylesheet"> <link href="css/bootstrap-slate.min.css" rel="stylesheet"> @@ -36,7 +42,7 @@ <span class="icon-bar"></span> <span class="icon-bar"></span> </button> - <a class="navbar-brand" href="#">MediaRack</a> + <a class="navbar-brand" href="#"><img alt="MediaRack" src="img/logo.png" /></a> </div> <div class="navbar-collapse collapse"> <ul class="nav navbar-nav"> @@ -49,7 +55,7 @@ </div> <div class="container"> - + <div class="content jumbotron" id="home"> <div class="jcarousel-wrapper"> <div class="jcarousel"> @@ -59,11 +65,11 @@ <a href="#" class="jcarousel-control-next">›</a> </div> </div> - + <div class="content" id="shows"></div> - + <div class="content" id="movies"></div> - + </div> <!-- /container --> @@ -76,5 +82,22 @@ <script src="js/jquery.lazyload.min.js"></script> <script src="js/jquery.scrollstop.js"></script> <script src="js/mediarack.js"></script> + + <!-- Piwik --> + <script type="text/javascript"> + var _paq = _paq || []; + _paq.push(["trackPageView"]); + _paq.push(["enableLinkTracking"]); + + (function() { + var u=(("https:" == document.location.protocol) ? "https" : "http") + "://stats.faked.org/"; + _paq.push(["setTrackerUrl", u+"piwik.php"]); + _paq.push(["setSiteId", "7"]); + var d=document, g=d.createElement("script"), s=d.getElementsByTagName("script")[0]; g.type="text/javascript"; + g.defer=true; g.async=true; g.src=u+"piwik.js"; s.parentNode.insertBefore(g,s); + })(); + </script> + <!-- End Piwik Code --> + </body> </html>