clips - YoYoGames/GMEXT-Twitch GitHub Wiki

Clips

Functions

These are the functions of this module:



Back To Top

twitch_clips_create_clip

Twitch Endpoint: Create Clip

This function creates a clip from the broadcaster's stream.

This API captures up to 90 seconds of the broadcaster's stream. The 90 seconds spans the point in the stream from when you called the API. For example, if you call the API at the 4:00 minute mark, the API captures from approximately the 3:35 mark to approximately the 4:05 minute mark. Twitch tries its best to capture 90 seconds of the stream, but the actual length may be less. This may occur if you begin capturing the clip near the beginning or end of the stream.

By default, Twitch publishes up to the last 30 seconds of the 90 seconds window and provides a default title for the clip. To specify the title and the portion of the 90 seconds window that's used for the clip, use the URL in the response's edit_url field. You can specify a clip that's from 5 seconds to 60 seconds in length. The URL is valid for up to 24 hours or until the clip is published, whichever comes first.

Creating a clip is an asynchronous process that can take a short amount of time to complete. To determine whether the clip was successfully created, call twitch_clips_get_clips using the clip ID that this request returned. If twitch_clips_get_clips returns the clip, the clip was successfully created. If after 15 seconds twitch_clips_get_clips hasn't returned the clip, assume it failed.

Note

Requires a user access token that includes the TWITCH_SCOPE: TWITCH_SCOPE_CLIPS_EDIT.

This function operates asynchronously, which means that it does not immediately return the requested result. Instead, upon completion of the task, it will trigger the Success Callback, or Failure Callback.


Syntax:

twitch_clips_create_clip(broadcaster_id, optionals, callback_success, callback_failed)
Argument Type Description
broadcaster_id String The ID of the broadcaster whose stream you want to create a clip from.
optionals Struct The optional parameters to be passed into the function:

- has_delay : Boolean : A Boolean value that determines whether the API captures the clip at the moment the viewer requests it or after a delay. If false (default), Twitch captures the clip at the moment the viewer requests it (this is the same clip experience as the Twitch UX). If true, Twitch adds a delay before capturing the clip (this basically shifts the capture window to the right slightly).
callback_success Function Triggered if the request succeeded
callback_failed Function Triggered if the request failed



Returns:

N/A


Triggers:

Success Callback

These members are returned in the success callback:

Member Type Description
edit_url String A URL that you can use to edit the clip's title, identify the part of the clip to publish, and publish the clip. Learn More The URL is valid for up to 24 hours or until the clip is published, whichever comes first.
id String An ID that uniquely identifies the clip.

Failure Callback

This method is triggered on failure.




Back To Top

twitch_clips_get_clips

Twitch Endpoint: Get Clips

This function gets one or more video clips that were captured from streams. For information about clips, see How to use clips.

The id, game_id, and broadcaster_id parameters are mutually exclusive.

This function operates asynchronously, which means that it does not immediately return the requested result. Instead, upon completion of the task, it will trigger the Success Callback, or Failure Callback.


Syntax:

twitch_clips_get_clips(broadcaster_id, game_id, id, optionals, callback_success, callback_failed)
Argument Type Description
broadcaster_id String An ID that identifies the broadcaster whose video clips you want to get. Use this parameter to get clips that were captured from the broadcaster's streams.
game_id String An ID that identifies the game whose clips you want to get. Use this parameter to get clips that were captured from streams that were playing this game.
id String or Array An ID that identifies the clip to get. To specify more than one ID, pass an array with the ID of each clip you want to get. You may specify a maximum of 100 IDs. The API ignores duplicate IDs and IDs that aren't found.
optionals Struct The optional parameters to be passed into the function:

- started_at : String : The start date used to filter clips. The API returns only clips within the start and end date window. Specify the date and time in RFC3339 format.
- ended_at : String : The end date used to filter clips. If not specified, the time window is the start date plus one week. Specify the date and time in RFC3339 format.
- first : Real : The maximum number of clips to return per page in the response. The minimum page size is 1 clip per page and the maximum is 100. The default is 20.
- before : String : The cursor used to get the previous page of results. The Pagination struct in the response contains the cursor's value. Read more
- after : String : The cursor used to get the next page of results. The Pagination struct in the response contains the cursor's value. Read more
- is_featured : Boolean : A Boolean value that determines whether the response includes featured clips. If true, returns only clips that are featured. If false, returns only clips that aren't featured. All clips are returned if this parameter is not present.
callback_success Function Triggered if the request succeeded
callback_failed Function Triggered if the request failed



Returns:

N/A


Triggers:

Success Callback

These members are returned in the success callback:

Member Type Description
data Array The list of video clips. For clips returned by game_id or broadcaster_id, the list is in descending order by view count. For lists returned by id, the list is in the same order as the input IDs.
 ├── id String An ID that uniquely identifies the clip.
 ├── url String A URL to the clip.
 ├── embed_url String A URL that you can use in an iframe to embed the clip (see Embedding Video and Clips).
 ├── broadcaster_id String An ID that identifies the broadcaster that the video was clipped from.
 ├── broadcaster_name String The broadcaster's display name.
 ├── creator_id String An ID that identifies the user that created the clip.
 ├── creator_name String The user's display name.
 ├── video_id String An ID that identifies the video that the clip came from. This field contains an empty string if the video is not available.
 ├── game_id String The ID of the game that was being played when the clip was created.
 ├── language String The ISO 639-1 two-letter language code that the broadcaster broadcasts in. For example, "en" for English. The value is "other" if the broadcaster uses a language that Twitch doesn't support.
 ├── title String The title of the clip.
 ├── view_count Real The number of times the clip has been viewed.
 ├── created_at String The date and time of when the clip was created. The date and time is in RFC3339 format.
 ├── thumbnail_url String A URL to a thumbnail image of the clip.
 ├── duration Real The length of the clip, in seconds. Precision is 0.1.
 ├── vod_offset Real The zero-based offset, in seconds, to where the clip starts in the video (VOD). Is undefined if the video is not available or hasn't been created yet from the live stream (see video_id). Note that there's a delay between when a clip is created during a broadcast and when the offset is set. During the delay period, vod_offset is undefined. The delay is indeterminant but is typically minutes long.
 └── is_featured Boolean A Boolean value that indicates if the clip is featured or not.
pagination Struct The information used to page through the list of results. The struct is empty if there are no more pages left to page through. Read More
 └── cursor String The cursor used to get the next page of results. Set the request's after or before parameter to this value depending on whether you're paging forwards or backwards.

Failure Callback

This method is triggered on failure.



⚠️ **GitHub.com Fallback** ⚠️