How to Merge a New Video Import to an Existing Video Using the API How to Merge a New Video Import to an Existing Video Using the API

How to Merge a New Video Import to an Existing Video Using the API

If a video file is already online, it's possible to import it directly to the platform as a new source for a video already existing on the library using the file's URL and the API, This can be done using the Create Video Import endpoint.

Depending on the file size the import process might take from a few minutes to a few hours.

Note: The URL needs to point directly to the video file without redirects.

Importing the file

Note: If the file is already on the video import section (and is not attached already no a video) you can skip this step, you only need the asset's import id, which can be obtained using the List Video imports endpoint.

If you only have a single video, to import a file with Zype's API docs website, you need to head to the Video Import section, we are going to use the Create Video Import endpoint to send a POST Request which the only requirement is the URL of the video File and the admin API Key.

The request can be sent from the documentation itself, but there are also are working examples for cURL and different programming languages on how to use the endpoint. 

Since we want to add/merge the import as a new source to a video already on the library we need to set the auto_add parameter as false

To create the sample request or send it from the docs:

  1. Enter your account's admin API key into the authentication box
    • auth (1).png
  2. Enter the body parameters, in this exercise we want to import the video, added to the library, and have it transcoded as a Zype Hosted source. 
    • In the parameter source_url we include the URL of the video file.
    • The parameter to_zype_hosted as true if the file is to be transcoded as a Zype Hosted asset.
    • The parameter auto_add as false to prevent the import from being added as a new video to the library.
  3. Click the Try Button or copy the samples, cURL, NodeJS, Ruby PHP and Python are available. 
  • Screen Shot 2021-08-27 at 11.08.28.png

The video file will be imported and downloaded to the platform as an async process, the import will be added as an import and we need to capture the id of the import retuned be the request. 

{
"response": {
"_id": "61116abe3a4e7d0001c0094c", <---- we are going to need this
"active": false,
"auto_activate": false,
"auto_add": false,
"bulk_adding_to_library": false,
"created_at": "2021-08-09T13:49:50.049-04:00",
...
"source_url": "https://my.domain.com/my_video.mp4",
"to_zype_hosted": true,
...
}
}

 

Attach an Existing Video with our Import

Now we are going to merge our new import with the video we already have in our library, to that end we need the video's id (you can use the list videos endpoint to get the video id )  and the import id we got on the first step. We are going to create a PUT request with the Attach a Video to a Video Import endpoint 

The parameters are:

  • id: The Id of the import obtained on the previous step (or using the List Video imports endpoint)
  • video_id: id of the video object already on the library
curl --request PUT \  
--url https://api.zype.com/video_imports/61116abe3a4e7d0001c0094c/add_video \
--header 'Accept: application/json' \
--header 'Content-Type: application/json' \
--data '{"video_id":"6102f0ef4997ce0001b10dff"}'

A sample curl request would look like this and our video object on the library will have a new source!