Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions twitchdl/commands/clips.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,15 @@ def clips(args):

generator = twitch.channel_clips_generator(args.channel_name, args.period, limit)

if args.sort != "views-desc":
match args.sort:
case "views-asc":
generator = sorted(list(generator), key=lambda x: x['viewCount'])
case "date-desc":
generator = sorted(list(generator), key=lambda x: x['createdAt'], reverse=True)
case "date-asc":
generator = sorted(list(generator), key=lambda x: x['createdAt'])

if args.json:
return print_json(list(generator))

Expand Down
8 changes: 7 additions & 1 deletion twitchdl/console.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ def rate(value: str) -> int:
"type": str,
}),
(["-l", "--limit"], {
"help": "Number of videos to fetch. Defaults to 40 in copmpact mode, 10 otherwise.",
"help": "Number of videos to fetch. Defaults to 40 in compact mode, 10 otherwise.",
"type": pos_integer,
}),
(["-a", "--all"], {
Expand Down Expand Up @@ -143,6 +143,12 @@ def rate(value: str) -> int:
"action": "store_true",
"default": False,
}),
(["-s", "--sort"], {
"help": "Order in which to return clips. Defaults to `views-desc`.",
"type": str,
"choices": ["views-desc", "views-asc", "date-desc", "date-asc"],
"default": "views-desc",
}),
(["-P", "--period"], {
"help": "Period from which to return clips. Defaults to `all_time`.",
"type": str,
Expand Down