> ## Documentation Index
> Fetch the complete documentation index at: https://apidoc.cometapi.com/llms.txt
> Use this file to discover all available pages before exploring further.

# تنزيل محتوى فيديو HappyHorse

> نزّل ملف MP4 المكتمل لمهمة فيديو HappyHorse عبر مسار المحتوى.

استخدم نقطة النهاية هذه لتنزيل ملف MP4 لمهمة فيديو HappyHorse مكتملة. إذا كانت المهمة لا تزال قيد التشغيل، فستُرجع API خطأ JSON بدلًا من بيانات الفيديو الثنائية.

## قبل التنزيل

* أنشئ مهمة باستخدام [إنشاء فيديو HappyHorse](./create).
* نفّذ الاستطلاع باستخدام [استرجاع فيديو HappyHorse](./retrieve) حتى تصبح قيمة `status` هي `completed`.
* مرّر معرّف المهمة نفسه إلى نقطة النهاية هذه.

## تخزين الوسائط المكتملة

يكون نص الاستجابة عبارة عن محتوى ثنائي `video/mp4`. احفظ هذه البيانات في وحدة التخزين الخاصة بك عندما يحتاج تطبيقك إلى وصول دائم إلى الوسائط المُولَّدة.


## OpenAPI

````yaml api/openapi/video/happyhorse/get-retrieve-content.openapi.json GET /v1/videos/{task_id}/content
openapi: 3.1.0
info:
  title: HappyHorse Video Content API
  version: 1.0.0
  description: >-
    Download the completed MP4 file for a HappyHorse video task. The endpoint
    returns binary video content on success and a JSON error if the task is not
    ready.
servers:
  - url: https://api.cometapi.com
security:
  - bearerAuth: []
paths:
  /v1/videos/{task_id}/content:
    get:
      summary: Download HappyHorse video content
      description: >-
        Download the generated MP4 file after a HappyHorse video task reaches
        completed status.
      operationId: happyhorse_retrieve_video_content
      parameters:
        - name: task_id
          in: path
          required: true
          description: Task ID returned by POST /v1/videos.
          schema:
            type: string
          example: task_example
      responses:
        '200':
          description: Binary MP4 video content.
          content:
            video/mp4:
              schema:
                type: string
                format: binary
        '400':
          description: The task is not completed.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              example:
                error:
                  message: 'Task is not completed yet, current status: IN_PROGRESS'
                  type: invalid_request_error
        '404':
          description: The task ID does not match a task for the authenticated user.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              example:
                error:
                  message: Task not found
                  type: invalid_request_error
      security:
        - bearerAuth: []
      x-codeSamples:
        - lang: Shell
          label: Download MP4
          source: |-
            curl https://api.cometapi.com/v1/videos/<TASK_ID>/content \
              -H "Authorization: Bearer $COMETAPI_KEY" \
              --output output.mp4
        - lang: Python
          label: Download MP4
          source: |
            import os
            from pathlib import Path

            import requests

            TASK_ID = "<TASK_ID>"
            response = requests.get(
                f"https://api.cometapi.com/v1/videos/{TASK_ID}/content",
                headers={"Authorization": "Bearer " + os.environ["COMETAPI_KEY"]},
                timeout=300,
            )
            response.raise_for_status()
            Path("output.mp4").write_bytes(response.content)
        - lang: JavaScript
          label: Download MP4
          source: |
            import { writeFile } from "node:fs/promises";

            const TASK_ID = "<TASK_ID>";
            const response = await fetch(
              `https://api.cometapi.com/v1/videos/${TASK_ID}/content`,
              { headers: { Authorization: `Bearer ${process.env.COMETAPI_KEY}` } },
            );

            if (!response.ok) {
              throw new Error(await response.text());
            }

            const video = new Uint8Array(await response.arrayBuffer());
            await writeFile("output.mp4", video);
components:
  schemas:
    ErrorResponse:
      description: >-
        Error body. Validation errors can use a top-level code and message,
        while authentication errors can use an error object.
      oneOf:
        - type: object
          required:
            - message
          properties:
            code:
              type:
                - string
                - 'null'
              description: Short error code.
            message:
              type: string
              description: Human-readable error message.
          additionalProperties: true
        - type: object
          required:
            - error
          properties:
            error:
              type: object
              required:
                - message
              properties:
                message:
                  type: string
                  description: Human-readable error message.
                type:
                  type: string
                  description: Error category.
                code:
                  type:
                    - string
                    - 'null'
                  description: Short error code.
              additionalProperties: true
          additionalProperties: true
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      description: Bearer authentication. Use your CometAPI API key.

````