Merge branch 'master' into master

This commit is contained in:
DarkFighterLuke
2025-03-10 19:01:34 +01:00
committed by GitHub
6 changed files with 40 additions and 36 deletions
@@ -192,7 +192,7 @@ namespace Jellyfin.Plugin.TubeArchivistMetadata
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 (user != null && Configuration.GetJFUsernamesToArray().Contains(user!.Username)) if (Configuration.JFTASync && user != null && Configuration.GetJFUsernamesToArray().Contains(user!.Username))
{ {
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);
@@ -218,12 +218,19 @@ namespace Jellyfin.Plugin.TubeArchivistMetadata
return; return;
} }
try
{
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)
{ {
Logger.LogCritical("POST /watched returned {StatusCode} for item {ItemName} ({VideoYTId}) with watched status {IsPlayed}", statusCode, eventArgs.Item.Name, itemYTId, isPlayed); Logger.LogCritical("POST /watched returned {StatusCode} for item {ItemName} ({VideoYTId}) with watched status {IsPlayed}", statusCode, eventArgs.Item.Name, itemYTId, isPlayed);
} }
} }
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);
}
}
} }
} }
} }
@@ -65,7 +65,7 @@ namespace Jellyfin.Plugin.TubeArchivistMetadata.TubeArchivist
/// <returns>A task.</returns> /// <returns>A task.</returns>
public async Task<Channel?> GetChannel(string channelId) public async Task<Channel?> GetChannel(string channelId)
{ {
ResponseContainer<Channel>? channel = null; Channel? channel = null;
var channelsEndpoint = "/api/channel/"; var channelsEndpoint = "/api/channel/";
var url = new Uri(Utils.SanitizeUrl(Plugin.Instance?.Configuration.TubeArchivistUrl + channelsEndpoint + channelId)); var url = new Uri(Utils.SanitizeUrl(Plugin.Instance?.Configuration.TubeArchivistUrl + channelsEndpoint + channelId));
@@ -82,10 +82,10 @@ namespace Jellyfin.Plugin.TubeArchivistMetadata.TubeArchivist
if (response.IsSuccessStatusCode) if (response.IsSuccessStatusCode)
{ {
string rawData = await response.Content.ReadAsStringAsync().ConfigureAwait(true); string rawData = await response.Content.ReadAsStringAsync().ConfigureAwait(true);
channel = JsonConvert.DeserializeObject<ResponseContainer<Channel>>(rawData); channel = JsonConvert.DeserializeObject<Channel>(rawData);
} }
return channel?.Data; return channel;
} }
/// <summary> /// <summary>
@@ -95,7 +95,7 @@ namespace Jellyfin.Plugin.TubeArchivistMetadata.TubeArchivist
/// <returns>A task.</returns> /// <returns>A task.</returns>
public async Task<Video?> GetVideo(string videoId) public async Task<Video?> GetVideo(string videoId)
{ {
ResponseContainer<Video>? video = null; Video? video = null;
var videosEndpoint = "/api/video/"; var videosEndpoint = "/api/video/";
var url = new Uri(Utils.SanitizeUrl(Plugin.Instance?.Configuration.TubeArchivistUrl + videosEndpoint + videoId)); var url = new Uri(Utils.SanitizeUrl(Plugin.Instance?.Configuration.TubeArchivistUrl + videosEndpoint + videoId));
@@ -112,10 +112,11 @@ namespace Jellyfin.Plugin.TubeArchivistMetadata.TubeArchivist
if (response.IsSuccessStatusCode) if (response.IsSuccessStatusCode)
{ {
string rawData = await response.Content.ReadAsStringAsync().ConfigureAwait(true); string rawData = await response.Content.ReadAsStringAsync().ConfigureAwait(true);
video = JsonConvert.DeserializeObject<ResponseContainer<Video>>(rawData); _logger.LogInformation("{Message}", rawData);
video = JsonConvert.DeserializeObject<Video>(rawData);
} }
return video?.Data; return video;
} }
/// <summary> /// <summary>
@@ -174,15 +175,11 @@ namespace Jellyfin.Plugin.TubeArchivistMetadata.TubeArchivist
{ {
Progress? progress = null; Progress? progress = null;
var progressEndpoint = $"/api/video/{videoId}/progress/"; var video = await GetVideo(videoId).ConfigureAwait(true);
var url = new Uri(Utils.SanitizeUrl(Plugin.Instance!.Configuration.TubeArchivistUrl + progressEndpoint)); if (video != null)
var response = await client.GetAsync(url).ConfigureAwait(true);
if (response.IsSuccessStatusCode)
{ {
string rawData = await response.Content.ReadAsStringAsync().ConfigureAwait(true); progress = new Progress((long)video.Player.Position);
progress = JsonConvert.DeserializeObject<Progress>(rawData); _logger.LogInformation("{Message}", $"Retrieved progress {video.Player.Position}");
} }
return progress; return progress;
@@ -1,4 +1,3 @@
using System;
using Newtonsoft.Json; using Newtonsoft.Json;
namespace Jellyfin.Plugin.TubeArchivistMetadata.TubeArchivist namespace Jellyfin.Plugin.TubeArchivistMetadata.TubeArchivist
@@ -13,12 +12,12 @@ namespace Jellyfin.Plugin.TubeArchivistMetadata.TubeArchivist
/// </summary> /// </summary>
/// <param name="duration">Duration of the video.</param> /// <param name="duration">Duration of the video.</param>
/// <param name="isWatched">Whether the video is marked as watched.</param> /// <param name="isWatched">Whether the video is marked as watched.</param>
/// <param name="watchedUnixTime">Unix time of when the video has been marked watched.</param> /// <param name="position">Video watched seconds.</param>
public Player(long duration, bool isWatched, long watchedUnixTime) public Player(long duration, bool isWatched, double position)
{ {
Duration = duration; Duration = duration;
IsWatched = isWatched; IsWatched = isWatched;
WatchedUnixTime = watchedUnixTime; Position = position;
} }
/// <summary> /// <summary>
@@ -34,18 +33,9 @@ namespace Jellyfin.Plugin.TubeArchivistMetadata.TubeArchivist
public bool IsWatched { get; } public bool IsWatched { get; }
/// <summary> /// <summary>
/// Gets the Unix date and time when the video has been marked as watched. /// Gets the video watched seconds.
/// </summary> /// </summary>
[JsonProperty(PropertyName = "watched_date")] [JsonProperty(PropertyName = "position")]
public long WatchedUnixTime { get; } public double Position { get; }
/// <summary>
/// Gets the date and time when the video has been marked as watched.
/// </summary>
[JsonIgnore]
public DateTime WatchedTime
{
get => DateTimeOffset.FromUnixTimeSeconds(WatchedUnixTime).DateTime;
}
} }
} }
+1
View File
@@ -7,6 +7,7 @@
> [!IMPORTANT] > [!IMPORTANT]
> Jellyfin release cycle has changed in the past few months and now it is shorter than before. The plugin supports only the latest Jellyfin release, in order to continue using this plugin with all the latest features you will need to upgrade your Jellyfin installation. > Jellyfin release cycle has changed in the past few months and now it is shorter than before. The plugin supports only the latest Jellyfin release, in order to continue using this plugin with all the latest features you will need to upgrade your Jellyfin installation.
> The same rule applies to TubeArchivist: the plugin is only guaranteed to work with the latest TubeArchivist version.
## About ## About
+3 -2
View File
@@ -2,7 +2,7 @@
name: "TubeArchivistMetadata" name: "TubeArchivistMetadata"
guid: "dc97d0c6-28b0-4242-afb4-5833ae1b3715" guid: "dc97d0c6-28b0-4242-afb4-5833ae1b3715"
imageUrl: https://raw.githubusercontent.com/tubearchivist/tubearchivist-jf-plugin/master/images/logo.png imageUrl: https://raw.githubusercontent.com/tubearchivist/tubearchivist-jf-plugin/master/images/logo.png
version: "1.3.4.0" version: "1.3.5.0"
targetAbi: "10.10.0.0" targetAbi: "10.10.0.0"
framework: "net8.0" framework: "net8.0"
overview: "Metadata for your TubeArchivist library on Jellyfin" overview: "Metadata for your TubeArchivist library on Jellyfin"
@@ -14,4 +14,5 @@ owner: "DarkFighterLuke"
artifacts: artifacts:
- "Jellyfin.Plugin.TubeArchivistMetadata.dll" - "Jellyfin.Plugin.TubeArchivistMetadata.dll"
changelog: > changelog: >
Merge workaround for JF crashing when scanning Series pull request by wolffshots Adapt to the new TA API changes
Fix JF crash when setting watched status with TA offline
+8
View File
@@ -8,6 +8,14 @@
"overview": "Metadata for your TubeArchivist library on Jellyfin", "overview": "Metadata for your TubeArchivist library on Jellyfin",
"imageUrl": "https://raw.githubusercontent.com/tubearchivist/tubearchivist-jf-plugin/master/images/logo.png", "imageUrl": "https://raw.githubusercontent.com/tubearchivist/tubearchivist-jf-plugin/master/images/logo.png",
"versions": [ "versions": [
{
"version": "1.3.5.0",
"changelog": "Adapt to the new TA API changes Fix JF crash when setting watched status with TA offline\n",
"targetAbi": "10.10.0.0",
"sourceUrl": "https://github.com/tubearchivist/tubearchivist-jf-plugin/releases/download/v1.3.5/tubearchivistmetadata_1.3.5.0.zip",
"checksum": "2536622c0ec73e6401860929f24849f7",
"timestamp": "2025-03-10T17:47:43Z"
},
{ {
"version": "1.3.4.0", "version": "1.3.4.0",
"changelog": "Merge workaround for JF crashing when scanning Series pull request by wolffshots\n", "changelog": "Merge workaround for JF crashing when scanning Series pull request by wolffshots\n",