|
|
@@ -1049,8 +1049,8 @@ trait JellyStatHomepageItem
|
|
|
$actualItemId = $result['NowPlayingItemId'] ?? null;
|
|
|
} elseif ($contentType === 'show') {
|
|
|
// Debug: Log all available IDs for TV shows to understand data structure
|
|
|
- error_log("JellyStat TV Show Debug - Series: {$result['SeriesName']}");
|
|
|
- error_log("Available IDs: SeriesId=" . ($result['SeriesId'] ?? 'null') .
|
|
|
+ $this->writeLog('debug', "JellyStat TV Show Debug - Series: {$result['SeriesName']}");
|
|
|
+ $this->writeLog('debug', "Available IDs: SeriesId=" . ($result['SeriesId'] ?? 'null') .
|
|
|
", ShowId=" . ($result['ShowId'] ?? 'null') .
|
|
|
", ParentId=" . ($result['ParentId'] ?? 'null') .
|
|
|
", NowPlayingItemId=" . ($result['NowPlayingItemId'] ?? 'null'));
|
|
|
@@ -1062,23 +1062,23 @@ trait JellyStatHomepageItem
|
|
|
if (!empty($result['SeriesId'])) {
|
|
|
// SeriesId is the most reliable for series posters
|
|
|
$actualItemId = $result['SeriesId'];
|
|
|
- error_log("Using SeriesId: {$actualItemId}");
|
|
|
+ $this->writeLog('debug', "Using SeriesId: {$actualItemId}");
|
|
|
} elseif (!empty($result['ShowId'])) {
|
|
|
// ShowId is also series-specific
|
|
|
$actualItemId = $result['ShowId'];
|
|
|
- error_log("Using ShowId: {$actualItemId}");
|
|
|
+ $this->writeLog('debug', "Using ShowId: {$actualItemId}");
|
|
|
} elseif (!empty($result['NowPlayingItemId'])) {
|
|
|
// Try NowPlayingItemId - it might be the series ID if we're looking at series-level data
|
|
|
$actualItemId = $result['NowPlayingItemId'];
|
|
|
- error_log("Using NowPlayingItemId: {$actualItemId}");
|
|
|
+ $this->writeLog('debug', "Using NowPlayingItemId: {$actualItemId}");
|
|
|
} elseif (!empty($result['ParentId'])) {
|
|
|
// Last resort: ParentId (might be series, season, or library)
|
|
|
$actualItemId = $result['ParentId'];
|
|
|
- error_log("Using ParentId: {$actualItemId}");
|
|
|
+ $this->writeLog('debug', "Using ParentId: {$actualItemId}");
|
|
|
}
|
|
|
|
|
|
if (!$actualItemId) {
|
|
|
- error_log("No suitable ID found for TV show: {$result['SeriesName']}");
|
|
|
+ $this->writeLog('debug', "No suitable ID found for TV show: {$result['SeriesName']}");
|
|
|
}
|
|
|
} elseif ($contentType === 'music') {
|
|
|
// For music, use NowPlayingItemId (album/track)
|
|
|
@@ -1102,6 +1102,11 @@ trait JellyStatHomepageItem
|
|
|
$itemStats[$key]['play_count']++;
|
|
|
$itemStats[$key]['total_duration'] += $result['PlaybackDuration'] ?? 0;
|
|
|
|
|
|
+ // Debug: Log each play count increment
|
|
|
+ if ($contentType === 'show') {
|
|
|
+ $this->writeLog('debug', "Play count increment for {$title}: now {$itemStats[$key]['play_count']} (Episode: {$result['EpisodeName']}, User: {$result['UserName']}, Date: {$result['ActivityDateInserted']})");
|
|
|
+ }
|
|
|
+
|
|
|
// Update last played time
|
|
|
$currentTime = $result['ActivityDateInserted'] ?? null;
|
|
|
if ($currentTime && (!$itemStats[$key]['last_played'] || $currentTime > $itemStats[$key]['last_played'])) {
|