فهرست منبع

Merge pull request #1526 from henrywhitaker3/feature/custom-active-stream-names

Add override of active stream user names
causefx 5 سال پیش
والد
کامیت
b6d03aa33a
6فایلهای تغییر یافته به همراه141 افزوده شده و 68 حذف شده
  1. 2 0
      api/config/default.php
  2. 92 15
      api/homepage/plex.php
  3. 9 52
      api/v2/routes/homepage.php
  4. 20 1
      js/custom.js
  5. 0 0
      js/custom.min.js
  6. 18 0
      js/functions.js

+ 2 - 0
api/config/default.php

@@ -221,6 +221,8 @@ return array(
 	'homepageOrderJackett' => '31',
 	'homepageShowStreamNames' => false,
 	'homepageShowStreamNamesAuth' => '1',
+	'homepageUseCustomStreamNames' => false,
+	'homepageCustomStreamNames' => '',
 	'homepageStreamRefresh' => '60000',
 	'homepageRecentRefresh' => '60000',
 	'homepageDownloadRefresh' => '60000',

+ 92 - 15
api/homepage/plex.php

@@ -2,7 +2,7 @@
 
 trait PlexHomepageItem
 {
-	
+
 	public function plexSettingsArray()
 	{
 		return array(
@@ -205,6 +205,39 @@ trait PlexHomepageItem
 								'value' => '3'
 							)
 						)
+					),
+					array(
+						'type' => 'blank',
+						'label' => ''
+					),
+					array(
+						'type' => 'switch',
+						'name' => 'homepageUseCustomStreamNames',
+						'label' => 'Use custom names for users',
+						'value' => $this->config['homepageUseCustomStreamNames']
+					),
+					array(
+						'type' => 'html',
+						'name' => 'grabFromTautulli',
+						'label' => 'Grab from Tautulli. (Note, you must have set the Tautulli API key already)',
+						'override' => 6,
+						'html' => '<button type="button" onclick="getTautulliFriendlyNames()" class="btn btn-sm btn-success btn-rounded waves-effect waves-light b-none">Grab Names</button>',
+					),
+					array(
+						'type' => 'html',
+						'name' => 'homepageCustomStreamNamesAce',
+						'class' => 'jsonTextarea hidden',
+						'label' => 'Custom definitions for user names (JSON Object, with the key being the plex name, and the value what you want to override with)',
+						'override' => 12,
+						'html' => '<div id="homepageCustomStreamNamesAce" style="height: 300px;">' . htmlentities($this->config['homepageCustomStreamNames']) . '</div>',
+					),
+					array(
+						'type' => 'textbox',
+						'name' => 'homepageCustomStreamNames',
+						'class' => 'jsonTextarea hidden',
+						'id' => 'homepageCustomStreamNamesText',
+						'label' => '',
+						'value' => $this->config['homepageCustomStreamNames'],
 					)
 				),
 				'Test Connection' => array(
@@ -224,7 +257,7 @@ trait PlexHomepageItem
 			)
 		);
 	}
-	
+
 	public function testConnectionPlex()
 	{
 		if (!empty($this->config['plexURL']) && !empty($this->config['plexToken'])) {
@@ -249,7 +282,7 @@ trait PlexHomepageItem
 			return 'URL and/or Token not setup';
 		}
 	}
-	
+
 	public function plexHomepagePermissions($key = null)
 	{
 		$permissions = [
@@ -335,7 +368,7 @@ trait PlexHomepageItem
 			return [];
 		}
 	}
-	
+
 	public function homepageOrderplexnowplaying()
 	{
 		if ($this->homepageItemPermissions($this->plexHomepagePermissions('streams'))) {
@@ -351,7 +384,7 @@ trait PlexHomepageItem
 				';
 		}
 	}
-	
+
 	public function homepageOrderplexrecent()
 	{
 		if ($this->homepageItemPermissions($this->plexHomepagePermissions('recent'))) {
@@ -367,7 +400,7 @@ trait PlexHomepageItem
 				';
 		}
 	}
-	
+
 	public function homepageOrderplexplaylist()
 	{
 		if ($this->homepageItemPermissions($this->plexHomepagePermissions('playlists'))) {
@@ -383,7 +416,7 @@ trait PlexHomepageItem
 				';
 		}
 	}
-	
+
 	public function getPlexHomepageStreams()
 	{
 		if (!$this->homepageItemPermissions($this->plexHomepagePermissions('streams'), true)) {
@@ -412,7 +445,7 @@ trait PlexHomepageItem
 			return $api;
 		}
 	}
-	
+
 	public function getPlexHomepageRecent()
 	{
 		if (!$this->homepageItemPermissions($this->plexHomepagePermissions('recent'), true)) {
@@ -454,7 +487,7 @@ trait PlexHomepageItem
 		$this->setAPIResponse('success', null, 200, $api);
 		return $api;
 	}
-	
+
 	public function getPlexHomepagePlaylists()
 	{
 		if (!$this->homepageItemPermissions($this->plexHomepagePermissions('playlists'), true)) {
@@ -494,9 +527,8 @@ trait PlexHomepageItem
 			$this->setAPIResponse('error', 'Plex API error', 500);
 			return false;
 		}
-		
 	}
-	
+
 	public function getPlexHomepageMetadata($array)
 	{
 		if (!$this->homepageItemPermissions($this->plexHomepagePermissions('metadata'), true)) {
@@ -530,7 +562,7 @@ trait PlexHomepageItem
 			return $api;
 		}
 	}
-	
+
 	public function getPlexHomepageSearch($query)
 	{
 		if (!$this->homepageItemPermissions($this->plexHomepagePermissions('search'), true)) {
@@ -564,7 +596,7 @@ trait PlexHomepageItem
 			return $api;
 		}
 	}
-	
+
 	public function resolvePlexItem($item)
 	{
 		// Static Height & Width
@@ -674,7 +706,7 @@ trait PlexHomepageItem
 		$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'] = ($this->config['homepageShowStreamNames'] && $this->qualifyRequest($this->config['homepageShowStreamNamesAuth'])) ? (string)$item->User['title'] : "";
+		$plexItem['user'] = $this->formatPlexUserName($item);
 		$plexItem['userThumb'] = ($this->config['homepageShowStreamNames'] && $this->qualifyRequest($this->config['homepageShowStreamNamesAuth'])) ? (string)$item->User['thumb'] : "";
 		$plexItem['userAddress'] = ($this->config['homepageShowStreamNames'] && $this->qualifyRequest($this->config['homepageShowStreamNamesAuth'])) ? (string)$item->Player['address'] : "x.x.x.x";
 		$plexItem['address'] = $this->config['plexTabURL'] ? $this->config['plexTabURL'] . "/web/index.html#!/server/" . $this->config['plexID'] . "/details?key=/library/metadata/" . $item['ratingKey'] : "https://app.plex.tv/web/app#!/server/" . $this->config['plexID'] . "/details?key=/library/metadata/" . $item['ratingKey'];
@@ -757,4 +789,49 @@ trait PlexHomepageItem
 		}
 		return $plexItem;
 	}
-}
+
+	public function getTautulliFriendlyNames()
+	{
+		if (!$this->qualifyRequest(1)) {
+			return false;
+		}
+
+		$url = $this->qualifyURL($this->config['tautulliURL']);
+		$url .= '/api/v2?apikey=' . $this->config['tautulliApikey'];
+		$url .= '&cmd=get_users';
+
+		$response = Requests::get($url, [], []);
+		$names = [];
+
+		try {
+			$response = json_decode($response->body, true);
+			foreach ($response['response']['data'] as $user) {
+				if ($user['user_id'] != 0) {
+					$names[$user['username']] = $user['friendly_name'];
+				}
+			}
+		} catch (Exception $e) {
+			$this->setAPIResponse('failure', null, 422, [$e->getMessage()]);
+		}
+
+		$this->setAPIResponse('success', null, 200, $names);
+	}
+
+	private function formatPlexUserName($item)
+	{
+		$name = ($this->config['homepageShowStreamNames'] && $this->qualifyRequest($this->config['homepageShowStreamNamesAuth'])) ? (string)$item->User['title'] : "";
+
+		try {
+			if ($this->config['homepageUseCustomStreamNames']) {
+				$customNames = json_decode($this->config['homepageCustomStreamNames'], true);
+				if (array_key_exists($name, $customNames)) {
+					$name = $customNames[$name];
+				}
+			}
+		} catch (Exception $e) {
+			// don't do anythig if it goes wrong, like if the JSON is badly formatted
+		}
+
+		return $name;
+	}
+}

+ 9 - 52
api/v2/routes/homepage.php

@@ -7,7 +7,6 @@ $app->get('/homepage/image', function ($request, $response, $args) {
 	return $response
 		->withHeader('Content-Type', 'application/json;charset=UTF-8')
 		->withStatus($GLOBALS['responseCode']);
-	
 });
 $app->get('/homepage/calendar', function ($request, $response, $args) {
 	$Organizr = ($request->getAttribute('Organizr')) ?? new Organizr();
@@ -16,7 +15,6 @@ $app->get('/homepage/calendar', function ($request, $response, $args) {
 	return $response
 		->withHeader('Content-Type', 'application/json;charset=UTF-8')
 		->withStatus($GLOBALS['responseCode']);
-	
 });
 $app->get('/homepage/plex/streams', function ($request, $response, $args) {
 	$Organizr = ($request->getAttribute('Organizr')) ?? new Organizr();
@@ -25,7 +23,6 @@ $app->get('/homepage/plex/streams', function ($request, $response, $args) {
 	return $response
 		->withHeader('Content-Type', 'application/json;charset=UTF-8')
 		->withStatus($GLOBALS['responseCode']);
-	
 });
 $app->get('/homepage/emby/streams', function ($request, $response, $args) {
 	$Organizr = ($request->getAttribute('Organizr')) ?? new Organizr();
@@ -34,7 +31,6 @@ $app->get('/homepage/emby/streams', function ($request, $response, $args) {
 	return $response
 		->withHeader('Content-Type', 'application/json;charset=UTF-8')
 		->withStatus($GLOBALS['responseCode']);
-	
 });
 $app->get('/homepage/jellyfin/streams', function ($request, $response, $args) {
 	$Organizr = ($request->getAttribute('Organizr')) ?? new Organizr();
@@ -43,7 +39,6 @@ $app->get('/homepage/jellyfin/streams', function ($request, $response, $args) {
 	return $response
 		->withHeader('Content-Type', 'application/json;charset=UTF-8')
 		->withStatus($GLOBALS['responseCode']);
-	
 });
 $app->get('/homepage/plex/recent', function ($request, $response, $args) {
 	$Organizr = ($request->getAttribute('Organizr')) ?? new Organizr();
@@ -52,7 +47,6 @@ $app->get('/homepage/plex/recent', function ($request, $response, $args) {
 	return $response
 		->withHeader('Content-Type', 'application/json;charset=UTF-8')
 		->withStatus($GLOBALS['responseCode']);
-	
 });
 $app->get('/homepage/emby/recent', function ($request, $response, $args) {
 	$Organizr = ($request->getAttribute('Organizr')) ?? new Organizr();
@@ -61,7 +55,6 @@ $app->get('/homepage/emby/recent', function ($request, $response, $args) {
 	return $response
 		->withHeader('Content-Type', 'application/json;charset=UTF-8')
 		->withStatus($GLOBALS['responseCode']);
-	
 });
 $app->get('/homepage/jellyfin/recent', function ($request, $response, $args) {
 	$Organizr = ($request->getAttribute('Organizr')) ?? new Organizr();
@@ -70,7 +63,6 @@ $app->get('/homepage/jellyfin/recent', function ($request, $response, $args) {
 	return $response
 		->withHeader('Content-Type', 'application/json;charset=UTF-8')
 		->withStatus($GLOBALS['responseCode']);
-	
 });
 $app->get('/homepage/plex/playlists', function ($request, $response, $args) {
 	$Organizr = ($request->getAttribute('Organizr')) ?? new Organizr();
@@ -79,7 +71,6 @@ $app->get('/homepage/plex/playlists', function ($request, $response, $args) {
 	return $response
 		->withHeader('Content-Type', 'application/json;charset=UTF-8')
 		->withStatus($GLOBALS['responseCode']);
-	
 });
 $app->post('/homepage/plex/metadata', function ($request, $response, $args) {
 	$Organizr = ($request->getAttribute('Organizr')) ?? new Organizr();
@@ -88,7 +79,6 @@ $app->post('/homepage/plex/metadata', function ($request, $response, $args) {
 	return $response
 		->withHeader('Content-Type', 'application/json;charset=UTF-8')
 		->withStatus($GLOBALS['responseCode']);
-	
 });
 $app->post('/homepage/emby/metadata', function ($request, $response, $args) {
 	$Organizr = ($request->getAttribute('Organizr')) ?? new Organizr();
@@ -97,7 +87,6 @@ $app->post('/homepage/emby/metadata', function ($request, $response, $args) {
 	return $response
 		->withHeader('Content-Type', 'application/json;charset=UTF-8')
 		->withStatus($GLOBALS['responseCode']);
-	
 });
 $app->post('/homepage/jellyfin/metadata', function ($request, $response, $args) {
 	$Organizr = ($request->getAttribute('Organizr')) ?? new Organizr();
@@ -106,7 +95,6 @@ $app->post('/homepage/jellyfin/metadata', function ($request, $response, $args)
 	return $response
 		->withHeader('Content-Type', 'application/json;charset=UTF-8')
 		->withStatus($GLOBALS['responseCode']);
-	
 });
 $app->get('/homepage/plex/search/{query}', function ($request, $response, $args) {
 	$Organizr = ($request->getAttribute('Organizr')) ?? new Organizr();
@@ -115,7 +103,6 @@ $app->get('/homepage/plex/search/{query}', function ($request, $response, $args)
 	return $response
 		->withHeader('Content-Type', 'application/json;charset=UTF-8')
 		->withStatus($GLOBALS['responseCode']);
-	
 });
 $app->get('/homepage/pihole/stats', function ($request, $response, $args) {
 	$Organizr = ($request->getAttribute('Organizr')) ?? new Organizr();
@@ -124,7 +111,6 @@ $app->get('/homepage/pihole/stats', function ($request, $response, $args) {
 	return $response
 		->withHeader('Content-Type', 'application/json;charset=UTF-8')
 		->withStatus($GLOBALS['responseCode']);
-	
 });
 $app->get('/homepage/rtorrent/queue', function ($request, $response, $args) {
 	$Organizr = ($request->getAttribute('Organizr')) ?? new Organizr();
@@ -133,7 +119,6 @@ $app->get('/homepage/rtorrent/queue', function ($request, $response, $args) {
 	return $response
 		->withHeader('Content-Type', 'application/json;charset=UTF-8')
 		->withStatus($GLOBALS['responseCode']);
-	
 });
 $app->get('/homepage/sonarr/queue', function ($request, $response, $args) {
 	$Organizr = ($request->getAttribute('Organizr')) ?? new Organizr();
@@ -142,7 +127,6 @@ $app->get('/homepage/sonarr/queue', function ($request, $response, $args) {
 	return $response
 		->withHeader('Content-Type', 'application/json;charset=UTF-8')
 		->withStatus($GLOBALS['responseCode']);
-	
 });
 $app->get('/homepage/sonarr/calendar', function ($request, $response, $args) {
 	$Organizr = ($request->getAttribute('Organizr')) ?? new Organizr();
@@ -151,7 +135,6 @@ $app->get('/homepage/sonarr/calendar', function ($request, $response, $args) {
 	return $response
 		->withHeader('Content-Type', 'application/json;charset=UTF-8')
 		->withStatus($GLOBALS['responseCode']);
-	
 });
 $app->get('/homepage/radarr/queue', function ($request, $response, $args) {
 	$Organizr = ($request->getAttribute('Organizr')) ?? new Organizr();
@@ -160,7 +143,6 @@ $app->get('/homepage/radarr/queue', function ($request, $response, $args) {
 	return $response
 		->withHeader('Content-Type', 'application/json;charset=UTF-8')
 		->withStatus($GLOBALS['responseCode']);
-	
 });
 $app->get('/homepage/radarr/calendar', function ($request, $response, $args) {
 	$Organizr = ($request->getAttribute('Organizr')) ?? new Organizr();
@@ -169,7 +151,6 @@ $app->get('/homepage/radarr/calendar', function ($request, $response, $args) {
 	return $response
 		->withHeader('Content-Type', 'application/json;charset=UTF-8')
 		->withStatus($GLOBALS['responseCode']);
-	
 });
 $app->get('/homepage/lidarr/calendar', function ($request, $response, $args) {
 	$Organizr = ($request->getAttribute('Organizr')) ?? new Organizr();
@@ -178,7 +159,6 @@ $app->get('/homepage/lidarr/calendar', function ($request, $response, $args) {
 	return $response
 		->withHeader('Content-Type', 'application/json;charset=UTF-8')
 		->withStatus($GLOBALS['responseCode']);
-	
 });
 $app->get('/homepage/couchpotato/calendar', function ($request, $response, $args) {
 	$Organizr = ($request->getAttribute('Organizr')) ?? new Organizr();
@@ -187,7 +167,6 @@ $app->get('/homepage/couchpotato/calendar', function ($request, $response, $args
 	return $response
 		->withHeader('Content-Type', 'application/json;charset=UTF-8')
 		->withStatus($GLOBALS['responseCode']);
-	
 });
 $app->get('/homepage/sickrage/calendar', function ($request, $response, $args) {
 	$Organizr = ($request->getAttribute('Organizr')) ?? new Organizr();
@@ -196,7 +175,6 @@ $app->get('/homepage/sickrage/calendar', function ($request, $response, $args) {
 	return $response
 		->withHeader('Content-Type', 'application/json;charset=UTF-8')
 		->withStatus($GLOBALS['responseCode']);
-	
 });
 $app->get('/homepage/ical/calendar', function ($request, $response, $args) {
 	$Organizr = ($request->getAttribute('Organizr')) ?? new Organizr();
@@ -205,7 +183,6 @@ $app->get('/homepage/ical/calendar', function ($request, $response, $args) {
 	return $response
 		->withHeader('Content-Type', 'application/json;charset=UTF-8')
 		->withStatus($GLOBALS['responseCode']);
-	
 });
 $app->get('/homepage/deluge/queue', function ($request, $response, $args) {
 	$Organizr = ($request->getAttribute('Organizr')) ?? new Organizr();
@@ -214,7 +191,6 @@ $app->get('/homepage/deluge/queue', function ($request, $response, $args) {
 	return $response
 		->withHeader('Content-Type', 'application/json;charset=UTF-8')
 		->withStatus($GLOBALS['responseCode']);
-	
 });
 $app->get('/homepage/transmission/queue', function ($request, $response, $args) {
 	$Organizr = ($request->getAttribute('Organizr')) ?? new Organizr();
@@ -223,7 +199,6 @@ $app->get('/homepage/transmission/queue', function ($request, $response, $args)
 	return $response
 		->withHeader('Content-Type', 'application/json;charset=UTF-8')
 		->withStatus($GLOBALS['responseCode']);
-	
 });
 $app->get('/homepage/qbittorrent/queue', function ($request, $response, $args) {
 	$Organizr = ($request->getAttribute('Organizr')) ?? new Organizr();
@@ -232,7 +207,6 @@ $app->get('/homepage/qbittorrent/queue', function ($request, $response, $args) {
 	return $response
 		->withHeader('Content-Type', 'application/json;charset=UTF-8')
 		->withStatus($GLOBALS['responseCode']);
-	
 });
 $app->get('/homepage/jdownloader/queue', function ($request, $response, $args) {
 	$Organizr = ($request->getAttribute('Organizr')) ?? new Organizr();
@@ -241,7 +215,6 @@ $app->get('/homepage/jdownloader/queue', function ($request, $response, $args) {
 	return $response
 		->withHeader('Content-Type', 'application/json;charset=UTF-8')
 		->withStatus($GLOBALS['responseCode']);
-	
 });
 $app->get('/homepage/nzbget/queue', function ($request, $response, $args) {
 	$Organizr = ($request->getAttribute('Organizr')) ?? new Organizr();
@@ -250,7 +223,6 @@ $app->get('/homepage/nzbget/queue', function ($request, $response, $args) {
 	return $response
 		->withHeader('Content-Type', 'application/json;charset=UTF-8')
 		->withStatus($GLOBALS['responseCode']);
-	
 });
 $app->get('/homepage/sabnzbd/queue', function ($request, $response, $args) {
 	$Organizr = ($request->getAttribute('Organizr')) ?? new Organizr();
@@ -259,7 +231,6 @@ $app->get('/homepage/sabnzbd/queue', function ($request, $response, $args) {
 	return $response
 		->withHeader('Content-Type', 'application/json;charset=UTF-8')
 		->withStatus($GLOBALS['responseCode']);
-	
 });
 $app->post('/homepage/sabnzbd/queue/resume', function ($request, $response, $args) {
 	$Organizr = ($request->getAttribute('Organizr')) ?? new Organizr();
@@ -270,7 +241,6 @@ $app->post('/homepage/sabnzbd/queue/resume', function ($request, $response, $arg
 	return $response
 		->withHeader('Content-Type', 'application/json;charset=UTF-8')
 		->withStatus($GLOBALS['responseCode']);
-	
 });
 $app->post('/homepage/sabnzbd/queue/pause', function ($request, $response, $args) {
 	$Organizr = ($request->getAttribute('Organizr')) ?? new Organizr();
@@ -281,7 +251,6 @@ $app->post('/homepage/sabnzbd/queue/pause', function ($request, $response, $args
 	return $response
 		->withHeader('Content-Type', 'application/json;charset=UTF-8')
 		->withStatus($GLOBALS['responseCode']);
-	
 });
 $app->get('/homepage/unifi/data', function ($request, $response, $args) {
 	$Organizr = ($request->getAttribute('Organizr')) ?? new Organizr();
@@ -290,7 +259,6 @@ $app->get('/homepage/unifi/data', function ($request, $response, $args) {
 	return $response
 		->withHeader('Content-Type', 'application/json;charset=UTF-8')
 		->withStatus($GLOBALS['responseCode']);
-	
 });
 $app->get('/homepage/tautulli/data', function ($request, $response, $args) {
 	$Organizr = ($request->getAttribute('Organizr')) ?? new Organizr();
@@ -299,7 +267,14 @@ $app->get('/homepage/tautulli/data', function ($request, $response, $args) {
 	return $response
 		->withHeader('Content-Type', 'application/json;charset=UTF-8')
 		->withStatus($GLOBALS['responseCode']);
-	
+});
+$app->get('/homepage/tautulli/names', function ($request, $response, $args) {
+	$Organizr = ($request->getAttribute('Organizr')) ?? new Organizr();
+	$Organizr->getTautulliFriendlyNames();
+	$response->getBody()->write(jsonE($GLOBALS['api']));
+	return $response
+		->withHeader('Content-Type', 'application/json;charset=UTF-8')
+		->withStatus($GLOBALS['responseCode']);
 });
 $app->get('/homepage/netdata/data', function ($request, $response, $args) {
 	$Organizr = ($request->getAttribute('Organizr')) ?? new Organizr();
@@ -308,7 +283,6 @@ $app->get('/homepage/netdata/data', function ($request, $response, $args) {
 	return $response
 		->withHeader('Content-Type', 'application/json;charset=UTF-8')
 		->withStatus($GLOBALS['responseCode']);
-	
 });
 $app->get('/homepage/monitorr/data', function ($request, $response, $args) {
 	$Organizr = ($request->getAttribute('Organizr')) ?? new Organizr();
@@ -317,7 +291,6 @@ $app->get('/homepage/monitorr/data', function ($request, $response, $args) {
 	return $response
 		->withHeader('Content-Type', 'application/json;charset=UTF-8')
 		->withStatus($GLOBALS['responseCode']);
-	
 });
 $app->get('/homepage/speedtest/data', function ($request, $response, $args) {
 	$Organizr = ($request->getAttribute('Organizr')) ?? new Organizr();
@@ -326,7 +299,6 @@ $app->get('/homepage/speedtest/data', function ($request, $response, $args) {
 	return $response
 		->withHeader('Content-Type', 'application/json;charset=UTF-8')
 		->withStatus($GLOBALS['responseCode']);
-	
 });
 $app->get('/homepage/octoprint/data', function ($request, $response, $args) {
 	$Organizr = ($request->getAttribute('Organizr')) ?? new Organizr();
@@ -335,7 +307,6 @@ $app->get('/homepage/octoprint/data', function ($request, $response, $args) {
 	return $response
 		->withHeader('Content-Type', 'application/json;charset=UTF-8')
 		->withStatus($GLOBALS['responseCode']);
-	
 });
 $app->get('/homepage/weather/data', function ($request, $response, $args) {
 	$Organizr = ($request->getAttribute('Organizr')) ?? new Organizr();
@@ -344,7 +315,6 @@ $app->get('/homepage/weather/data', function ($request, $response, $args) {
 	return $response
 		->withHeader('Content-Type', 'application/json;charset=UTF-8')
 		->withStatus($GLOBALS['responseCode']);
-	
 });
 $app->post('/homepage/weather/coordinates', function ($request, $response, $args) {
 	$Organizr = ($request->getAttribute('Organizr')) ?? new Organizr();
@@ -353,7 +323,6 @@ $app->post('/homepage/weather/coordinates', function ($request, $response, $args
 	return $response
 		->withHeader('Content-Type', 'application/json;charset=UTF-8')
 		->withStatus($GLOBALS['responseCode']);
-	
 });
 $app->get('/homepage/healthchecks', function ($request, $response, $args) {
 	$Organizr = ($request->getAttribute('Organizr')) ?? new Organizr();
@@ -362,7 +331,6 @@ $app->get('/homepage/healthchecks', function ($request, $response, $args) {
 	return $response
 		->withHeader('Content-Type', 'application/json;charset=UTF-8')
 		->withStatus($GLOBALS['responseCode']);
-	
 });
 $app->get('/homepage/healthchecks/{tags}', function ($request, $response, $args) {
 	$Organizr = ($request->getAttribute('Organizr')) ?? new Organizr();
@@ -371,7 +339,6 @@ $app->get('/homepage/healthchecks/{tags}', function ($request, $response, $args)
 	return $response
 		->withHeader('Content-Type', 'application/json;charset=UTF-8')
 		->withStatus($GLOBALS['responseCode']);
-	
 });
 $app->get('/homepage/ombi/requests[/{type}[/{limit}[/{offset}]]]', function ($request, $response, $args) {
 	$Organizr = ($request->getAttribute('Organizr')) ?? new Organizr();
@@ -383,7 +350,6 @@ $app->get('/homepage/ombi/requests[/{type}[/{limit}[/{offset}]]]', function ($re
 	return $response
 		->withHeader('Content-Type', 'application/json;charset=UTF-8')
 		->withStatus($GLOBALS['responseCode']);
-	
 });
 $app->post('/homepage/ombi/requests/{type}/{id}', function ($request, $response, $args) {
 	$Organizr = ($request->getAttribute('Organizr')) ?? new Organizr();
@@ -392,7 +358,6 @@ $app->post('/homepage/ombi/requests/{type}/{id}', function ($request, $response,
 	return $response
 		->withHeader('Content-Type', 'application/json;charset=UTF-8')
 		->withStatus($GLOBALS['responseCode']);
-	
 });
 $app->post('/homepage/ombi/requests/{type}/{id}/available', function ($request, $response, $args) {
 	$Organizr = ($request->getAttribute('Organizr')) ?? new Organizr();
@@ -401,7 +366,6 @@ $app->post('/homepage/ombi/requests/{type}/{id}/available', function ($request,
 	return $response
 		->withHeader('Content-Type', 'application/json;charset=UTF-8')
 		->withStatus($GLOBALS['responseCode']);
-	
 });
 $app->post('/homepage/ombi/requests/{type}/{id}/unavailable', function ($request, $response, $args) {
 	$Organizr = ($request->getAttribute('Organizr')) ?? new Organizr();
@@ -410,7 +374,6 @@ $app->post('/homepage/ombi/requests/{type}/{id}/unavailable', function ($request
 	return $response
 		->withHeader('Content-Type', 'application/json;charset=UTF-8')
 		->withStatus($GLOBALS['responseCode']);
-	
 });
 $app->post('/homepage/ombi/requests/{type}/{id}/approve', function ($request, $response, $args) {
 	$Organizr = ($request->getAttribute('Organizr')) ?? new Organizr();
@@ -419,7 +382,6 @@ $app->post('/homepage/ombi/requests/{type}/{id}/approve', function ($request, $r
 	return $response
 		->withHeader('Content-Type', 'application/json;charset=UTF-8')
 		->withStatus($GLOBALS['responseCode']);
-	
 });
 $app->put('/homepage/ombi/requests/{type}/{id}/deny', function ($request, $response, $args) {
 	$Organizr = ($request->getAttribute('Organizr')) ?? new Organizr();
@@ -428,7 +390,6 @@ $app->put('/homepage/ombi/requests/{type}/{id}/deny', function ($request, $respo
 	return $response
 		->withHeader('Content-Type', 'application/json;charset=UTF-8')
 		->withStatus($GLOBALS['responseCode']);
-	
 });
 $app->delete('/homepage/ombi/requests/{type}/{id}', function ($request, $response, $args) {
 	$Organizr = ($request->getAttribute('Organizr')) ?? new Organizr();
@@ -437,7 +398,6 @@ $app->delete('/homepage/ombi/requests/{type}/{id}', function ($request, $respons
 	return $response
 		->withHeader('Content-Type', 'application/json;charset=UTF-8')
 		->withStatus($GLOBALS['responseCode']);
-	
 });
 $app->get('/homepage/youtube/{query}', function ($request, $response, $args) {
 	$Organizr = ($request->getAttribute('Organizr')) ?? new Organizr();
@@ -446,7 +406,6 @@ $app->get('/homepage/youtube/{query}', function ($request, $response, $args) {
 	return $response
 		->withHeader('Content-Type', 'application/json;charset=UTF-8')
 		->withStatus($GLOBALS['responseCode']);
-	
 });
 $app->post('/homepage/scrape', function ($request, $response, $args) {
 	$Organizr = ($request->getAttribute('Organizr')) ?? new Organizr();
@@ -455,7 +414,6 @@ $app->post('/homepage/scrape', function ($request, $response, $args) {
 	return $response
 		->withHeader('Content-Type', 'application/json;charset=UTF-8')
 		->withStatus($GLOBALS['responseCode']);
-	
 });
 $app->get('/homepage/jackett/{query}', function ($request, $response, $args) {
 	$Organizr = ($request->getAttribute('Organizr')) ?? new Organizr();
@@ -464,5 +422,4 @@ $app->get('/homepage/jackett/{query}', function ($request, $response, $args) {
 	return $response
 		->withHeader('Content-Type', 'application/json;charset=UTF-8')
 		->withStatus($GLOBALS['responseCode']);
-	
-});
+});

+ 20 - 1
js/custom.js

@@ -1861,4 +1861,23 @@ $(document).on('click', '.imageManagerItem', function() {
 $(document).on('click', '.close-editHomepageItemDiv',function () {
 	$('body').removeAttr('style');
 	$('html').removeAttr('style');
-})
+})
+// Control init of custom plex JSON editor
+$(document).on('click', 'li a[aria-controls="Misc Options"]', function() {
+    var resizeEditor = function(jsonEditor) {
+        const aceEditor = jsonEditor;
+        const newHeight = aceEditor.getSession().getScreenLength() * (aceEditor.renderer.lineHeight + aceEditor.renderer.scrollBar.getWidth());
+        aceEditor.container.style.height = `${newHeight}px`;
+        aceEditor.resize();
+    }
+
+    jsonEditor = ace.edit("homepageCustomStreamNamesAce");
+    var JsonMode = ace.require("ace/mode/javascript").Mode;
+    jsonEditor.session.setMode(new JsonMode());
+    jsonEditor.setTheme("ace/theme/idle_fingers");
+    jsonEditor.setShowPrintMargin(false);
+    jsonEditor.session.on('change', function(delta) {
+        $('#homepageCustomStreamNamesText').val(jsonEditor.getValue());
+        $('#customize-appearance-form-save').removeClass('hidden');
+    });
+}); 

تفاوت فایلی نمایش داده نمی شود زیرا این فایل بسیار بزرگ است
+ 0 - 0
js/custom.min.js


+ 18 - 0
js/functions.js

@@ -8320,6 +8320,24 @@ function tryUpdateNetdata(array){
     });
     return existing;
 }
+function getTautulliFriendlyNames()
+{
+    organizrAPI2('GET','api/v2/homepage/tautulli/names').success(function(data) {
+        try {
+            let response = data.response;
+            if(response.data !== null){
+                var string = JSON.stringify(response.data, null, 4);
+                jsonEditor = ace.edit("homepageCustomStreamNamesAce");
+                jsonEditor.setValue(string);
+                $('#homepage-Plex-form-save').removeClass('hidden');
+            }
+        }catch(e) {
+	        organizrCatchError(e,data);
+        }
+    }).fail(function(xhr) {
+	    OrganizrApiError(xhr);
+    });
+}
 function homepageJackett(){
 	if(activeInfo.settings.homepage.options.alternateHomepageHeaders){
 		var header = `

برخی فایل ها در این مقایسه diff نمایش داده نمی شوند زیرا تعداد فایل ها بسیار زیاد است