All Products
Search
Document Center

Media asset management

Last Updated: Jul 11, 2019

Initialize a client

Initialize a client before using the SDK. For more information, see initVodClient.

Search for media asset information

For more information about the request and response parameters, see SearchMedia.

// Call example
var client = initVodClient('<Your AccessKey ID>', '<Your AccessKey Secret>');

client.request("SearchMedia", {
    Fields: 'Title,CoverURL,Status',
    Match: "Status in ('Normal','Checking') and CreationTime = ('2018-07-01T08:00:00Z','2018-08-01T08:00:00Z')",
    PageNo: 1,
    PageSize: 10,
    SearchType: 'video',
    SortBy: 'CreationTime:Desc'
}, {}).then(function (response) {
    console.log("Total = " + response.Total);
    console.log("ScrollToken = " + response.ScrollToken);
    if (response.MediaList && response.MediaList && response.MediaList.length > 0){
        for (var i=0; i<response.MediaList.length; i++){
            console.log("MediaId = " + response.MediaList[i].MediaId);
            console.log("MediaType = " + response.MediaList[i].MediaType);
            console.log("CreationTime = " + response.MediaList[i].CreationTime);
            console.log("Title = " + response.MediaList[i].Video.Title);
            console.log("CoverURL = " + response.MediaList[i].Video.CoverURL);
            console.log("Status = " + response.MediaList[i].Video.Status);
        }
    }
    console.log('RequestId = ' + response.RequestId);
}).catch(function (response) {
    console.log('ErrorCode = ' + response.data.Code);
    console.log('ErrorMessage = ' + response.data.Message);
    console.log('RequestId = ' + response.data.RequestId);
});

Obtain video information

For more information about the request and response parameters, see GetVideoInfo.

// Call example
var client = initVodClient('<Your AccessKey ID>', '<Your AccessKey Secret>');

client.request("GetVideoInfo", {
    VideoId: 'VideoId'
}, {}).then(function (response) {
    if (response.Video){
        console.log("Title = " + response.Video.Title);
        console.log("Description = " + response.Video.Description);
    }
    console.log('RequestId = ' + response.RequestId);
}).catch(function (response) {
    console.log('ErrorCode = ' + response.data.Code);
    console.log('ErrorMessage = ' + response.data.Message);
    console.log('RequestId = ' + response.data.RequestId);
});

Obtain the information about multiple videos

For more information about the request and response parameters, see GetVideoInfos.

// Call example
var client = initVodClient('<Your AccessKey ID>', '<Your AccessKey Secret>');

client.request("GetVideoInfos", {
    VideoIds: 'Video1,Video2'
}, {}).then(function (response) {
    if (response.VideoList && response.VideoList.length > 0){
        console.log("===== exist video infos : =====");
        for (var i=0; i<response.VideoList.length; i++) {
            var video = response.VideoList[i];
            console.log("VideoId = " + video.VideoId);
            console.log("Title = " + video.Title);
            console.log("Description = " + video.Description);
            console.log("Tags = " + video.Tags);
            console.log("CreationTime = " + video.CreationTime);
        }
    }
    if (response.NonExistVideoIds && response.NonExistVideoIds.length > 0){
        console.log("===== nonexistent videoIds : =====");
        for (var i=0; i<response.NonExistVideoIds.length; i++) {
            console.log("VideoId = " + response.NonExistVideoIds[i]);
        }
    }
    console.log('RequestId = ' + response.RequestId);
}).catch(function (response) {
    console.log('ErrorCode = ' + response.data.Code);
    console.log('ErrorMessage = ' + response.data.Message);
    console.log('RequestId = ' + response.data.RequestId);
});

Modify video information

For more information about the request and response parameters, see UpdateVideoInfo.

// Call example
var client = initVodClient('<Your AccessKey ID>', '<Your AccessKey Secret>');

client.request("UpdateVideoInfo", {
    VideoId: 'VideoId',
    Title: 'new Title',
    Description: 'new Description',
    Tags: 'new Tag1,new Tag2'
}, {}).then(function (response) {
    console.log('RequestId = ' + response.RequestId);
}).catch(function (response) {
    console.log('ErrorCode = ' + response.data.Code);
    console.log('ErrorMessage = ' + response.data.Message);
    console.log('RequestId = ' + response.data.RequestId);
});

Modify the information about multiple videos

For more information about the request and response parameters, see UpdateVideoInfos.

// Call example
var client = initVodClient('<Your AccessKey ID>', '<Your AccessKey Secret>');

var updateContent = [{
    VideoId: 'VideoId1',
    Title: 'new Title',
    Tags: 'new Tag1,new Tag2'
},{
    VideoId: 'VideoId2',
    Title: 'new Title',
    Tags: 'new Tag1,new Tag2'
}];
client.request("UpdateVideoInfos", {
    UpdateContent: JSON.stringify(updateContent)
}, {}).then(function (response) {
    if (response.NonExistVideoIds && response.NonExistVideoIds.length > 0){ 
        console.log("===== nonexistent videoIds : =====");
        for (var i=0; i<response.NonExistVideoIds.length; i++) { 
            console.log("VideoId = " + response.NonExistVideoIds[i]);
        }
    }
    console.log('RequestId = ' + response.RequestId);
}).catch(function (response) {
    console.log('ErrorCode = ' + response.data.Code);
    console.log('ErrorMessage = ' + response.data.Message);
    console.log('RequestId = ' + response.data.RequestId);
});

Delete videos

For more information about the request and response parameters, see DeleteVideo.

// Call example
var client = initVodClient('<Your AccessKey ID>', '<Your AccessKey Secret>');

client.request("DeleteVideo", {
    VideoIds: 'Video1,Video2'
}, {}).then(function (response) {
    console.log('RequestId = ' + response.RequestId);
}).catch(function (response) {
    console.log('ErrorCode = ' + response.data.Code);
    console.log('ErrorMessage = ' + response.data.Message);
    console.log('RequestId = ' + response.data.RequestId);
});

Obtain mezzanine file information (including the mezzanine file download URL)

For more information about the request and response parameters, see GetMezzanineInfo.

// Call example
var client = initVodClient('<Your AccessKey ID>', '<Your AccessKey Secret>');

client.request("GetMezzanineInfo", {
    VideoId: 'VideoId',
    AuthTimeout: 3600 // Sets the expiration time of the mezzanine file download URL.
}, {}).then(function (response) {
    if (response.Mezzanine){
        console.log('Mezzanine.VideoId = ' + response.Mezzanine.VideoId);
        console.log('Mezzanine.FileURL = ' + response.Mezzanine.FileURL);
        console.log('Mezzanine.Width = ' + response.Mezzanine.Width);
        console.log('Mezzanine.Height = ' + response.Mezzanine.Height);
        console.log('Mezzanine.Size = ' + response.Mezzanine.Size);
    }
    console.log('RequestId = ' + response.RequestId);
}).catch(function (response) {
    console.log('ErrorCode = ' + response.data.Code);
    console.log('ErrorMessage = ' + response.data.Message);
    console.log('RequestId = ' + response.data.RequestId);
});

Obtain a video list

For more information about the request and response parameters, see GetVideoList.

// Call example
var client = initVodClient('<Your AccessKey ID>', '<Your AccessKey Secret>');

client.request("GetVideoList", {
    StartTime: '2018-12-28T06:00:00Z',
    EndTime: '2018-12-28T14:00:00Z',
    PageNo: 1,
    PageSize: 2
}, {}).then(function (response) {
    // The total number of videos that are found based on the specified filter criteria.
    console.log('Total = ' + response.Total);
    if (response.VideoList && response.VideoList.Video && response.VideoList.Video.length > 0){ 
        for (var i=0; i<response.VideoList.Video.length; i++){ 
            var video = response.VideoList.Video[i];
            console.log('Title = ' + video.Title);
            console.log('Description = ' + video.Description);
            console.log('Tags = ' + video.Tags);
            console.log('CreationTime = ' + video.CreationTime);
        }
    }
    console.log('RequestId = ' + response.RequestId);
}).catch(function (response) {
    console.log('ErrorCode = ' + response.data.Code);
    console.log('ErrorMessage = ' + response.data.Message);
    console.log('RequestId = ' + response.data.RequestId);
});

Delete media streams

For more information about the request and response parameters, see DeleteStream.

// Call example
var client = initVodClient('<Your AccessKey ID>', '<Your AccessKey Secret>');

client.request("DeleteStream", {
    VideoId: 'VideoId',
    JobIds: 'JobId1,JobId2'
}, {}).then(function (response) {
    console.log('RequestId = ' + response.RequestId);
}).catch(function (response) {
    console.log('ErrorCode = ' + response.data.Code);
    console.log('ErrorMessage = ' + response.data.Message);
    console.log('RequestId = ' + response.data.RequestId);
});

Delete multiple mezzanine files

For more information about the request and response parameters, see DeleteMezzanines.

// Call example
var client = initVodClient('<Your AccessKey ID>', '<Your AccessKey Secret>');

client.request("DeleteMezzanines", {
    VideoIds: 'VideoId',
    Force: false
}, {}).then(function (response) {
    console.log('RequestId = ' + response.RequestId);
}).catch(function (response) {
    console.log('ErrorCode = ' + response.data.Code);
    console.log('ErrorMessage = ' + response.data.Message);
    console.log('RequestId = ' + response.data.RequestId);
});

Update the information about multiple images

For more information about the request and response parameters, see UpdateImageInfos.

// Call example
var client = initVodClient('<Your AccessKey ID>', '<Your AccessKey Secret>');

var updateContent = [{
    ImageId: 'ImageId1',
    Title: 'new title',
    Tags: 'new Tag1,new Tag2'
},{
    ImageId: 'ImageId2',
    Title: 'new title',
    Tags: 'new Tag1,new Tag2'
}];
client.request("UpdateImageInfos", {
    UpdateContent: JSON.stringify(updateContent)
}, {}).then(function (response) {
    if (response.NonExistImageIds && response.NonExistImageIds.ImageId && response.NonExistImageIds.ImageId.length > 0) { 
        console.log("======nonexistent ImageIds : ======");
        console.log('ImageId = ' + response.NonExistImageIds.ImageId);
    }
    console.log('RequestId = ' + response.RequestId);
}).catch(function (response) {
    console.log('ErrorCode = ' + response.data.Code);
    console.log('ErrorMessage = ' + response.data.Message);
    console.log('RequestId = ' + response.data.RequestId);
});

Obtain image information

For more information about the request and response parameters, see GetImageInfo.

// Call example
var client = initVodClient('<Your AccessKey ID>', '<Your AccessKey Secret>');

client.request("GetImageInfo", {
    ImageId: 'ImageId1'
}, {}).then(function (response) {
    if (response.ImageInfo) {
        console.log('ImageId = ' + response.ImageInfo.ImageId);
        console.log('Title = ' + response.ImageInfo.Title);
        console.log('CreationTime = ' + response.ImageInfo.CreationTime);
        console.log('FileURL = ' + response.ImageInfo.Mezzanine.FileURL);
    }
    console.log('RequestId = ' + response.RequestId);
}).catch(function (response) {
    console.log('ErrorCode = ' + response.data.Code);
    console.log('ErrorMessage = ' + response.data.Message);
    console.log('RequestId = ' + response.data.RequestId);
});

Delete images

For more information about the request and response parameters, see DeleteImage.

// Call example
var client = initVodClient('<Your AccessKey ID>', '<Your AccessKey Secret>');

// Deletes image files based on image URLs.
var paras = {
    DeleteImageType: 'ImageURL',
    ImageURLs: 'http://sample.aliyun.com/cover.jpg'
};
// Deletes image files based on image IDs.
// var paras = {
//     DeleteImageType: 'ImageId', 
//     ImageIds: 'ImageId1,ImageId2' 
// };
// Deletes image files of the specified image type based on a video ID.
// var paras = {
//     DeleteImageType: 'VideoId', 
//     VideoId: 'http://sample.aliyun.com/cover.jpg', 
//     ImageType: 'SpriteSnapshot' 
// };
client.request("DeleteImage", paras, {}).then(function (response) {
    console.log('RequestId = ' + response.RequestId);
}).catch(function (response) {
    console.log('ErrorCode = ' + response.data.Code);
    console.log('ErrorMessage = ' + response.data.Message);
    console.log('RequestId = ' + response.data.RequestId);
});