Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

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