فهرست منبع

fix youtube api and emby logo

mgomon 8 ماه پیش
والد
کامیت
84773a75d2
3فایلهای تغییر یافته به همراه20 افزوده شده و 5 حذف شده
  1. 4 2
      api/classes/organizr.class.php
  2. 9 1
      js/custom.js
  3. 7 2
      js/functions.js

+ 4 - 2
api/classes/organizr.class.php

@@ -7297,7 +7297,7 @@ class Organizr
 		return $this->processQueries($response);
 	}
 
-	public function youtubeSearch($query)
+public function youtubeSearch($query)
 	{
 		if (!$query) {
 			$this->setAPIResponse('error', 'No query supplied', 422);
@@ -7313,7 +7313,9 @@ class Organizr
 		$key = $keys[$randomKeyIndex];
 		$apikey = ($this->config['youtubeAPI'] !== '') ? $this->config['youtubeAPI'] : $key;
 		$results = false;
-		$url = "https://www.googleapis.com/youtube/v3/search?part=snippet&q=$query+official+trailer&part=snippet&maxResults=1&type=video&videoDuration=short&key=$apikey";
+		// Ensure query is URL-encoded to avoid API errors
+		$safeQuery = urlencode($query . ' official trailer');
+		$url = "https://www.googleapis.com/youtube/v3/search?part=snippet&q={$safeQuery}&maxResults=1&type=video&videoDuration=short&key={$apikey}";
 		$response = Requests::get($url);
 		if ($response->success) {
 			$results = json_decode($response->body, true);

+ 9 - 1
js/custom.js

@@ -1421,8 +1421,16 @@ $(document).on("click", ".metadata-get", function(e) {
     ajaxloader(".content-wrap","in");
     organizrAPI2('POST','api/v2/homepage/'+source+'/metadata',{key:key}).success(function(data) {
         let response = data.response;
+        // Determine effective source for icon/button (e.g., emby/jellyfin) when coming from jellystat
+        let effectiveSource = source;
+        try {
+            if (source === 'jellystat' && response && response.data && response.data.content && response.data.content[0]) {
+                const c = response.data.content[0];
+                if (c.tabName) { effectiveSource = String(c.tabName).toLowerCase(); }
+            }
+        } catch (e) { /* no-op */ }
         $('.'+uid+'-metadata-info').html('');
-        $('.'+uid+'-metadata-info').html(buildMetadata(response.data, source));
+        $('.'+uid+'-metadata-info').html(buildMetadata(response.data, effectiveSource));
         $('.'+uid).trigger('click');
         $(".metadata-actors").owlCarousel({
             autoplay: true,

+ 7 - 2
js/functions.js

@@ -10655,7 +10655,8 @@ function youtubeCheck(title,link){
 			inlineLoad();
 			var id = response.data.items["0"].id.videoId;
 			var div = `
-		<div id="player-`+link+`" data-plyr-provider="youtube" data-plyr-embed-id="`+id+`"></div>
+		<div id="player-`+link+`" data-plyr-provider="youtube" data-plyr-embed-id="`+id+`"
+		></div>
 		<div class="clearfix"></div>
 		`;
 			$('.youtube-div').html(div);
@@ -10665,9 +10666,13 @@ function youtubeCheck(title,link){
 
 	}).fail(function(xhr) {
 		OrganizrApiError(xhr, 'YouTube API Error');
+        // Fallback: open YouTube search in a new tab/window
+        var q = '';
+        try { q = decodeURIComponent(title); } catch(e1) { try { q = unescape(title); } catch(e2) { q = title; } }
+        var url = 'https://www.youtube.com/results?search_query=' + encodeURIComponent(q + ' trailer');
+        window.open(url, '_blank');
 	});
 }
-//request search
 function requestSearch(title,page=1) {
 	return $.ajax({
 		url: "https://api.themoviedb.org/3/search/multi?api_key=83cf4ee97bb728eeaf9d4a54e64356a1&language="+activeInfo.language+"&query="+title+"&page="+page+"&include_adult=false",