Create progress TA API DTO
This commit is contained in:
@@ -0,0 +1,53 @@
|
|||||||
|
using Newtonsoft.Json;
|
||||||
|
|
||||||
|
namespace Jellyfin.Plugin.TubeArchivistMetadata.TubeArchivist
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// A class representing TubeArchivist API video progress data.
|
||||||
|
/// </summary>
|
||||||
|
public class Progress
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Initializes a new instance of the <see cref="Progress"/> class.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="position">Playback progress in seconds.</param>
|
||||||
|
/// <param name="youtubeId">Video YouTube id.</param>
|
||||||
|
/// <param name="userId">Playback progress user id.</param>
|
||||||
|
public Progress(
|
||||||
|
long position,
|
||||||
|
string? youtubeId,
|
||||||
|
long? userId)
|
||||||
|
{
|
||||||
|
YoutubeId = youtubeId;
|
||||||
|
UserId = userId;
|
||||||
|
Position = position;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Initializes a new instance of the <see cref="Progress"/> class.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="position">Playback progress in seconds.</param>
|
||||||
|
public Progress(long position)
|
||||||
|
{
|
||||||
|
Position = position;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets the video YouTube id.
|
||||||
|
/// </summary>
|
||||||
|
[JsonProperty(PropertyName = "youtube_id")]
|
||||||
|
public string? YoutubeId { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets playback progress user id.
|
||||||
|
/// </summary>
|
||||||
|
[JsonProperty(PropertyName = "user_id")]
|
||||||
|
public long? UserId { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets video playback progress (in seconds).
|
||||||
|
/// </summary>
|
||||||
|
[JsonProperty(PropertyName = "position")]
|
||||||
|
public long Position { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -159,12 +159,7 @@ namespace Jellyfin.Plugin.TubeArchivistMetadata.TubeArchivist
|
|||||||
{
|
{
|
||||||
var progressEndpoint = $"/api/video/{videoId}/progress/";
|
var progressEndpoint = $"/api/video/{videoId}/progress/";
|
||||||
var url = new Uri(Utils.SanitizeUrl(Plugin.Instance!.Configuration.TubeArchivistUrl + progressEndpoint));
|
var url = new Uri(Utils.SanitizeUrl(Plugin.Instance!.Configuration.TubeArchivistUrl + progressEndpoint));
|
||||||
var body = JsonConvert.SerializeObject(new
|
var body = JsonConvert.SerializeObject(new Progress(progress));
|
||||||
{
|
|
||||||
position = progress
|
|
||||||
});
|
|
||||||
|
|
||||||
var sc = new StringContent(body, Encoding.UTF8, "application/json");
|
|
||||||
|
|
||||||
var response = await client.PostAsync(url, new StringContent(body, Encoding.UTF8, "application/json")).ConfigureAwait(true);
|
var response = await client.PostAsync(url, new StringContent(body, Encoding.UTF8, "application/json")).ConfigureAwait(true);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user