Răsfoiți Sursa

open in plex button work

causefx 8 ani în urmă
părinte
comite
bce691d7b0

+ 1 - 0
api/config/default.php

@@ -20,6 +20,7 @@ return array(
     'plexURL' => '',
     'plexTabURL' => '',
     'plexToken' => '',
+    'plexTabName' => '',
     'embyURL' => '',
     'embyToken' => '',
     'plexID' => '',

+ 45 - 45
api/functions/homepage-connect-functions.php

@@ -95,53 +95,53 @@ function resolvePlexItem($item) {
             $plexItem['nowPlayingKey'] = (string)$item['ratingKey'] . "-np";
             $plexItem['nowPlayingTitle'] = (string)$item['title'];
             $plexItem['nowPlayingBottom'] = (string)$item['year'];
-		}
-        $plexItem['elapsed'] = isset($item['viewOffset']) && $item['viewOffset'] !== '0' ? (int)$item['viewOffset'] : null;
-        $plexItem['duration'] = isset($item['duration']) ? (int)$item['duration'] : (int)$item->Media['duration'];
-        $plexItem['watched'] = ($plexItem['elapsed'] && $plexItem['duration'] ? floor(($plexItem['elapsed'] / $plexItem['duration']) * 100) : 0);
-        $plexItem['transcoded'] = isset($item->TranscodeSession['progress']) ? floor((int)$item->TranscodeSession['progress']- $plexItem['watched']) : '';
-        $plexItem['stream'] = isset($item->Media->Part->Stream['decision']) ? (string)$item->Media->Part->Stream['decision']: '';
-        $plexItem['id'] = str_replace('"', '', (string)$item->Player['machineIdentifier']);
-        $plexItem['session'] = (string)$item->Session['id'];
-        $plexItem['bandwidth'] = (string)$item->Session['bandwidth'];
-        $plexItem['bandwidthType'] = (string)$item->Session['location'];
-        $plexItem['sessionType'] = isset($item->TranscodeSession['progress']) ? 'Transcoding' : 'Direct Playing';
-        $plexItem['state'] = (((string)$item->Player['state'] == "paused") ? "pause" : "play");
-        $plexItem['user'] = ($GLOBALS['homepageShowStreamNames'] && qualifyRequest($GLOBALS['homepageShowStreamNamesAuth']) ) ? (string)$item->User['title'] : "";
-        $plexItem['userThumb'] = ($GLOBALS['homepageShowStreamNames'] && qualifyRequest($GLOBALS['homepageShowStreamNamesAuth']) ) ? (string)$item->User['thumb'] : "";
-        $plexItem['userAddress'] = ($GLOBALS['homepageShowStreamNames'] && qualifyRequest($GLOBALS['homepageShowStreamNamesAuth']) ) ? (string)$item->Player['address'] : "x.x.x.x";
-        $plexItem['userStream'] = array(
-            'platform' => (string)$item->Player['platform'],
-            'device' => (string)$item->Player['device'],
-            'stream' => (string)$item->Media->Part['decision'].($item->TranscodeSession['throttled'] == '1' ? ' (Throttled)': ''),
-            'videoResolution' => (string)$item->Media['videoResolution'],
-            'throttled' => ($item->TranscodeSession['throttled'] == 1) ? true : false,
-            'sourceVideoCodec' => (string)$item->TranscodeSession['sourceVideoCodec'],
-            'videoCodec' => (string)$item->TranscodeSession['videoCodec'],
-            'audioCodec' => (string)$item->TranscodeSession['audioCodec'],
-            'sourceAudioCodec' => (string)$item->TranscodeSession['sourceAudioCodec'],
-            'videoDecision' => streamType((string)$item->TranscodeSession['videoDecision']),
-            'audioDecision' => streamType((string)$item->TranscodeSession['audioDecision']),
-            'container' => (string)$item->TranscodeSession['container'],
-            'audioChannels' => (string)$item->TranscodeSession['audioChannels']
-        );
-        $plexItem['address'] = $GLOBALS['plexTabURL'] ? $GLOBALS['plexTabURL']."/web/index.html#!/server/".$GLOBALS['plexID']."/details?key=/library/metadata/".$item['ratingKey'] : "https://app.plex.tv/web/app#!/server/".$GLOBALS['plexID']."/details?key=/library/metadata/".$item['ratingKey'];
-        $plexItem['nowPlayingOriginalImage'] = 'api/?v1/image&source=plex&img='.$plexItem['nowPlayingThumb'].'&height='.$nowPlayingHeight.'&width='.$nowPlayingWidth.'&key='.$plexItem['nowPlayingKey'].'$'.randString();
-        $plexItem['originalImage'] = 'api/?v1/image&source=plex&img='.$plexItem['thumb'].'&height='.$height.'&width='.$width.'&key='.$plexItem['key'].'$'.randString();
-        if (file_exists($cacheDirectory.$plexItem['nowPlayingKey'].'.jpg')){ $plexItem['nowPlayingImageURL'] = $cacheDirectoryWeb.$plexItem['nowPlayingKey'].'.jpg'; }
-        if (file_exists($cacheDirectory.$plexItem['key'].'.jpg')){ $plexItem['imageURL']  = $cacheDirectoryWeb.$plexItem['key'].'.jpg'; }
-        if (file_exists($cacheDirectory.$plexItem['nowPlayingKey'].'.jpg') && (time() - 604800) > filemtime($cacheDirectory.$plexItem['nowPlayingKey'].'.jpg') || !file_exists($cacheDirectory.$plexItem['nowPlayingKey'].'.jpg')) {
-            $plexItem['nowPlayingImageURL'] = 'api/?v1/image&source=plex&img='.$plexItem['nowPlayingThumb'].'&height='.$nowPlayingHeight.'&width='.$nowPlayingWidth.'&key='.$plexItem['nowPlayingKey'].'';
-        }
-        if (file_exists($cacheDirectory.$plexItem['key'].'.jpg') && (time() - 604800) > filemtime($cacheDirectory.$plexItem['key'].'.jpg') || !file_exists($cacheDirectory.$plexItem['key'].'.jpg')) {
-            $plexItem['imageURL'] = 'api/?v1/image&source=plex&img='.$plexItem['thumb'].'&height='.$height.'&width='.$width.'&key='.$plexItem['key'].'';
-        }
-        if(!$plexItem['nowPlayingThumb'] ){ $plexItem['nowPlayingOriginalImage']  = $plexItem['nowPlayingImageURL']  = "images/no-np.png"; $plexItem['nowPlayingKey'] = "no-np"; }
-        if(!$plexItem['thumb'] ){  $plexItem['originalImage'] = $plexItem['imageURL'] = "images/no-list.png"; $plexItem['key'] = "no-list"; }
-
+	}
+    $plexItem['elapsed'] = isset($item['viewOffset']) && $item['viewOffset'] !== '0' ? (int)$item['viewOffset'] : null;
+    $plexItem['duration'] = isset($item['duration']) ? (int)$item['duration'] : (int)$item->Media['duration'];
+    $plexItem['watched'] = ($plexItem['elapsed'] && $plexItem['duration'] ? floor(($plexItem['elapsed'] / $plexItem['duration']) * 100) : 0);
+    $plexItem['transcoded'] = isset($item->TranscodeSession['progress']) ? floor((int)$item->TranscodeSession['progress']- $plexItem['watched']) : '';
+    $plexItem['stream'] = isset($item->Media->Part->Stream['decision']) ? (string)$item->Media->Part->Stream['decision']: '';
+    $plexItem['id'] = str_replace('"', '', (string)$item->Player['machineIdentifier']);
+    $plexItem['session'] = (string)$item->Session['id'];
+    $plexItem['bandwidth'] = (string)$item->Session['bandwidth'];
+    $plexItem['bandwidthType'] = (string)$item->Session['location'];
+    $plexItem['sessionType'] = isset($item->TranscodeSession['progress']) ? 'Transcoding' : 'Direct Playing';
+    $plexItem['state'] = (((string)$item->Player['state'] == "paused") ? "pause" : "play");
+    $plexItem['user'] = ($GLOBALS['homepageShowStreamNames'] && qualifyRequest($GLOBALS['homepageShowStreamNamesAuth']) ) ? (string)$item->User['title'] : "";
+    $plexItem['userThumb'] = ($GLOBALS['homepageShowStreamNames'] && qualifyRequest($GLOBALS['homepageShowStreamNamesAuth']) ) ? (string)$item->User['thumb'] : "";
+    $plexItem['userAddress'] = ($GLOBALS['homepageShowStreamNames'] && qualifyRequest($GLOBALS['homepageShowStreamNamesAuth']) ) ? (string)$item->Player['address'] : "x.x.x.x";
+    $plexItem['userStream'] = array(
+        'platform' => (string)$item->Player['platform'],
+        'device' => (string)$item->Player['device'],
+        'stream' => (string)$item->Media->Part['decision'].($item->TranscodeSession['throttled'] == '1' ? ' (Throttled)': ''),
+        'videoResolution' => (string)$item->Media['videoResolution'],
+        'throttled' => ($item->TranscodeSession['throttled'] == 1) ? true : false,
+        'sourceVideoCodec' => (string)$item->TranscodeSession['sourceVideoCodec'],
+        'videoCodec' => (string)$item->TranscodeSession['videoCodec'],
+        'audioCodec' => (string)$item->TranscodeSession['audioCodec'],
+        'sourceAudioCodec' => (string)$item->TranscodeSession['sourceAudioCodec'],
+        'videoDecision' => streamType((string)$item->TranscodeSession['videoDecision']),
+        'audioDecision' => streamType((string)$item->TranscodeSession['audioDecision']),
+        'container' => (string)$item->TranscodeSession['container'],
+        'audioChannels' => (string)$item->TranscodeSession['audioChannels']
+    );
+    $plexItem['address'] = $GLOBALS['plexTabURL'] ? $GLOBALS['plexTabURL']."/web/index.html#!/server/".$GLOBALS['plexID']."/details?key=/library/metadata/".$item['ratingKey'] : "https://app.plex.tv/web/app#!/server/".$GLOBALS['plexID']."/details?key=/library/metadata/".$item['ratingKey'];
+    $plexItem['nowPlayingOriginalImage'] = 'api/?v1/image&source=plex&img='.$plexItem['nowPlayingThumb'].'&height='.$nowPlayingHeight.'&width='.$nowPlayingWidth.'&key='.$plexItem['nowPlayingKey'].'$'.randString();
+    $plexItem['originalImage'] = 'api/?v1/image&source=plex&img='.$plexItem['thumb'].'&height='.$height.'&width='.$width.'&key='.$plexItem['key'].'$'.randString();
+    $plexItem['openTab'] = $GLOBALS['plexTabURL'] && $GLOBALS['plexTabName'] ? true : false;
+    $plexItem['tabName'] = $GLOBALS['plexTabName'] ? $GLOBALS['plexTabName'] : '';
+    if (file_exists($cacheDirectory.$plexItem['nowPlayingKey'].'.jpg')){ $plexItem['nowPlayingImageURL'] = $cacheDirectoryWeb.$plexItem['nowPlayingKey'].'.jpg'; }
+    if (file_exists($cacheDirectory.$plexItem['key'].'.jpg')){ $plexItem['imageURL']  = $cacheDirectoryWeb.$plexItem['key'].'.jpg'; }
+    if (file_exists($cacheDirectory.$plexItem['nowPlayingKey'].'.jpg') && (time() - 604800) > filemtime($cacheDirectory.$plexItem['nowPlayingKey'].'.jpg') || !file_exists($cacheDirectory.$plexItem['nowPlayingKey'].'.jpg')) {
+        $plexItem['nowPlayingImageURL'] = 'api/?v1/image&source=plex&img='.$plexItem['nowPlayingThumb'].'&height='.$nowPlayingHeight.'&width='.$nowPlayingWidth.'&key='.$plexItem['nowPlayingKey'].'';
+    }
+    if (file_exists($cacheDirectory.$plexItem['key'].'.jpg') && (time() - 604800) > filemtime($cacheDirectory.$plexItem['key'].'.jpg') || !file_exists($cacheDirectory.$plexItem['key'].'.jpg')) {
+        $plexItem['imageURL'] = 'api/?v1/image&source=plex&img='.$plexItem['thumb'].'&height='.$height.'&width='.$width.'&key='.$plexItem['key'].'';
+    }
+    if(!$plexItem['nowPlayingThumb'] ){ $plexItem['nowPlayingOriginalImage']  = $plexItem['nowPlayingImageURL']  = "images/no-np.png"; $plexItem['nowPlayingKey'] = "no-np"; }
+    if(!$plexItem['thumb'] ){  $plexItem['originalImage'] = $plexItem['imageURL'] = "images/no-list.png"; $plexItem['key'] = "no-list"; }
 	if(isset($useImage)){ $plexItem['useImage'] = $useImage; }
     return $plexItem;
-
 }
 function getPlexStreams(){
 	if(!empty($GLOBALS['plexURL']) && !empty($GLOBALS['plexToken']) && !empty($GLOBALS['plexID'] && qualifyRequest($GLOBALS['homepagePlexStreamsAuth']))){

+ 17 - 3
api/functions/homepage-functions.php

@@ -220,13 +220,13 @@ function getHomepageList(){
                     array(
             			'type' => 'switch',
             			'name' => 'homepageShowStreamNames',
-            			'label' => 'Show Usernames',
+            			'label' => 'Show User Information',
             			'value' => $GLOBALS['homepageShowStreamNames']
             		),
 					array(
     					'type' => 'select',
     					'name' => 'homepageShowStreamNamesAuth',
-                        'label' => 'Username Authorization',
+                        'label' => 'User Information Authorization',
     					'value' => $GLOBALS['homepageShowStreamNamesAuth'],
     					'options' => $groups
     				),
@@ -243,7 +243,21 @@ function getHomepageList(){
                         'label' => 'Recent Items Refresh Seconds',
     					'value' => $GLOBALS['homepageRecentRefresh'],
     					'options' => $time
-    				)
+    				),
+					array(
+                        'type' => 'input',
+                        'name' => 'plexTabName',
+                        'label' => 'Plex Tab Name',
+                        'value' => $GLOBALS['plexTabName'],
+						'placeholder' => 'Only use if you have Plex in a reverse proxy'
+                    ),
+					array(
+                        'type' => 'input',
+                        'name' => 'plexTabURL',
+                        'label' => 'Plex Tab URL',
+                        'value' => $GLOBALS['plexTabURL'],
+						'placeholder' => 'http(s)://hostname:port'
+                    )
                 )
             )
         ),

+ 19 - 2
js/custom.js

@@ -91,7 +91,7 @@ function pageLoad(){
     });
     $(function () {
         $('.recent-items').owlCarousel({
-    	    margin:0,
+    	    margin:40,
     	    nav:false,
     		autoplay:false,
             dots:false,
@@ -1530,7 +1530,24 @@ $(document).on("click", ".refreshImage", function(e) {
         message('Image Refreshed ',' Clear Cache Please','bottom-right','#FFF','success','3000');
 	}, 1000);
 });
-
+// open tab code
+$(document).on("click", ".openTab", function(e) {
+    if($(this).attr("data-open-tab") === "true") {
+        var tabName = $(this).attr("data-tab-name");
+		var container = $("#container-"+tabName);
+		var activeFrame = container.children('iframe');
+		if(activeFrame.length === 1){
+			$('#menu-'+tabName+' a').trigger("click");
+            activeFrame.attr("src", $(this).attr("data-url"));
+		}else{
+            container.attr("data-url", $(this).attr("data-url"));
+            $('#menu-'+tabName+' a').trigger("click");
+		}
+	}else{
+        var source = $(this).attr("data-url");
+		window.open(source, '_blank');
+	}
+});
 /* ===== Open-Close Right Sidebar ===== */
 
 $(document).on("click", ".right-side-toggle", function () {

+ 2 - 2
js/functions.js

@@ -1853,9 +1853,9 @@ function buildPlexStreamItem(array){
 							<ul class="el-info p-t-20 m-t-20">
 								<li><a class="btn default btn-outline inline-popups" href="#`+v.session+`" data-effect="mfp-zoom-out"><i class="icon-graph"></i></a></li>
 								<li><a class="btn default btn-outline image-popup-vertical-fit" href="`+v.nowPlayingImageURL+`"><i class="icon-info"></i></a></li>
-								<li><a class="btn default btn-outline" href="javascript:void(0);"><i class="icon-share-alt"></i></a></li>
+								<li><a class="btn default btn-outline openTab" data-tab-name="`+v.tabName+`" data-type="`+v.type+`" data-open-tab="`+v.openTab+`" data-url="`+v.address+`" href="javascript:void(0);"><i class="icon-share-alt"></i></a></li>
 								<li><a class="btn default btn-outline refreshImage" data-image="`+v.nowPlayingOriginalImage+`" href="javascript:void(0);"><i class="icon-refresh"></i></a></li>
-								<li><a class="btn default btn-outline" href="javascript:void(0);"><i class="icon-graph"></i></a></li>
+								<!--<li><a class="btn default btn-outline" href="javascript:void(0);"><i class="icon-graph"></i></a></li>-->
 							</ul>
 						</div>
 					</div>