Jelajahi Sumber

feat: Add User Watch Statistics homepage plugin

- Add comprehensive userWatchStats plugin for Plex/Emby/Jellyfin
- Support for top users, most watched content, and recent activity
- Configurable display options and auto-refresh intervals
- Proper integration with Organizr's HTTP client and patterns
- Connection testing for all supported media servers
- Clean up test and simple plugin versions
- Update organizr.class.php to use only primary plugin trait
- Add API endpoint for userWatchStats data retrieval
mgomon 8 bulan lalu
induk
melakukan
6d4cd9bb73

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

@@ -67,8 +67,6 @@ class Organizr
 	use uTorrentHomepageItem;
 	use UptimeKumaHomepageItem;
 	use HomepageUserWatchStats;
-	use HomepageUserWatchStatsSimple;
-	use UserWatchStatsTestHomepageItem;
 
 	// ===================================
 	// Organizr Version

+ 87 - 130
api/homepage/userWatchStats.php

@@ -422,25 +422,18 @@ trait HomepageUserWatchStats
      */
     private function getTautulliMostWatched($url, $token, $days)
     {
-        $endpoint = rtrim($url, '/') . '/api/v2';
-        $params = [
-            'apikey' => $token,
-            'cmd' => 'get_home_stats',
-            'time_range' => $days,
-            'stats_type' => 'plays',
-            'stats_count' => 10
-        ];
+        $apiURL = rtrim($url, '/') . '/api/v2?apikey=' . $token . '&cmd=get_home_stats&time_range=' . $days . '&stats_type=plays&stats_count=10';
         
-        $response = $this->guzzle->request('GET', $endpoint, [
-            'query' => $params,
-            'timeout' => 15,
-            'connect_timeout' => 15,
-            'http_errors' => false
-        ]);
-
-        if ($response->getStatusCode() === 200) {
-            $data = json_decode($response->getBody(), true);
-            return $data['response']['data'] ?? [];
+        try {
+            $options = $this->requestOptions($url, null, $this->config['plexDisableCertCheck'] ?? false, $this->config['plexUseCustomCertificate'] ?? false);
+            $response = Requests::get($apiURL, [], $options);
+            
+            if ($response->success) {
+                $data = json_decode($response->body, true);
+                return $data['response']['data'] ?? [];
+            }
+        } catch (Requests_Exception $e) {
+            $this->writeLog('error', 'Tautulli Most Watched Error: ' . $e->getMessage(), 'SYSTEM');
         }
 
         return [];
@@ -451,23 +444,18 @@ trait HomepageUserWatchStats
      */
     private function getTautulliUserStats($url, $token, $days)
     {
-        $endpoint = rtrim($url, '/') . '/api/v2';
-        $params = [
-            'apikey' => $token,
-            'cmd' => 'get_user_watch_time_stats',
-            'time_range' => $days
-        ];
+        $apiURL = rtrim($url, '/') . '/api/v2?apikey=' . $token . '&cmd=get_user_watch_time_stats&time_range=' . $days;
         
-        $response = $this->guzzle->request('GET', $endpoint, [
-            'query' => $params,
-            'timeout' => 15,
-            'connect_timeout' => 15,
-            'http_errors' => false
-        ]);
-
-        if ($response->getStatusCode() === 200) {
-            $data = json_decode($response->getBody(), true);
-            return $data['response']['data'] ?? [];
+        try {
+            $options = $this->requestOptions($url, null, $this->config['plexDisableCertCheck'] ?? false, $this->config['plexUseCustomCertificate'] ?? false);
+            $response = Requests::get($apiURL, [], $options);
+            
+            if ($response->success) {
+                $data = json_decode($response->body, true);
+                return $data['response']['data'] ?? [];
+            }
+        } catch (Requests_Exception $e) {
+            $this->writeLog('error', 'Tautulli User Stats Error: ' . $e->getMessage(), 'SYSTEM');
         }
 
         return [];
@@ -478,30 +466,25 @@ trait HomepageUserWatchStats
      */
     private function getTautulliTopUsers($url, $token, $days)
     {
-        $endpoint = rtrim($url, '/') . '/api/v2';
-        $params = [
-            'apikey' => $token,
-            'cmd' => 'get_users',
-            'length' => 25
-        ];
+        $apiURL = rtrim($url, '/') . '/api/v2?apikey=' . $token . '&cmd=get_users&length=25';
         
-        $response = $this->guzzle->request('GET', $endpoint, [
-            'query' => $params,
-            'timeout' => 15,
-            'connect_timeout' => 15,
-            'http_errors' => false
-        ]);
-
-        if ($response->getStatusCode() === 200) {
-            $data = json_decode($response->getBody(), true);
-            $users = $data['response']['data']['data'] ?? [];
-            
-            // Sort by play count
-            usort($users, function($a, $b) {
-                return ($b['play_count'] ?? 0) - ($a['play_count'] ?? 0);
-            });
+        try {
+            $options = $this->requestOptions($url, null, $this->config['plexDisableCertCheck'] ?? false, $this->config['plexUseCustomCertificate'] ?? false);
+            $response = Requests::get($apiURL, [], $options);
             
-            return array_slice($users, 0, 10);
+            if ($response->success) {
+                $data = json_decode($response->body, true);
+                $users = $data['response']['data']['data'] ?? [];
+                
+                // Sort by play count
+                usort($users, function($a, $b) {
+                    return ($b['play_count'] ?? 0) - ($a['play_count'] ?? 0);
+                });
+                
+                return array_slice($users, 0, 10);
+            }
+        } catch (Requests_Exception $e) {
+            $this->writeLog('error', 'Tautulli Top Users Error: ' . $e->getMessage(), 'SYSTEM');
         }
 
         return [];
@@ -512,23 +495,18 @@ trait HomepageUserWatchStats
      */
     private function getTautulliRecentActivity($url, $token)
     {
-        $endpoint = rtrim($url, '/') . '/api/v2';
-        $params = [
-            'apikey' => $token,
-            'cmd' => 'get_recently_added',
-            'count' => 10
-        ];
+        $apiURL = rtrim($url, '/') . '/api/v2?apikey=' . $token . '&cmd=get_recently_added&count=10';
         
-        $response = $this->guzzle->request('GET', $endpoint, [
-            'query' => $params,
-            'timeout' => 15,
-            'connect_timeout' => 15,
-            'http_errors' => false
-        ]);
-
-        if ($response->getStatusCode() === 200) {
-            $data = json_decode($response->getBody(), true);
-            return $data['response']['data']['recently_added'] ?? [];
+        try {
+            $options = $this->requestOptions($url, null, $this->config['plexDisableCertCheck'] ?? false, $this->config['plexUseCustomCertificate'] ?? false);
+            $response = Requests::get($apiURL, [], $options);
+            
+            if ($response->success) {
+                $data = json_decode($response->body, true);
+                return $data['response']['data']['recently_added'] ?? [];
+            }
+        } catch (Requests_Exception $e) {
+            $this->writeLog('error', 'Tautulli Recent Activity Error: ' . $e->getMessage(), 'SYSTEM');
         }
 
         return [];
@@ -539,32 +517,28 @@ trait HomepageUserWatchStats
      */
     private function getTautulliLeastWatched($url, $token, $days)
     {
-        $endpoint = rtrim($url, '/') . '/api/v2';
-        $params = [
-            'apikey' => $token,
-            'cmd' => 'get_libraries',
-        ];
+        $apiURL = rtrim($url, '/') . '/api/v2?apikey=' . $token . '&cmd=get_libraries';
         
-        $response = $this->guzzle->request('GET', $endpoint, [
-            'query' => $params,
-            'timeout' => 15,
-            'connect_timeout' => 15,
-            'http_errors' => false
-        ]);
-
-        if ($response->getStatusCode() === 200) {
-            $data = json_decode($response->getBody(), true);
-            $libraries = $data['response']['data'] ?? [];
+        try {
+            $options = $this->requestOptions($url, null, $this->config['plexDisableCertCheck'] ?? false, $this->config['plexUseCustomCertificate'] ?? false);
+            $response = Requests::get($apiURL, [], $options);
             
-            $leastWatched = [];
-            foreach ($libraries as $library) {
-                $libraryStats = $this->getTautulliLibraryStats($url, $token, $library['section_id'], $days);
-                if (!empty($libraryStats)) {
-                    $leastWatched = array_merge($leastWatched, array_slice($libraryStats, -10));
+            if ($response->success) {
+                $data = json_decode($response->body, true);
+                $libraries = $data['response']['data'] ?? [];
+                
+                $leastWatched = [];
+                foreach ($libraries as $library) {
+                    $libraryStats = $this->getTautulliLibraryStats($url, $token, $library['section_id'], $days);
+                    if (!empty($libraryStats)) {
+                        $leastWatched = array_merge($leastWatched, array_slice($libraryStats, -10));
+                    }
                 }
+                
+                return $leastWatched;
             }
-            
-            return $leastWatched;
+        } catch (Requests_Exception $e) {
+            $this->writeLog('error', 'Tautulli Least Watched Error: ' . $e->getMessage(), 'SYSTEM');
         }
 
         return [];
@@ -575,26 +549,18 @@ trait HomepageUserWatchStats
      */
     private function getTautulliLibraryStats($url, $token, $sectionId, $days)
     {
-        $endpoint = rtrim($url, '/') . '/api/v2';
-        $params = [
-            'apikey' => $token,
-            'cmd' => 'get_library_media_info',
-            'section_id' => $sectionId,
-            'length' => 50,
-            'order_column' => 'play_count',
-            'order_dir' => 'asc'
-        ];
+        $apiURL = rtrim($url, '/') . '/api/v2?apikey=' . $token . '&cmd=get_library_media_info&section_id=' . $sectionId . '&length=50&order_column=play_count&order_dir=asc';
         
-        $response = $this->guzzle->request('GET', $endpoint, [
-            'query' => $params,
-            'timeout' => 15,
-            'connect_timeout' => 15,
-            'http_errors' => false
-        ]);
-
-        if ($response->getStatusCode() === 200) {
-            $data = json_decode($response->getBody(), true);
-            return $data['response']['data']['data'] ?? [];
+        try {
+            $options = $this->requestOptions($url, null, $this->config['plexDisableCertCheck'] ?? false, $this->config['plexUseCustomCertificate'] ?? false);
+            $response = Requests::get($apiURL, [], $options);
+            
+            if ($response->success) {
+                $data = json_decode($response->body, true);
+                return $data['response']['data']['data'] ?? [];
+            }
+        } catch (Requests_Exception $e) {
+            $this->writeLog('error', 'Tautulli Library Stats Error: ' . $e->getMessage(), 'SYSTEM');
         }
 
         return [];
@@ -692,27 +658,18 @@ trait HomepageUserWatchStats
             return '/plugins/images/organizr/user-bg.png';
         }
 
-        $endpoint = rtrim($tautulliUrl, '/') . "/api/v2";
-        $params = [
-            'apikey' => $tautulliToken,
-            'cmd' => 'get_user_thumb',
-            'user_id' => $userId
-        ];
+        $apiURL = rtrim($tautulliUrl, '/') . '/api/v2?apikey=' . $tautulliToken . '&cmd=get_user_thumb&user_id=' . $userId;
 
         try {
-            $response = $this->guzzle->request('GET', $endpoint, [
-                'query' => $params,
-                'timeout' => 10,
-                'connect_timeout' => 10,
-                'http_errors' => false
-            ]);
-
-            if ($response->getStatusCode() === 200) {
-                $data = json_decode($response->getBody(), true);
+            $options = $this->requestOptions($tautulliUrl, null, $this->config['plexDisableCertCheck'] ?? false, $this->config['plexUseCustomCertificate'] ?? false);
+            $response = Requests::get($apiURL, [], $options);
+
+            if ($response->success) {
+                $data = json_decode($response->body, true);
                 return $data['response']['data']['thumb'] ?? '/plugins/images/organizr/user-bg.png';
             }
-        } catch (Exception $e) {
-            // Return default avatar on error
+        } catch (Requests_Exception $e) {
+            $this->writeLog('error', 'Tautulli User Avatar Error: ' . $e->getMessage(), 'SYSTEM');
         }
 
         return '/plugins/images/organizr/user-bg.png';

+ 0 - 141
api/homepage/userWatchStatsTest.php

@@ -1,141 +0,0 @@
-<?php
-
-trait UserWatchStatsTestHomepageItem
-{
-    public function userWatchStatsTestSettingsArray($infoOnly = false)
-    {
-        $homepageInformation = [
-            'name' => 'User Watch Statistics Test',
-            'enabled' => true,
-            'image' => 'plugins/images/homepage/userWatchStats.png',
-            'category' => 'Media Server',
-            'settingsArray' => __FUNCTION__
-        ];
-        if ($infoOnly) {
-            return $homepageInformation;
-        }
-        $homepageSettings = [
-            'debug' => true,
-            'settings' => [
-                'Enable' => [
-                    $this->settingsOption('enable', 'homepageUserWatchStatsTestEnabled'),
-                    $this->settingsOption('auth', 'homepageUserWatchStatsTestAuth'),
-                ],
-                'Connection' => [
-                    $this->settingsOption('url', 'plexURL', ['label' => 'Tautulli URL']),
-                    $this->settingsOption('token', 'plexToken', ['label' => 'Tautulli API Key']),
-                    $this->settingsOption('disable-cert-check', 'plexDisableCertCheck'),
-                    $this->settingsOption('use-custom-certificate', 'plexUseCustomCertificate'),
-                ],
-                'Test Connection' => [
-                    $this->settingsOption('blank', null, ['label' => 'Please Save before Testing']),
-                    $this->settingsOption('test', 'userWatchStatsTest'),
-                ]
-            ]
-        ];
-        return array_merge($homepageInformation, $homepageSettings);
-    }
-
-    public function testConnectionUserWatchStatsTest()
-    {
-        if (!$this->homepageItemPermissions($this->userWatchStatsTestHomepagePermissions('test'), true)) {
-            return false;
-        }
-        $url = $this->qualifyURL($this->config['plexURL']);
-        $url = $url . "/api/v2?apikey=" . $this->config['plexToken'] . '&cmd=get_server_info';
-        $options = $this->requestOptions($url, null, $this->config['plexDisableCertCheck'], $this->config['plexUseCustomCertificate']);
-        try {
-            $response = Requests::get($url, [], $options);
-            if ($response->success) {
-                $data = json_decode($response->body, true);
-                if (isset($data['response']['result']) && $data['response']['result'] === 'success') {
-                    $this->setAPIResponse('success', 'Successfully connected to Tautulli', 200);
-                    return true;
-                } else {
-                    $this->setAPIResponse('error', 'Invalid response from Tautulli server', 500);
-                }
-            } else {
-                $this->setAPIResponse('error', 'Tautulli Connection Error', 500);
-                return false;
-            }
-        } catch (Requests_Exception $e) {
-            $this->setResponse(500, $e->getMessage());
-            return false;
-        }
-    }
-
-    public function userWatchStatsTestHomepagePermissions($key = null)
-    {
-        $permissions = [
-            'test' => [
-                'enabled' => [
-                    'homepageUserWatchStatsTestEnabled',
-                ],
-                'auth' => [
-                    'homepageUserWatchStatsTestAuth',
-                ],
-                'not_empty' => [
-                    'plexURL',
-                    'plexToken'
-                ]
-            ],
-            'main' => [
-                'enabled' => [
-                    'homepageUserWatchStatsTestEnabled'
-                ],
-                'auth' => [
-                    'homepageUserWatchStatsTestAuth'
-                ],
-                'not_empty' => [
-                    'plexURL',
-                    'plexToken'
-                ]
-            ]
-        ];
-        return $this->homepageCheckKeyPermissions($key, $permissions);
-    }
-
-    public function homepageOrderUserWatchStatsTest()
-    {
-        if ($this->homepageItemPermissions($this->userWatchStatsTestHomepagePermissions('main'))) {
-            return '
-            <div id="' . __FUNCTION__ . '">
-                <div class="white-box">
-                    <div class="white-box-header">
-                        <i class="fa fa-bar-chart"></i> User Watch Statistics Test
-                    </div>
-                    <div class="white-box-content">
-                        <div class="row">
-                            <div class="col-lg-12 text-center">
-                                <h4>Test Plugin Working!</h4>
-                                <p>This is a test version of the User Watch Statistics plugin.</p>
-                            </div>
-                        </div>
-                    </div>
-                </div>
-            </div>
-            ';
-        }
-    }
-
-    public function getUserWatchStatsTest($options = null)
-    {
-        if (!$this->homepageItemPermissions($this->userWatchStatsTestHomepagePermissions('main'), true)) {
-            return false;
-        }
-
-        try {
-            $stats = [
-                'message' => 'Test plugin is working',
-                'status' => 'success'
-            ];
-            
-            $this->setAPIResponse('success', 'Test plugin loaded successfully', 200, $stats);
-            return true;
-            
-        } catch (Exception $e) {
-            $this->setAPIResponse('error', 'Test plugin error: ' . $e->getMessage(), 500);
-            return false;
-        }
-    }
-}

+ 0 - 229
api/homepage/userWatchStats_simple.php

@@ -1,229 +0,0 @@
-<?php
-
-trait HomepageUserWatchStatsSimple
-{
-    public function userWatchStatsSimpleSettingsArray($infoOnly = false)
-    {
-        $homepageInformation = [
-            'name' => 'User Watch Statistics Simple',
-            'enabled' => true,
-            'image' => 'plugins/images/homepage/userWatchStats.png',
-            'category' => 'Media Server',
-            'settingsArray' => __FUNCTION__
-        ];
-        if ($infoOnly) {
-            return $homepageInformation;
-        }
-        $homepageSettings = [
-            'debug' => true,
-            'settings' => [
-                'Enable' => [
-                    $this->settingsOption('enable', 'homepageUserWatchStatsSimpleEnabled'),
-                    $this->settingsOption('auth', 'homepageUserWatchStatsSimpleAuth'),
-                ],
-                'Connection' => [
-                    $this->settingsOption('url', 'plexURL', ['label' => 'Tautulli URL']),
-                    $this->settingsOption('token', 'plexToken', ['label' => 'Tautulli API Key']),
-                    $this->settingsOption('disable-cert-check', 'plexDisableCertCheck'),
-                    $this->settingsOption('use-custom-certificate', 'plexUseCustomCertificate'),
-                ],
-                'Test Connection' => [
-                    $this->settingsOption('blank', null, ['label' => 'Please Save before Testing']),
-                    $this->settingsOption('test', 'userWatchStatsSimple'),
-                ]
-            ]
-        ];
-        return array_merge($homepageInformation, $homepageSettings);
-    }
-
-    public function testConnectionUserWatchStatsSimple()
-    {
-        if (!$this->homepageItemPermissions($this->userWatchStatsSimpleHomepagePermissions('test'), true)) {
-            return false;
-        }
-        $url = $this->qualifyURL($this->config['plexURL']);
-        $url = $url . "/api/v2?apikey=" . $this->config['plexToken'] . '&cmd=get_server_info';
-        $options = $this->requestOptions($url, null, $this->config['plexDisableCertCheck'], $this->config['plexUseCustomCertificate']);
-        try {
-            $response = Requests::get($url, [], $options);
-            if ($response->success) {
-                $data = json_decode($response->body, true);
-                if (isset($data['response']['result']) && $data['response']['result'] === 'success') {
-                    $this->setAPIResponse('success', 'Successfully connected to Tautulli', 200);
-                    return true;
-                } else {
-                    $this->setAPIResponse('error', 'Invalid response from Tautulli server', 500);
-                }
-            } else {
-                $this->setAPIResponse('error', 'Tautulli Connection Error', 500);
-                return false;
-            }
-        } catch (Requests_Exception $e) {
-            $this->setResponse(500, $e->getMessage());
-            return false;
-        }
-    }
-
-    public function userWatchStatsSimpleHomepagePermissions($key = null)
-    {
-        $permissions = [
-            'test' => [
-                'enabled' => [
-                    'homepageUserWatchStatsSimpleEnabled',
-                ],
-                'auth' => [
-                    'homepageUserWatchStatsSimpleAuth',
-                ],
-                'not_empty' => [
-                    'plexURL',
-                    'plexToken'
-                ]
-            ],
-            'main' => [
-                'enabled' => [
-                    'homepageUserWatchStatsSimpleEnabled'
-                ],
-                'auth' => [
-                    'homepageUserWatchStatsSimpleAuth'
-                ],
-                'not_empty' => [
-                    'plexURL',
-                    'plexToken'
-                ]
-            ]
-        ];
-        return $this->homepageCheckKeyPermissions($key, $permissions);
-    }
-
-    public function homepageOrderUserWatchStatsSimple()
-    {
-        if ($this->homepageItemPermissions($this->userWatchStatsSimpleHomepagePermissions('main'))) {
-            $refreshInterval = ($this->config['homepageUserWatchStatsSimpleRefresh'] ?? 5) * 60000; // Convert minutes to milliseconds
-
-            return '
-            <div id="' . __FUNCTION__ . '">
-                <div class="white-box">
-                    <div class="white-box-header">
-                        <i class="fa fa-bar-chart"></i> User Watch Statistics (Simple)
-                        <span class="pull-right">
-                            <small id="watchstats-simple-last-update" class="text-muted"></small>
-                            <button class="btn btn-xs btn-primary" onclick="refreshUserWatchStatsSimple()" title="Refresh Data">
-                                <i class="fa fa-refresh" id="watchstats-simple-refresh-icon"></i>
-                            </button>
-                        </span>
-                    </div>
-                    <div class="white-box-content">
-                        <div class="row" id="watchstats-simple-content">
-                            <div class="col-lg-12 text-center">
-                                <i class="fa fa-spinner fa-spin"></i> Loading statistics...
-                            </div>
-                        </div>
-                    </div>
-                </div>
-            </div>
-
-            <script>
-            var watchStatsSimpleRefreshTimer;
-            var watchStatsSimpleLastRefresh = 0;
-
-            function refreshUserWatchStatsSimple() {
-                var refreshIcon = $("#watchstats-simple-refresh-icon");
-                refreshIcon.addClass("fa-spin");
-
-                // Show loading state
-                $("#watchstats-simple-content").html(\'<div class="col-lg-12 text-center"><i class="fa fa-spinner fa-spin"></i> Loading statistics...</div>\');
-
-                // Load watch statistics
-                getUserWatchStatsSimpleData()
-                .always(function() {
-                    refreshIcon.removeClass("fa-spin");
-                    watchStatsSimpleLastRefresh = Date.now();
-                    updateWatchStatsSimpleLastRefreshTime();
-                });
-            }
-
-            function updateWatchStatsSimpleLastRefreshTime() {
-                if (watchStatsSimpleLastRefresh > 0) {
-                    var ago = Math.floor((Date.now() - watchStatsSimpleLastRefresh) / 1000);
-                    var timeText = ago < 60 ? ago + "s ago" : Math.floor(ago / 60) + "m ago";
-                    $("#watchstats-simple-last-update").text("Updated " + timeText);
-                }
-            }
-
-            function getUserWatchStatsSimpleData() {
-                return organizrAPI2("GET", "api/v2/homepage/userWatchStatsSimple")
-                .done(function(data) {
-                    if (data && data.response && data.response.result === "success" && data.response.data) {
-                        var stats = data.response.data;
-                        var html = "";
-                        
-                        // Display basic statistics
-                        html += \'<div class="col-lg-12"><h4>Basic Statistics (Simplified View)</h4></div>\';
-                        
-                        // Show some basic info
-                        html += \'<div class="col-lg-12"><div class="alert alert-info">This is a simplified version of User Watch Statistics for testing purposes.</div></div>\';
-                        
-                        $("#watchstats-simple-content").html(html);
-                    } else {
-                        $("#watchstats-simple-content").html(\'<div class="col-lg-12 text-center text-danger">Failed to load statistics</div>\');
-                    }
-                })
-                .fail(function(xhr, status, error) {
-                    $("#watchstats-simple-content").html(\'<div class="col-lg-12 text-center text-danger">Error loading statistics</div>\');
-                });
-            }
-
-            // Auto-refresh setup
-            var refreshInterval = ' . $refreshInterval . ';
-            if (refreshInterval > 0) {
-                watchStatsSimpleRefreshTimer = setInterval(function() {
-                    refreshUserWatchStatsSimple();
-                }, refreshInterval);
-            }
-
-            // Update time display every 30 seconds
-            setInterval(updateWatchStatsSimpleLastRefreshTime, 30000);
-
-            // Initial load
-            $(document).ready(function() {
-                refreshUserWatchStatsSimple();
-            });
-
-            // Cleanup timer when page unloads
-            $(window).on("beforeunload", function() {
-                if (watchStatsSimpleRefreshTimer) {
-                    clearInterval(watchStatsSimpleRefreshTimer);
-                }
-            });
-            </script>
-            ';
-        }
-    }
-
-    /**
-     * Main function to get simple watch statistics
-     */
-    public function getUserWatchStatsSimple($options = null)
-    {
-        if (!$this->homepageItemPermissions($this->userWatchStatsSimpleHomepagePermissions('main'), true)) {
-            return false;
-        }
-
-        try {
-            // For the simple version, just return basic test data
-            $stats = [
-                'period' => '30 days',
-                'message' => 'Simple version for testing',
-                'status' => 'active'
-            ];
-            
-            $this->setAPIResponse('success', 'Simple watch statistics retrieved successfully', 200, $stats);
-            return true;
-            
-        } catch (Exception $e) {
-            $this->writeLog('error', 'User Watch Stats Simple Error: ' . $e->getMessage(), 'SYSTEM');
-            $this->setAPIResponse('error', 'Failed to retrieve simple watch statistics: ' . $e->getMessage(), 500);
-            return false;
-        }
-    }
-}

+ 0 - 16
api/v2/routes/homepage.php

@@ -629,19 +629,3 @@ $app->get('/homepage/userWatchStats', function ($request, $response, $args) {
 		->withHeader('Content-Type', 'application/json;charset=UTF-8')
 		->withStatus($GLOBALS['responseCode']);
 });
-$app->get('/homepage/userWatchStatsSimple', function ($request, $response, $args) {
-	$Organizr = ($request->getAttribute('Organizr')) ?? new Organizr();
-	$Organizr->getUserWatchStatsSimple();
-	$response->getBody()->write(jsonE($GLOBALS['api']));
-	return $response
-		->withHeader('Content-Type', 'application/json;charset=UTF-8')
-		->withStatus($GLOBALS['responseCode']);
-});
-$app->get('/homepage/userWatchStatsTest', function ($request, $response, $args) {
-	$Organizr = ($request->getAttribute('Organizr')) ?? new Organizr();
-	$Organizr->getUserWatchStatsTest();
-	$response->getBody()->write(jsonE($GLOBALS['api']));
-	return $response
-		->withHeader('Content-Type', 'application/json;charset=UTF-8')
-		->withStatus($GLOBALS['responseCode']);
-});