Merge pull request #26 from wolffshots/workaround-series-crash

Workaround for JF crashing when scanning Series
This commit is contained in:
DarkFighterLuke
2024-11-04 22:23:45 +01:00
committed by GitHub
@@ -178,18 +178,26 @@ namespace Jellyfin.Plugin.TubeArchivistMetadata
var isPlayed = eventArgs.Item.IsPlayed(user); var isPlayed = eventArgs.Item.IsPlayed(user);
Logger.LogDebug("User {UserId} changed watched status to {Status} for the item {ItemName}", eventArgs.UserId, isPlayed, eventArgs.Item.Name); Logger.LogDebug("User {UserId} changed watched status to {Status} for the item {ItemName}", eventArgs.UserId, isPlayed, eventArgs.Item.Name);
string itemYTId; string itemYTId;
try
{
if (eventArgs.Item is Series) if (eventArgs.Item is Series)
{ {
itemYTId = Utils.GetChannelNameFromPath(eventArgs.Item.Path); itemYTId = Utils.GetChannelNameFromPath(eventArgs.Item.Path);
} }
else if (eventArgs.Item is Episode) else if (eventArgs.Item is Episode)
{ {
itemYTId = Utils.GetVideoNameFromPath(eventArgs.Item.Path); itemYTId = Utils.GetVideoNameFromPath(eventArgs.Item.Path); // Potentially problematic line for Series
} }
else else
{ {
return; return;
} }
}
catch (Exception ex)
{
Logger.LogError(ex, "Error while processing item path: {ItemPath}", eventArgs.Item.Path ?? "null");
return; // Exit the method if there's an error
}
var statusCode = await TubeArchivistApi.GetInstance().SetWatchedStatus(itemYTId, isPlayed).ConfigureAwait(true); var statusCode = await TubeArchivistApi.GetInstance().SetWatchedStatus(itemYTId, isPlayed).ConfigureAwait(true);
if (statusCode != System.Net.HttpStatusCode.OK) if (statusCode != System.Net.HttpStatusCode.OK)