Skip to main content

Downloading Videos

This guide explains how to download videos using the Teyuto API, based on the actual response format provided by the API.

1. Video Download Process

First, you need to request the video download information. The exact endpoint isn't specified, but it might look something like this:

curl -X GET "https://api.teyuto.tv/v2/videos/12345/download" \
-H "Authorization: YOUR_API_KEY" \
-H "Accept: application/json"

Replace 12345 with the actual video ID.

2. Parse the Response

Once you receive the response, parse the JSON to access the video information.

Understanding the API Response

When you request video download information, the Teyuto API returns a JSON object containing an array of available video qualities. Here's what the response looks like:

{
"status": 200,
"videos": [
{
"width": 2880,
"height": 1440,
"size": 22627159,
"progress": 100,
"status": "complete",
"mp4_url": "https://streams.teyuto.tv/videos/12345/slug12345.mp4"
},
// ... more video quality options ...
]
}

Each item in the videos array represents a different quality version of the video, with the following properties:

  • width and height: The dimensions of the video
  • size: The file size in bytes
  • progress: The encoding progress (100 means it's ready)
  • status: The status of the video (e.g., "complete")
  • mp4_url: The direct URL to download this version of the video

3. Choose a Video Quality

Decide which quality version of the video you want to download. You might want to select the highest quality (largest width and height) or let the user choose.

4. Download the Video

Use the mp4_url of the chosen quality to download the video. You can do this programmatically or provide this URL to the user for direct download.

Here's an example using cURL:

curl -O "https://streams.teyuto.tv/videos/113004_1-51043/qid2854v1_h264_7200_1440.mp4"

Replace the URL with the actual mp4_url from the API response.

Best Practices

  1. Quality Selection: Offer users the choice of video quality if appropriate for your application.

  2. File Size Awareness: Display the file size to users before they initiate a download.

  3. Progress Checking: Although the example shows all videos as complete, always check the progress and status fields to ensure the video is ready for download.

  4. Error Handling: Implement robust error handling to manage issues like network interruptions or unavailable video qualities.

  5. Bandwidth Consideration: Be mindful of bandwidth usage, especially when downloading higher quality videos.

  6. Storage Management: Ensure sufficient storage space, particularly for higher resolution options.

  7. URL Security: The mp4_url might be a temporary URL. Avoid storing these URLs long-term; instead, request fresh information when needed.

Considerations

  • Authentication: Ensure your requests to the Teyuto API are properly authenticated.
  • Rate Limiting: Be aware of any rate limits on requests to avoid exceeding your API usage quota.
  • Video Availability: Not all quality options may be available for every video. Always check the API response for available options.
  • Legal and Copyright: Ensure you have the right to download and use the video content as intended.

Conclusion

The Teyuto API provides a flexible way to access videos in various qualities. By parsing the API response correctly and following these guidelines, you can efficiently integrate video downloads into your application while providing users with quality options.