Browse Source

Fix JellyStat metadata popup integration

- Add 'jellystat' source handling to metadata popup JavaScript switch statement
- Update getJellyStatMetadata method to return safer data structure with proper string values
- Add required fields (nowPlayingImageURL, address, tabName, openTab) for metadata popup compatibility
- Ensure all metadata fields are properly cast to strings to prevent JavaScript 'replace' errors
- Cast duration and rating to '0' strings instead of empty to avoid undefined access errors
mgomon 8 months ago
parent
commit
6441ea6781
2 changed files with 15 additions and 8 deletions
  1. 12 8
      api/homepage/jellystat.php
  2. 3 0
      js/custom.js

+ 12 - 8
api/homepage/jellystat.php

@@ -207,22 +207,26 @@ trait JellyStatHomepageItem
         // For now, return basic metadata from the key (which is the item ID)
         // In the future this could be enhanced to fetch full metadata from JellyStat API
         $metadata = [
-            'guid' => $key,
-            'summary' => 'This item data is from JellyStat analytics.',
-            'rating' => '',
-            'duration' => '',
+            'guid' => (string)$key,
+            'summary' => 'This item data is from JellyStat analytics. Click the JellyStat button to view detailed statistics and analytics for this content.',
+            'rating' => '0',
+            'duration' => '0',
             'originallyAvailableAt' => '',
             'year' => '',
             'tagline' => 'JellyStat Analytics',
-            'genres' => [],
-            'actors' => []
+            'genres' => [], // Empty array will be handled as string in frontend
+            'actors' => []  // Empty array will be handled as string in frontend
         ];
         
         // Create a mock item structure similar to Emby's format
         $item = [
-            'uid' => $key,
+            'uid' => (string)$key,
             'title' => 'JellyStat Item',
-            'type' => 'jellystat', 
+            'type' => 'jellystat',
+            'nowPlayingImageURL' => 'plugins/images/homepage/no-np.png', // Safe fallback image
+            'address' => $this->qualifyURL($this->config['jellyStatURL'] ?? ''),
+            'tabName' => 'jellystat',
+            'openTab' => 'true',
             'metadata' => $metadata
         ];
         

+ 3 - 0
js/custom.js

@@ -1412,6 +1412,9 @@ $(document).on("click", ".metadata-get", function(e) {
         case 'jellyfin':
             var action = 'getEmbyMetadata';
             break;
+        case 'jellystat':
+            var action = 'getJellyStatMetadata';
+            break;
         default:
 
     }