소스 검색

Added new filter and fix for private playlists

causefx 8 년 전
부모
커밋
ead7964d32
2개의 변경된 파일63개의 추가작업 그리고 9개의 파일을 삭제
  1. 12 8
      functions.php
  2. 51 1
      homepage.php

+ 12 - 8
functions.php

@@ -855,7 +855,11 @@ function resolvePlexItem($server, $token, $item, $nowPlaying = false, $showNames
     if (file_exists('images/cache/'.$key.'.jpg') && (time() - 604800) > filemtime('images/cache/'.$key.'.jpg') || !file_exists('images/cache/'.$key.'.jpg')) {
         $image_url = 'ajax.php?a=plex-image&img='.$thumb.'&height='.$height.'&width='.$width.'&key='.$key.'';        
     }
-    if(!$thumb){ $image_url = "images/no-np.png"; $key = "no-np"; }
+    if($nowPlaying){
+        if(!$thumb){ $image_url = "images/no-np.png"; $key = "no-np"; }
+    }else{
+        if(!$thumb){ $image_url = "images/no-list.png"; $key = "no-list"; }
+    }
 	if(isset($useImage)){ $image_url = $useImage; }
 	$openTab = (PLEXTABNAME) ? "true" : "false";
     // Assemble Item And Cache Into Array 
@@ -868,15 +872,15 @@ function resolvePlexItem($server, $token, $item, $nowPlaying = false, $showNames
 
 //Recent Added
 function outputRecentAdded($header, $items, $script = false, $array) {
-    $hideMenu = '<div class="pull-right"><div class="btn-group" role="group"><button type="button" class="btn waves btn-default btn-sm dropdown-toggle waves-effect waves-float" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">Filter<span class="caret"></span></button><ul style="right:0; left: auto" class="dropdown-menu">';
+    $hideMenu = '<div class="pull-right"><div class="btn-group" role="group"><button type="button" class="btn waves btn-default btn-sm dropdown-toggle waves-effect waves-float" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">Filter<span class="caret"></span></button><ul style="right:0; left: auto" class="dropdown-menu filter-recent-event">';
     if($array["movie"] == "true"){
-        $hideMenu .= '<li><a class="js-filter-movie" href="javascript:void(0)">Hide Movies</a></li>';
+        $hideMenu .= '<li data-filter="item-movie" data-filter-on="false"><a class="js-filter-movie" href="javascript:void(0)">Movies</a></li>';
     }
     if($array["season"] == "true"){
-        $hideMenu .= '<li><a class="js-filter-season" href="javascript:void(0)">Hide Show</a></li>';
+        $hideMenu .= '<li data-filter="item-season" data-filter-on="false"><a class="js-filter-season" href="javascript:void(0)">Shows</a></li>';
     }
     if($array["album"] == "true"){
-        $hideMenu .= '<li><a class="js-filter-album" href="javascript:void(0)">Hide Music</a></li>';
+        $hideMenu .= '<li data-filter="item-album" data-filter-on="false"><a class="js-filter-album" href="javascript:void(0)">Music</a></li>';
     }
     $hideMenu .= '</ul></div></div>';
     // If None Populate Empty Item
@@ -946,7 +950,7 @@ function getPlexStreams($size, $showNames, $role){
 				$items[] = resolvePlexItem($gotServer, PLEXTOKEN, $child, true, $showNames, $role);
 			}
 
-			return outputNowPlaying(translate('PLAYING_NOW_ON_PLEX')." <code>".count($items)." Streams</code>", $size, 'streams-plex', $items, "
+			return outputNowPlaying(translate('PLAYING_NOW_ON_PLEX')." ( ".count($items)." Streams )", $size, 'streams-plex', $items, "
 				setInterval(function() {
 					$('<div></div>').load('ajax.php?a=plex-streams',function() {
 						var element = $(this).find('[id]');
@@ -2690,7 +2694,7 @@ function getServerPath() {
         $protocol = "http://"; 
     }
 	$domain = '';
-    if (isset($_SERVER['SERVER_NAME']) && $_SERVER['SERVER_NAME'] != "_"){
+    if (isset($_SERVER['SERVER_NAME']) && strpos($_SERVER['SERVER_NAME'], '.') !== false){
         $domain = $_SERVER['SERVER_NAME'];
 	}elseif(isset($_SERVER['HTTP_HOST'])){
 		if (strpos($_SERVER['HTTP_HOST'], ':') !== false) {
@@ -3647,7 +3651,7 @@ function getPlexPlaylists(){
 			$output = "";
 			foreach($api AS $child) {
 				$items = "";
-				if($child['playlistType'] == "video"){
+				if ($child['playlistType'] == "video" && strpos(strtolower($child['title']) , 'private') === false){
 					$api = @curl_get($address.$child['key']."?X-Plex-Token=".PLEXTOKEN);
 					$api = simplexml_load_string($api);
 					if (is_array($api) || is_object($api)){

+ 51 - 1
homepage.php

@@ -665,7 +665,57 @@ $endDate = date('Y-m-d',strtotime("+".CALENDARENDDAY." days"));
                 ]
                 });
             });
+
+            
+            // each filter we click on
+            $(".filter-recent-event > li").on("click", function() {
+                
+            // toggle the filter on/off
+            $(this).data( "filter-on" , !$(this).data("filter-on") );
+            
+            // set all the filter strings to empty
+            var filtersOn = "";
+            var filtersOff = "";
+            var allFilters = "";
+            
+            // loop through each filter
+            $(".filter-recent-event > li").each(function() {
+                
+                // set a variable to hold the value of the filter class
+                // and also if the filter is on/off
+                var filter = $(this).data("filter");
+                var isOn = $(this).data("filter-on");
+
+                // add the filter to the filtersOn / filtersOff collection
+                if( isOn ) {
+                    filtersOn += "." + filter + ", ";
+                } else {
+                    filtersOff += "." + filter + ", ";
+                }
+
+            });
+            
+            // remove the last ", " from each filter collection.
+            filtersOn = filtersOn.replace(/, $/, "");
+            filtersOff = filtersOff.replace(/, $/, "");
+            
+            // remove all filters if none are on.
+            if( filtersOn === "" ) {
+                filtersOn = "*";
+                filtersOff = "";
+            }
+            
+            // combine the filters together ( on + off )
+            allFilters = filtersOn + ":not(" + filtersOff + ")";
+            console.log( allFilters );
             
+            // now filter the slides.
+            $('.recentItems ')
+                .slick('slickUnfilter')
+                .slick('slickFilter' , allFilters );
+
+            });
+            /*
             var movieFiltered = false;
             var seasonFiltered = false;
             var albumFiltered = false;
@@ -704,7 +754,7 @@ $endDate = date('Y-m-d',strtotime("+".CALENDARENDDAY." days"));
                 $(this).text('Hide Music');
                 albumFiltered = false;
               }
-            });
+            });*/
             
             /*$('.w-refresh').click(function(e){
                 var moreInfo = $(this).closest('div.overlay').addClass("show");