Adapt to the new TA API changes
This commit is contained in:
@@ -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;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user