zSoulweaver / kient

TypeScript-First Client Library for Kick.com
https://kient.pages.dev/
MIT License
29 stars 11 forks source link

feat: add clip endpoints #12

Closed ahmedrangel closed 7 months ago

ahmedrangel commented 7 months ago

Hello, I really liked your library, especially because it handles authentication very well. I thought it would be nice to add support for clip endpoints.

This PR aims to add a new endpoint for clips to which I have added two methods getClip(clipId) and downloadClip(clipId)

getClip(clipId)

This method retrieves the details of a clip.

Example of use

// ... Kient
const clip_info = await client.api.clip.getClip('clip_01H811MXG4FBR62FXPE1AXABDH')
console.log(clip_info)

Output example

{
  "clip": {
    "id": "clip_01HKXS6G6Y8R408ZZ6GJ4MCCE0",
    "livestream_id": "21657476",
    "category_id": "15",
    "channel_id": 1117152,
    "user_id": 17899999,
    "title": "Fly her out",
    "clip_url": "https://clips.kick.com/clips/dd/clip_01HKXS6G6Y8R408ZZ6GJ4MCCE0/playlist.m3u8",
    "thumbnail_url": "https://clips.kick.com/clips/dd/clip_01HKXS6G6Y8R408ZZ6GJ4MCCE0/thumbnail.png",
    "privacy": "CLIP_PRIVACY_PUBLIC",
    "likes": 3,
    "liked": false,
    "views": 4233,
    "duration": 30,
    "started_at": "2024-01-12T02:48:56.846Z",
    "created_at": "2024-01-12T02:50:08.426782Z",
    "is_mature": false,
    "video_url": "https://clips.kick.com/clips/dd/clip_01HKXS6G6Y8R408ZZ6GJ4MCCE0/playlist.m3u8",
    "view_count": 4233,
    "likes_count": 3,
    "category": {
      "id": 15,
      "name": "Just Chatting",
      "slug": "just-chatting",
      "responsive": "https://files.kick.com/images/subcategories/15/banner/b697a8a3-62db-4779-aa76-e4e47662af97",
      "banner": "https://files.kick.com/images/subcategories/15/banner/b697a8a3-62db-4779-aa76-e4e47662af97",
      "parent_category": "irl"
    },
    "creator": {
      "id": 17899999,
      "username": "ATOM313",
      "slug": "atom313",
      "profile_picture": "https://files.kick.com/images/user/17899999/profile_image/conversion/24969f0a-08a1-4549-ab0f-1096cc48bfee-thumb.webp"
    },
    "channel": {
      "id": 1117152,
      "username": "demisux",
      "slug": "demisux",
      "profile_picture": "https://files.kick.com/images/user/1157280/profile_image/conversion/8dc2d044-258a-41a9-92f7-abec7772d701-thumb.webp"
    }
  }
}

downloadClip(clipId)

This method triggers the Kick API to download a clip and generates a temporary video/mp4 URL.

Example of use

// ... Kient
const clip_download = await client.api.clip.downloadClip('clip_01H811MXG4FBR62FXPE1AXABDH')
console.log(clip_download)

Output example

{
  "url": "https://clips.kick.com/tmp/clip_01H811MXG4FBR62FXPE1AXABDH.mp4"
}
ahmedrangel commented 7 months ago

Thank you for the correction! I'm not very experienced in Typescript but for this addition, I was able to understand it well by taking the time to analyze the code of what you did in the other endpoints.