diff --git a/Jellyfin.Plugin.TubeArchivistMetadata/TubeArchivist/PaginationInfo.cs b/Jellyfin.Plugin.TubeArchivistMetadata/TubeArchivist/PaginationInfo.cs
new file mode 100644
index 0000000..ca6e2d8
--- /dev/null
+++ b/Jellyfin.Plugin.TubeArchivistMetadata/TubeArchivist/PaginationInfo.cs
@@ -0,0 +1,99 @@
+using System.Collections.ObjectModel;
+using Newtonsoft.Json;
+
+namespace Jellyfin.Plugin.TubeArchivistMetadata.TubeArchivist
+{
+ ///
+ /// A class representing pagination information from the TubeArchivist API.
+ ///
+ public class PaginationInfo
+ {
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ /// The size of the page.
+ /// The starting page number.
+ /// The collection of previous page numbers.
+ /// The current page number.
+ /// A value indicating whether the max hits have been reached.
+ /// The parameters used for pagination.
+ /// The last page number.
+ /// The collection of next page numbers.
+ /// The total number of hits.
+ public PaginationInfo(
+ int pageSize,
+ int pageFrom,
+ Collection prevPages,
+ int currentPage,
+ bool maxHits,
+ string parameters,
+ int lastPage,
+ Collection nextPages,
+ int totalHits)
+ {
+ this.PageSize = pageSize;
+ this.PageFrom = pageFrom;
+ this.PrevPages = prevPages;
+ this.CurrentPage = currentPage;
+ this.MaxHits = maxHits;
+ this.Parameters = parameters;
+ this.LastPage = lastPage;
+ this.NextPages = nextPages;
+ this.TotalHits = totalHits;
+ }
+
+ ///
+ /// Gets the page size.
+ ///
+ [JsonProperty(PropertyName = "page_size")]
+ public int PageSize { get; }
+
+ ///
+ /// Gets the page from.
+ ///
+ [JsonProperty(PropertyName = "page_from")]
+ public int PageFrom { get; }
+
+ ///
+ /// Gets the previous pages.
+ ///
+ [JsonProperty(PropertyName = "prev_pages")]
+ public Collection PrevPages { get; }
+
+ ///
+ /// Gets the current page.
+ ///
+ [JsonProperty(PropertyName = "current_page")]
+ public int CurrentPage { get; }
+
+ ///
+ /// Gets a value indicating whether the max hits have been reached.
+ ///
+ [JsonProperty(PropertyName = "max_hits")]
+ public bool MaxHits { get; }
+
+ ///
+ /// Gets the parameters.
+ ///
+ [JsonProperty(PropertyName = "params")]
+ public string Parameters { get; }
+
+ ///
+ /// Gets the last page.
+ ///
+ [JsonProperty(PropertyName = "last_page")]
+ public int LastPage { get; }
+
+ ///
+ /// Gets the next pages.
+ ///
+ [JsonProperty(PropertyName = "next_pages")]
+ public Collection NextPages { get; }
+
+ ///
+ /// Gets the total hits.
+ ///
+ [JsonProperty(PropertyName = "total_hits")]
+ public int TotalHits { get; }
+ }
+}
diff --git a/Jellyfin.Plugin.TubeArchivistMetadata/TubeArchivist/ResponseContainer.cs b/Jellyfin.Plugin.TubeArchivistMetadata/TubeArchivist/ResponseContainer.cs
index 753c10a..9c4a38c 100644
--- a/Jellyfin.Plugin.TubeArchivistMetadata/TubeArchivist/ResponseContainer.cs
+++ b/Jellyfin.Plugin.TubeArchivistMetadata/TubeArchivist/ResponseContainer.cs
@@ -10,5 +10,10 @@ namespace Jellyfin.Plugin.TubeArchivistMetadata.TubeArchivist
/// Gets or sets the contained data object.
///
public T? Data { get; set; }
+
+ ///
+ /// Gets or sets the pagination info object.
+ ///
+ public PaginationInfo? Paginate { get; set; }
}
}
diff --git a/Jellyfin.Plugin.TubeArchivistMetadata/TubeArchivist/TubeArchivistApi.cs b/Jellyfin.Plugin.TubeArchivistMetadata/TubeArchivist/TubeArchivistApi.cs
index 3b81f5d..fe13273 100644
--- a/Jellyfin.Plugin.TubeArchivistMetadata/TubeArchivist/TubeArchivistApi.cs
+++ b/Jellyfin.Plugin.TubeArchivistMetadata/TubeArchivist/TubeArchivistApi.cs
@@ -228,6 +228,38 @@ namespace Jellyfin.Plugin.TubeArchivistMetadata.TubeArchivist
{
string rawData = await response.Content.ReadAsStringAsync().ConfigureAwait(true);
playlists = JsonConvert.DeserializeObject?>>(rawData);
+ if (playlists?.Paginate != null)
+ {
+ var lastPage = playlists.Paginate.LastPage;
+ _logger.LogInformation("Pagination info: Current page {CurrentPage} / Last page {LastPage}, Total hits: {TotalHits}", playlists.Paginate.CurrentPage, playlists.Paginate.LastPage, playlists.Paginate.TotalHits);
+
+ while (playlists.Paginate.CurrentPage < lastPage)
+ {
+ var nextPage = playlists.Paginate.CurrentPage + 1;
+ var pagedUrl = new Uri(Utils.SanitizeUrl(Plugin.Instance?.Configuration.TubeArchivistUrl + playlistsEndpoint + "?page=" + nextPage));
+ response = await client.GetAsync(pagedUrl).ConfigureAwait(true);
+ _logger.LogInformation("{Message}", pagedUrl + ": " + response.StatusCode);
+
+ if (response.IsSuccessStatusCode)
+ {
+ rawData = await response.Content.ReadAsStringAsync().ConfigureAwait(true);
+ var nextPagePlaylists = JsonConvert.DeserializeObject?>>(rawData);
+ if (nextPagePlaylists?.Data != null)
+ {
+ foreach (var playlist in nextPagePlaylists.Data)
+ {
+ playlists.Data?.Add(playlist);
+ }
+ }
+
+ if (nextPagePlaylists?.Paginate != null)
+ {
+ playlists.Paginate = nextPagePlaylists.Paginate;
+ _logger.LogInformation("Pagination info: Current page {CurrentPage} / Last page {LastPage}, Total hits: {TotalHits}", playlists.Paginate.CurrentPage, playlists.Paginate.LastPage, playlists.Paginate.TotalHits);
+ }
+ }
+ }
+ }
}
return playlists?.Data;