chore: ran dotnet format on Plugin.cs
This commit is contained in:
@@ -179,20 +179,20 @@ namespace Jellyfin.Plugin.TubeArchivistMetadata
|
|||||||
|
|
||||||
if ((topParent?.Name ?? string.Empty) == (Instance?.Configuration.CollectionTitle ?? string.Empty) && topParent?.Name is not null)
|
if ((topParent?.Name ?? string.Empty) == (Instance?.Configuration.CollectionTitle ?? string.Empty) && topParent?.Name is not null)
|
||||||
{
|
{
|
||||||
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);
|
||||||
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)
|
||||||
{
|
|
||||||
long progress = (long)eventArgs.PlaybackPositionTicks / TimeSpan.TicksPerSecond;
|
|
||||||
var videoId = Utils.GetVideoNameFromPath(eventArgs.Item.Path);
|
|
||||||
var statusCode = await TubeArchivistApi.GetInstance().SetProgress(videoId, progress).ConfigureAwait(true);
|
|
||||||
if (statusCode != System.Net.HttpStatusCode.OK)
|
|
||||||
{
|
{
|
||||||
Logger.LogCritical("{Message}", $"POST /video/{videoId}/progress returned {statusCode} for video {eventArgs.Item.Name} with progress {progress} seconds");
|
long progress = (long)eventArgs.PlaybackPositionTicks / TimeSpan.TicksPerSecond;
|
||||||
|
var videoId = Utils.GetVideoNameFromPath(eventArgs.Item.Path);
|
||||||
|
var statusCode = await TubeArchivistApi.GetInstance().SetProgress(videoId, progress).ConfigureAwait(true);
|
||||||
|
if (statusCode != System.Net.HttpStatusCode.OK)
|
||||||
|
{
|
||||||
|
Logger.LogCritical("{Message}", $"POST /video/{videoId}/progress returned {statusCode} for video {eventArgs.Item.Name} with progress {progress} seconds");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Logger.LogDebug("Parent name ({ParentName}) is not collection title({CollectionTitle})", topParent?.Name ?? string.Empty, Instance?.Configuration.CollectionTitle);
|
Logger.LogDebug("Parent name ({ParentName}) is not collection title({CollectionTitle})", topParent?.Name ?? string.Empty, Instance?.Configuration.CollectionTitle);
|
||||||
@@ -209,53 +209,53 @@ namespace Jellyfin.Plugin.TubeArchivistMetadata
|
|||||||
|
|
||||||
if ((topParent?.Name ?? string.Empty) == (Instance?.Configuration.CollectionTitle ?? string.Empty) && topParent?.Name is not null)
|
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);
|
||||||
string itemYTId;
|
string itemYTId;
|
||||||
try
|
try
|
||||||
{
|
|
||||||
if (eventArgs.Item is Series)
|
|
||||||
{
|
{
|
||||||
itemYTId = Utils.GetChannelNameFromPath(eventArgs.Item.Path);
|
if (eventArgs.Item is Series)
|
||||||
}
|
|
||||||
else if (eventArgs.Item is Episode)
|
|
||||||
{
|
|
||||||
itemYTId = Utils.GetVideoNameFromPath(eventArgs.Item.Path);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
Logger.LogError(ex, "Error while processing item path: {ItemPath}", eventArgs.Item.Path ?? "null");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
var statusCode = await TubeArchivistApi.GetInstance().SetWatchedStatus(itemYTId, isPlayed).ConfigureAwait(true);
|
|
||||||
if (statusCode != System.Net.HttpStatusCode.OK)
|
|
||||||
{
|
|
||||||
Logger.LogCritical("POST /watched returned {StatusCode} for item {ItemName} ({VideoYTId}) with watched status {IsPlayed}", statusCode, eventArgs.Item.Name, itemYTId, isPlayed);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (eventArgs.Item is Episode)
|
|
||||||
{
|
|
||||||
var progress = _userDataManager.GetUserData(user, eventArgs.Item).PlaybackPositionTicks / TimeSpan.TicksPerSecond;
|
|
||||||
var videoId = Utils.GetVideoNameFromPath(eventArgs.Item.Path);
|
|
||||||
statusCode = await TubeArchivistApi.GetInstance().SetProgress(videoId, progress).ConfigureAwait(true);
|
|
||||||
if (statusCode != System.Net.HttpStatusCode.OK)
|
|
||||||
{
|
{
|
||||||
Logger.LogCritical("{Message}", $"POST /video/{videoId}/progress returned {statusCode} for video {eventArgs.Item.Name} with progress {progress} seconds");
|
itemYTId = Utils.GetChannelNameFromPath(eventArgs.Item.Path);
|
||||||
|
}
|
||||||
|
else if (eventArgs.Item is Episode)
|
||||||
|
{
|
||||||
|
itemYTId = Utils.GetVideoNameFromPath(eventArgs.Item.Path);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
catch (Exception ex)
|
||||||
catch (Exception ex)
|
{
|
||||||
{
|
Logger.LogError(ex, "Error while processing item path: {ItemPath}", eventArgs.Item.Path ?? "null");
|
||||||
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);
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var statusCode = await TubeArchivistApi.GetInstance().SetWatchedStatus(itemYTId, isPlayed).ConfigureAwait(true);
|
||||||
|
if (statusCode != System.Net.HttpStatusCode.OK)
|
||||||
|
{
|
||||||
|
Logger.LogCritical("POST /watched returned {StatusCode} for item {ItemName} ({VideoYTId}) with watched status {IsPlayed}", statusCode, eventArgs.Item.Name, itemYTId, isPlayed);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (eventArgs.Item is Episode)
|
||||||
|
{
|
||||||
|
var progress = _userDataManager.GetUserData(user, eventArgs.Item).PlaybackPositionTicks / TimeSpan.TicksPerSecond;
|
||||||
|
var videoId = Utils.GetVideoNameFromPath(eventArgs.Item.Path);
|
||||||
|
statusCode = await TubeArchivistApi.GetInstance().SetProgress(videoId, progress).ConfigureAwait(true);
|
||||||
|
if (statusCode != System.Net.HttpStatusCode.OK)
|
||||||
|
{
|
||||||
|
Logger.LogCritical("{Message}", $"POST /video/{videoId}/progress returned {statusCode} for video {eventArgs.Item.Name} with progress {progress} seconds");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
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
|
else
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user