chore: remove duplicated efforts
This commit is contained in:
@@ -172,17 +172,14 @@ namespace Jellyfin.Plugin.TubeArchivistMetadata
|
|||||||
}
|
}
|
||||||
|
|
||||||
private async void OnPlaybackProgress(object? sender, PlaybackProgressEventArgs eventArgs)
|
private async void OnPlaybackProgress(object? sender, PlaybackProgressEventArgs eventArgs)
|
||||||
{
|
|
||||||
if (Instance!.Configuration.JFTASync && eventArgs.Users.Any(u => Instance!.Configuration.JFUsernameFrom.Equals(u.Username, StringComparison.Ordinal)))
|
|
||||||
{
|
{
|
||||||
var topParent = eventArgs.Item.GetTopParent();
|
var topParent = eventArgs.Item.GetTopParent();
|
||||||
|
if (
|
||||||
if ((topParent?.Name ?? string.Empty) == (Instance?.Configuration.CollectionTitle ?? string.Empty) && topParent?.Name is not null)
|
Instance!.Configuration.JFTASync &&
|
||||||
{
|
eventArgs.Users.Any(u => Instance!.Configuration.JFUsernameFrom.Equals(u.Username, StringComparison.Ordinal)) &&
|
||||||
BaseItem? season = LibraryManager.GetItemById(eventArgs.Item.ParentId);
|
eventArgs.PlaybackPositionTicks.HasValue &&
|
||||||
BaseItem? channel = LibraryManager.GetItemById(season!.ParentId);
|
string.Equals(topParent?.Name, Instance?.Configuration.CollectionTitle, StringComparison.OrdinalIgnoreCase)
|
||||||
BaseItem? collection = LibraryManager.GetItemById(channel!.ParentId);
|
)
|
||||||
if (collection?.Name.ToLower(CultureInfo.CurrentCulture) == Instance?.Configuration.CollectionTitle.ToLower(CultureInfo.CurrentCulture) && eventArgs.PlaybackPositionTicks != null)
|
|
||||||
{
|
{
|
||||||
long progress = (long)eventArgs.PlaybackPositionTicks / TimeSpan.TicksPerSecond;
|
long progress = (long)eventArgs.PlaybackPositionTicks / TimeSpan.TicksPerSecond;
|
||||||
var videoId = Utils.GetVideoNameFromPath(eventArgs.Item.Path);
|
var videoId = Utils.GetVideoNameFromPath(eventArgs.Item.Path);
|
||||||
@@ -193,21 +190,17 @@ 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);
|
|
||||||
if (Configuration.JFTASync && user != null && Configuration.GetJFUsernamesToArray().Contains(user!.Username))
|
|
||||||
{
|
{
|
||||||
var topParent = eventArgs.Item.GetTopParent();
|
var topParent = eventArgs.Item.GetTopParent();
|
||||||
|
var user = _userManager.GetUserById(eventArgs.UserId);
|
||||||
if ((topParent?.Name ?? string.Empty) == (Instance?.Configuration.CollectionTitle ?? string.Empty) && topParent?.Name is not null)
|
if (
|
||||||
|
Configuration.JFTASync &&
|
||||||
|
user != null &&
|
||||||
|
Configuration.GetJFUsernamesToArray().Contains(user!.Username) &&
|
||||||
|
string.Equals(topParent?.Name, Instance?.Configuration.CollectionTitle, StringComparison.OrdinalIgnoreCase)
|
||||||
|
)
|
||||||
{
|
{
|
||||||
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);
|
||||||
@@ -257,11 +250,6 @@ 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