Improve paging

This commit is contained in:
Ivan Habunek 2020-05-17 14:41:11 +02:00
parent d22fd74357
commit cabc8ff327
No known key found for this signature in database
GPG Key ID: CDBD63C43A30BB95

View File

@ -103,10 +103,19 @@ def get_channel_videos(channel_id, limit, sort, type="archive", game_ids=[], aft
query = """ query = """
{{ {{
user(login: "{channel_id}") {{ user(login: "{channel_id}") {{
videos(options: {{ videos(
first: {limit},
type: {type},
sort: {sort},
after: "{after}",
options: {{
gameIDs: {game_ids} gameIDs: {game_ids}
}}, first: {limit}, type: {type}, sort: {sort}, after: "{after}") {{ }}
) {{
totalCount totalCount
pageInfo {{
hasNextPage
}}
edges {{ edges {{
cursor cursor
node {{ node {{
@ -152,9 +161,10 @@ def channel_videos_generator(channel_id, limit, sort, type, game_ids=None):
if not videos["edges"]: if not videos["edges"]:
break break
cursor = videos["edges"][-1]["cursor"] has_next = videos["pageInfo"]["hasNextPage"]
cursor = videos["edges"][-1]["cursor"] if has_next else None
yield videos, cursor is not None yield videos, has_next
if not cursor: if not cursor:
break break