mirror of
https://github.com/ihabunek/twitch-dl
synced 2024-08-30 18:32:25 +00:00
Improve paging
This commit is contained in:
parent
d22fd74357
commit
cabc8ff327
@ -102,31 +102,40 @@ 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(
|
||||||
gameIDs: {game_ids}
|
first: {limit},
|
||||||
}}, first: {limit}, type: {type}, sort: {sort}, after: "{after}") {{
|
type: {type},
|
||||||
totalCount
|
sort: {sort},
|
||||||
edges {{
|
after: "{after}",
|
||||||
cursor
|
options: {{
|
||||||
node {{
|
gameIDs: {game_ids}
|
||||||
id
|
}}
|
||||||
title
|
) {{
|
||||||
publishedAt
|
totalCount
|
||||||
broadcastType
|
pageInfo {{
|
||||||
lengthSeconds
|
hasNextPage
|
||||||
game {{
|
}}
|
||||||
name
|
edges {{
|
||||||
}}
|
cursor
|
||||||
creator {{
|
node {{
|
||||||
channel {{
|
id
|
||||||
displayName
|
title
|
||||||
|
publishedAt
|
||||||
|
broadcastType
|
||||||
|
lengthSeconds
|
||||||
|
game {{
|
||||||
|
name
|
||||||
|
}}
|
||||||
|
creator {{
|
||||||
|
channel {{
|
||||||
|
displayName
|
||||||
|
}}
|
||||||
|
}}
|
||||||
|
}}
|
||||||
}}
|
}}
|
||||||
}}
|
|
||||||
}}
|
}}
|
||||||
}}
|
|
||||||
}}
|
}}
|
||||||
}}
|
|
||||||
}}
|
}}
|
||||||
"""
|
"""
|
||||||
|
|
||||||
@ -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
|
||||||
|
Loading…
Reference in New Issue
Block a user