mirror of
https://github.com/mxpv/podsync.git
synced 2024-05-11 05:55:04 +00:00
Fix exception when Vimeo client requests more pages then channel has
This commit is contained in:
@@ -79,7 +79,11 @@ namespace Podsync.Services.Videos.Vimeo
|
||||
{
|
||||
var pageSize = Math.Min(count, MaxPageSize);
|
||||
|
||||
await GetPage(path, pageIndex, pageSize, collection);
|
||||
var isLast = await GetPage(path, pageIndex, pageSize, collection);
|
||||
if (isLast)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
count -= pageSize;
|
||||
pageIndex++;
|
||||
@@ -88,7 +92,7 @@ namespace Podsync.Services.Videos.Vimeo
|
||||
return collection;
|
||||
}
|
||||
|
||||
private async Task GetPage(string path, int pageIndex, int pageSize, List<Video> output)
|
||||
private async Task<bool> GetPage(string path, int pageIndex, int pageSize, List<Video> output)
|
||||
{
|
||||
dynamic resp = await QueryApi($"{path}?per_page={pageSize}&page={pageIndex}");
|
||||
|
||||
@@ -120,6 +124,9 @@ namespace Podsync.Services.Videos.Vimeo
|
||||
|
||||
output.Add(video);
|
||||
}
|
||||
|
||||
// Is last page?
|
||||
return string.IsNullOrEmpty(resp.paging?.next?.ToString());
|
||||
}
|
||||
|
||||
private async Task<Group> QueryGroup(string path)
|
||||
|
@@ -57,6 +57,12 @@ namespace Podsync.Tests.Services.Videos.Vimeo
|
||||
ValidateCollection(videos);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public Task PaginationTest()
|
||||
{
|
||||
return _client.GroupVideos("scifilondon48hr2012", 300);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task UserVideosTest()
|
||||
{
|
||||
|
Reference in New Issue
Block a user