Skip to content

Commit

Permalink
Fix: Gets all updates after hitting the 500 entry per page limit (#131)
Browse files Browse the repository at this point in the history
* Gets all updates after hitting the 500 page limit

* Patch for replacing metadata
  • Loading branch information
scampower3 authored Mar 31, 2024
1 parent b77b2f8 commit 3022e39
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
3 changes: 2 additions & 1 deletion Jellyfin.Plugin.Tvdb/ScheduledTasks/UpdateTask.cs
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,8 @@ public async Task ExecuteAsync(IProgress<double> progress, CancellationToken can
progress.Report(10);
MetadataRefreshOptions refreshOptions = new MetadataRefreshOptions(new DirectoryService(_fileSystem))
{
MetadataRefreshMode = MetadataRefreshMode.FullRefresh
MetadataRefreshMode = MetadataRefreshMode.FullRefresh,
ReplaceAllMetadata = true,
};
double increment = 90.0 / toUpdateItems.Count;
double currentProgress = 10;
Expand Down
13 changes: 12 additions & 1 deletion Jellyfin.Plugin.Tvdb/TvdbClientManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -542,7 +542,18 @@ public async Task<IReadOnlyList<EntityUpdate>> GetUpdates(
var updatesClient = _serviceProvider.GetRequiredService<IUpdatesClient>();
await LoginAsync().ConfigureAwait(false);
var updatesResult = await updatesClient.UpdatesAsync(since: fromTime, type: type, action: action, cancellationToken: cancellationToken).ConfigureAwait(false);
return updatesResult.Data;
var updates = updatesResult.Data.ToList();

// Each page has limit of 500 updates. Get all updates starting from page 1. First page (page 0) is already fetched.
int page = 1;
while (updatesResult.Links.Next != null)
{
updatesResult = await updatesClient.UpdatesAsync(since: fromTime, type: type, action: action, page: page, cancellationToken: cancellationToken).ConfigureAwait(false);
updates.AddRange(updatesResult.Data);
page++;
}

return updates;
}

/// <summary>
Expand Down

0 comments on commit 3022e39

Please sign in to comment.