chore: check library before updating watch status
This commit is contained in:
@@ -177,6 +177,11 @@ namespace Jellyfin.Plugin.TubeArchivistMetadata
|
|||||||
{
|
{
|
||||||
BaseItem? season = LibraryManager.GetItemById(eventArgs.Item.ParentId);
|
BaseItem? season = LibraryManager.GetItemById(eventArgs.Item.ParentId);
|
||||||
BaseItem? channel = LibraryManager.GetItemById(season!.ParentId);
|
BaseItem? channel = LibraryManager.GetItemById(season!.ParentId);
|
||||||
|
var topParent = eventArgs.Item.GetTopParent();
|
||||||
|
|
||||||
|
if ((topParent?.Name ?? string.Empty) == (Instance?.Configuration.CollectionTitle ?? string.Empty) && topParent?.Name is not null)
|
||||||
|
{
|
||||||
|
BaseItem? channel = LibraryManager.GetItemById(eventArgs.Item.ParentId);
|
||||||
BaseItem? collection = LibraryManager.GetItemById(channel!.ParentId);
|
BaseItem? collection = LibraryManager.GetItemById(channel!.ParentId);
|
||||||
if (collection?.Name.ToLower(CultureInfo.CurrentCulture) == Instance?.Configuration.CollectionTitle.ToLower(CultureInfo.CurrentCulture) && eventArgs.PlaybackPositionTicks != null)
|
if (collection?.Name.ToLower(CultureInfo.CurrentCulture) == Instance?.Configuration.CollectionTitle.ToLower(CultureInfo.CurrentCulture) && eventArgs.PlaybackPositionTicks != null)
|
||||||
{
|
{
|
||||||
@@ -189,12 +194,21 @@ namespace Jellyfin.Plugin.TubeArchivistMetadata
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Logger.LogDebug("Parent name ({ParentName}) is not collection title({CollectionTitle})", topParent?.Name ?? string.Empty, Instance?.Configuration.CollectionTitle);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private async void OnWatchedStatusChange(object? sender, UserDataSaveEventArgs eventArgs)
|
private async void OnWatchedStatusChange(object? sender, UserDataSaveEventArgs eventArgs)
|
||||||
{
|
{
|
||||||
var user = _userManager.GetUserById(eventArgs.UserId);
|
var user = _userManager.GetUserById(eventArgs.UserId);
|
||||||
if (Configuration.JFTASync && user != null && Configuration.GetJFUsernamesToArray().Contains(user!.Username))
|
if (Configuration.JFTASync && user != null && Configuration.GetJFUsernamesToArray().Contains(user!.Username))
|
||||||
|
{
|
||||||
|
var topParent = eventArgs.Item.GetTopParent();
|
||||||
|
|
||||||
|
if ((topParent?.Name ?? string.Empty) == (Instance?.Configuration.CollectionTitle ?? string.Empty) && topParent?.Name is not null)
|
||||||
{
|
{
|
||||||
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);
|
||||||
@@ -244,6 +258,11 @@ namespace Jellyfin.Plugin.TubeArchivistMetadata
|
|||||||
Logger.LogCritical("An exception occurred while calling POST /watched for item {ItemName} ({VideoYTId}) with watched status {IsPlayed}: {ExceptionMessage}", eventArgs.Item.Name, itemYTId, isPlayed, ex.Message);
|
Logger.LogCritical("An exception occurred while calling POST /watched for item {ItemName} ({VideoYTId}) with watched status {IsPlayed}: {ExceptionMessage}", eventArgs.Item.Name, itemYTId, isPlayed, ex.Message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Logger.LogDebug("Parent name ({ParentName}) is not collection title({CollectionTitle})", topParent?.Name ?? string.Empty, Instance?.Configuration.CollectionTitle);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user