mirror of
https://github.com/ihabunek/twitch-dl
synced 2024-08-30 18:32:25 +00:00
parent
932b7750b9
commit
68a8b70948
@ -72,10 +72,18 @@ def _print_video(video):
|
||||
print_out(video["url"])
|
||||
|
||||
|
||||
def videos(channel_name, **kwargs):
|
||||
videos = twitch.get_channel_videos(channel_name)
|
||||
def videos(channel_name, limit, offset, sort, **kwargs):
|
||||
videos = twitch.get_channel_videos(channel_name, limit, offset, sort)
|
||||
|
||||
print("Found {} videos".format(videos["_total"]))
|
||||
count = len(videos['videos'])
|
||||
if not count:
|
||||
print_out("No videos found")
|
||||
return
|
||||
|
||||
first = offset + 1
|
||||
last = offset + len(videos['videos'])
|
||||
total = videos["_total"]
|
||||
print_out("<yellow>Showing videos {}-{} of {}</yellow>".format(first, last, total))
|
||||
|
||||
for video in videos['videos']:
|
||||
_print_video(video)
|
||||
|
@ -41,6 +41,22 @@ COMMANDS = [
|
||||
"help": "channel name",
|
||||
"type": str,
|
||||
}),
|
||||
(["-l", "--limit"], {
|
||||
"help": "Number of videos to fetch (default 10, max 100)",
|
||||
"type": int,
|
||||
"default": 10,
|
||||
}),
|
||||
(["-o", "--offset"], {
|
||||
"help": "Offset for pagination of results. (default 0)",
|
||||
"type": int,
|
||||
"default": 0,
|
||||
}),
|
||||
(["-s", "--sort"], {
|
||||
"help": "Sorting order of videos. (default: time)",
|
||||
"type": str,
|
||||
"choices": ["views", "time"],
|
||||
"default": "time",
|
||||
}),
|
||||
],
|
||||
),
|
||||
Command(
|
||||
|
@ -27,7 +27,7 @@ def get_video(video_id):
|
||||
return authenticated_get(url).json()
|
||||
|
||||
|
||||
def get_channel_videos(channel_name, limit=20):
|
||||
def get_channel_videos(channel_name, limit, offset, sort):
|
||||
"""
|
||||
https://dev.twitch.tv/docs/v5/reference/channels#get-channel-videos
|
||||
"""
|
||||
@ -36,6 +36,8 @@ def get_channel_videos(channel_name, limit=20):
|
||||
return authenticated_get(url, {
|
||||
"broadcast_type": "archive",
|
||||
"limit": limit,
|
||||
"offset": offset,
|
||||
"sort": sort,
|
||||
}).json()
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user