Skip to content

Add sorting options for clips (ascending/descending for view-count and date)#120

Open
dghodgson wants to merge 1 commit intoihabunek:masterfrom
dghodgson:master
Open

Add sorting options for clips (ascending/descending for view-count and date)#120
dghodgson wants to merge 1 commit intoihabunek:masterfrom
dghodgson:master

Conversation

@dghodgson
Copy link

@dghodgson dghodgson commented Feb 20, 2023

Twitch's gql API sucks and doesn't seem to support anything but VIEWS_DESC for the query. AFAIK the official stance for the public Helix API is to just sort the data yourself after getting it.

So, here we are.

Tested with --json and --pager as well as without. Haven't tested downloading but I don't see why that would break.

This does have poor performance when working with large numbers of clips (e.g. --all on channels with thousands of clips) since it has to first exhaust the generator before sorting. But until we can query the GQL API properly I don't see any way around it.

There's no performance impact to the default setting of sorting by view-count descending since the query response comes sorted that way already (so we don't need to exhaust the generator).

Should be noted that since the API returns clips sorted by View Count, the sorting method provided by --sort will only apply to the most-viewed clips unless you specify --all. So that may be a little confusing for end users.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant