video: paginate results

This commit is contained in:
knoflook 2022-02-15 12:10:17 +01:00
parent 539d3fa6d0
commit ab1f8d9d7a
Signed by untrusted user: knoflook
GPG Key ID: D6A1D0E8FC4FEF1C
1 changed files with 18 additions and 3 deletions

View File

@ -100,11 +100,26 @@ def update_post(post_directory, video_metadata, host):
def main():
v = peertube.VideoApi(client)
response = v.videos_get(count=100, filter="local", tags_one_of="publish")
count = 100
page = 0
response = v.videos_get(count=count, filter="local", tags_one_of="publish", start=page)
videos = response.to_dict()
videos = videos["data"]
total = videos['total']
videos = videos['data']
total -= count
if total > 0:
to_download = total // count
last_page = total % count
for i in range(to_download):
page += 1
response = v.videos_get(count=count, filter="local", tags_one_of="publish", start=page)
videos += response.to_dict()['data']
if last_page > 0:
page += 1
response = v.videos_get(count=count, filter="local", tags_one_of="publish", start=page)
videos += response.to_dict()['data'][-1*last_page:]
output_dir = os.environ.get("OUTPUT_DIR")