fix: debuging

This commit is contained in:
2026-03-04 18:21:13 +01:00
parent 7fadc75c84
commit 96d67a8655

View File

@@ -85,6 +85,7 @@ public class SmartNotifyBackgroundService : IHostedService, IDisposable
var existingItems = _libraryManager.GetItemList(query);
var seeded = 0;
var alreadyKnown = 0;
foreach (var item in existingItems)
{
@@ -93,11 +94,16 @@ public class SmartNotifyBackgroundService : IHostedService, IDisposable
_historyService.RecordItem(item);
seeded++;
}
else
{
alreadyKnown++;
}
}
_logger.LogInformation(
"Seeded {Count} existing library items into SmartNotify DB (total in library: {Total})",
"[DEBUG Seed] Seeded {Seeded} new items, {AlreadyKnown} already known, {Total} total in library",
seeded,
alreadyKnown,
existingItems.Count);
}
catch (Exception ex)
@@ -140,6 +146,60 @@ public class SmartNotifyBackgroundService : IHostedService, IDisposable
return;
}
// Debug: log all available metadata on the item at ItemAdded time
if (item is Episode debugEp)
{
_logger.LogInformation(
"[DEBUG ItemAdded] Episode: Name={Name}, Id={Id}, Path={Path}, " +
"SeriesName={SeriesName}, SeriesId={SeriesId}, " +
"Season={Season}, Episode={Episode}, " +
"ProviderIds={ProviderIds}, " +
"DateCreated={DateCreated}, PremiereDate={PremiereDate}",
debugEp.Name,
debugEp.Id,
debugEp.Path,
debugEp.SeriesName,
debugEp.SeriesId,
debugEp.ParentIndexNumber,
debugEp.IndexNumber,
debugEp.ProviderIds != null ? System.Text.Json.JsonSerializer.Serialize(debugEp.ProviderIds) : "null",
debugEp.DateCreated,
debugEp.PremiereDate);
// Also try to access the Series object directly
try
{
var debugSeries = debugEp.Series;
if (debugSeries != null)
{
_logger.LogInformation(
"[DEBUG ItemAdded] Series object found: Name={Name}, Id={Id}, ProviderIds={ProviderIds}",
debugSeries.Name,
debugSeries.Id,
debugSeries.ProviderIds != null ? System.Text.Json.JsonSerializer.Serialize(debugSeries.ProviderIds) : "null");
}
else
{
_logger.LogInformation("[DEBUG ItemAdded] Series object is NULL for episode {Name}", debugEp.Name);
}
}
catch (Exception ex)
{
_logger.LogWarning(ex, "[DEBUG ItemAdded] Failed to access Series object for {Name}", debugEp.Name);
}
}
else if (item is Movie debugMovie)
{
_logger.LogInformation(
"[DEBUG ItemAdded] Movie: Name={Name}, Id={Id}, Path={Path}, " +
"ProviderIds={ProviderIds}, Year={Year}",
debugMovie.Name,
debugMovie.Id,
debugMovie.Path,
debugMovie.ProviderIds != null ? System.Text.Json.JsonSerializer.Serialize(debugMovie.ProviderIds) : "null",
debugMovie.ProductionYear);
}
_logger.LogDebug("Item added: {Name} (Type: {Type}, ID: {Id})", item.Name, item.GetType().Name, item.Id);
var config = Plugin.Instance?.Configuration;
@@ -280,6 +340,16 @@ public class SmartNotifyBackgroundService : IHostedService, IDisposable
notification.ImagePath = seriesImage;
}
}
_logger.LogInformation(
"[DEBUG CreateNotification] Result: SeriesName={SeriesName}, SeriesId={SeriesId}, " +
"S{Season}E{Episode}, ProviderIdsJson={ProviderIds}, ImagePath={ImagePath}",
notification.SeriesName,
notification.SeriesId,
notification.SeasonNumber,
notification.EpisodeNumber,
notification.ProviderIdsJson,
notification.ImagePath);
}
else if (item is Movie movie)
{
@@ -313,9 +383,45 @@ public class SmartNotifyBackgroundService : IHostedService, IDisposable
var item = _libraryManager.GetItemById(itemId);
if (item is not Episode episode)
{
_logger.LogInformation(
"[DEBUG Refresh] Item {Id} is {Type} (not Episode), skipping",
itemId,
item?.GetType().Name ?? "NULL");
return;
}
// Debug: log what Jellyfin returns for this episode at refresh time
_logger.LogInformation(
"[DEBUG Refresh] Episode from library: Name={Name}, SeriesName={SeriesName}, SeriesId={SeriesId}, " +
"Season={Season}, Episode={Episode}, ProviderIds={ProviderIds}",
episode.Name,
episode.SeriesName,
episode.SeriesId,
episode.ParentIndexNumber,
episode.IndexNumber,
episode.ProviderIds != null ? System.Text.Json.JsonSerializer.Serialize(episode.ProviderIds) : "null");
try
{
var debugSeries = episode.Series;
if (debugSeries != null)
{
_logger.LogInformation(
"[DEBUG Refresh] Series object: Name={Name}, Id={Id}, ProviderIds={ProviderIds}",
debugSeries.Name,
debugSeries.Id,
debugSeries.ProviderIds != null ? System.Text.Json.JsonSerializer.Serialize(debugSeries.ProviderIds) : "null");
}
else
{
_logger.LogInformation("[DEBUG Refresh] Series object is STILL NULL for {Name}", episode.Name);
}
}
catch (Exception ex)
{
_logger.LogWarning(ex, "[DEBUG Refresh] Failed to access Series for {Name}", episode.Name);
}
var changed = false;
if (string.IsNullOrEmpty(notification.SeriesName) || notification.SeriesName == "Unknown Series")