diff --git a/twitchdl/commands.py b/twitchdl/commands.py index b067476..c18ec22 100644 --- a/twitchdl/commands.py +++ b/twitchdl/commands.py @@ -16,14 +16,14 @@ from twitchdl.exceptions import ConsoleError from twitchdl.output import print_out, print_video -def videos(channel_name, limit, offset, sort, **kwargs): +def videos(channel_name, limit, offset, sort, type, **kwargs): print_out("Looking up user...") user = twitch.get_user(channel_name) if not user: raise ConsoleError("User {} not found.".format(channel_name)) print_out("Loading videos...") - videos = twitch.get_channel_videos(user["id"], limit, offset, sort) + videos = twitch.get_channel_videos(user["id"], limit, offset, sort, type) count = len(videos['videos']) if not count: print_out("No videos found") diff --git a/twitchdl/console.py b/twitchdl/console.py index c28f0fa..50a5cb4 100644 --- a/twitchdl/console.py +++ b/twitchdl/console.py @@ -57,6 +57,12 @@ COMMANDS = [ "choices": ["views", "time"], "default": "time", }), + (["-t", "--type"], { + "help": "Broadcast type. (default: archive)", + "type": str, + "choices": ["archive", "highlight", "upload"], + "default": "archive", + }), ], ), Command( diff --git a/twitchdl/twitch.py b/twitchdl/twitch.py index 87ca26e..2d16a98 100644 --- a/twitchdl/twitch.py +++ b/twitchdl/twitch.py @@ -93,14 +93,14 @@ def get_clip(slug): return data["data"]["clip"] -def get_channel_videos(channel_id, limit, offset, sort): +def get_channel_videos(channel_id, limit, offset, sort, type="archive"): """ https://dev.twitch.tv/docs/v5/reference/channels#get-channel-videos """ url = "https://api.twitch.tv/kraken/channels/{}/videos".format(channel_id) return kraken_get(url, { - "broadcast_type": "archive", + "broadcast_type": type, "limit": limit, "offset": offset, "sort": sort,