Implement JF->TA watched status synchronization

This commit is contained in:
DarkFighterLuke
2024-09-06 13:46:11 +02:00
parent a968ae838c
commit 233595baac
7 changed files with 275 additions and 3 deletions
@@ -153,7 +153,7 @@ namespace Jellyfin.Plugin.TubeArchivistMetadata.TubeArchivist
/// </summary>
/// <param name="videoId">Video id.</param>
/// <param name="progress">Progress in seconds.</param>
/// <returns>Nothing if successful.</returns>
/// <returns>The response <see cref="HttpStatusCode"/>.</returns>
public async Task<HttpStatusCode> SetProgress(string videoId, long progress)
{
var progressEndpoint = $"/api/video/{videoId}/progress/";
@@ -187,5 +187,22 @@ namespace Jellyfin.Plugin.TubeArchivistMetadata.TubeArchivist
return progress;
}
/// <summary>
/// Set video/channel/playlist as watched on TubeArchivist.
/// </summary>
/// <param name="itemId">Video/channel/playlist id.</param>
/// <param name="isWatched">Whether the item has been watched or not.</param>
/// <returns>The response <see cref="HttpStatusCode"/>.</returns>
public async Task<HttpStatusCode> SetWatchedStatus(string itemId, bool isWatched)
{
var watchedEndpoint = $"/api/watched/";
var url = new Uri(Utils.SanitizeUrl(Plugin.Instance!.Configuration.TubeArchivistUrl + watchedEndpoint));
var body = JsonConvert.SerializeObject(new Watched(itemId, isWatched));
var response = await client.PostAsync(url, new StringContent(body, Encoding.UTF8, "application/json")).ConfigureAwait(true);
return response.StatusCode;
}
}
}