全部产品
云市场

媒资管理

更新时间:2019-01-24 12:37:52

初始化客户端

使用前请先初始化客户端,参考 InitVodClient 接口。

搜索媒资信息

接口参数和返回字段请参考 SearchMedia

  1. using System;
  2. using Aliyun.Acs.Core;
  3. using Aliyun.Acs.Core.Exceptions;
  4. using Aliyun.Acs.vod.Model.V20170321;
  5. namespace Aliyun.Acs.vod.Sdk.SearchMedia
  6. {
  7. class MainClass
  8. {
  9. public static void Main(string[] args)
  10. {
  11. try
  12. {
  13. // 构造请求
  14. SearchMediaRequest request = new SearchMediaRequest();
  15. request.SearchType = "video";
  16. request.Fields = "Title,CoverURL,Status";
  17. request.Match = "Status in ('Normal','Checking') and CreationTime = ('2018-07-01T08:00:00Z','2018-08-01T08:00:00Z')";
  18. request.PageNo = 1;
  19. request.PageSize = 10;
  20. request.SearchType = "video";
  21. request.SortBy = "CreationTime:Desc";
  22. // 初始化客户端
  23. DefaultAcsClient client = InitVodClient("<Your AccessKeyId>", "<Your AccessKeySecret>");
  24. // 发起请求,并得到 response
  25. SearchMediaResponse response = client.GetAcsResponse(request);
  26. Console.WriteLine("RequestId = " + response.RequestId);
  27. if (response.MediaList != null && response.MediaList.Count > 0)
  28. {
  29. Console.WriteLine("Total = " + response.Total + "\n");
  30. Console.WriteLine("ScrollToken = " + response.ScrollToken + "\n");
  31. foreach (var media in response.MediaList)
  32. {
  33. Console.WriteLine("MediaId = " + media.MediaId + "\n");
  34. Console.WriteLine("MediaType = " + media.MediaType + "\n");
  35. Console.WriteLine("CreationTime = " + media.CreationTime + "\n");
  36. Console.WriteLine("Title = " + media.Video.Title + "\n");
  37. Console.WriteLine("CoverURL = " + media.Video.CoverURL + "\n");
  38. Console.WriteLine("Status = " + media.Video.Status + "\n");
  39. }
  40. }
  41. }
  42. catch (ServerException ex)
  43. {
  44. Console.WriteLine(ex.ToString());
  45. }
  46. catch (ClientException ex)
  47. {
  48. Console.WriteLine(ex.ToString());
  49. }
  50. }
  51. }
  52. }

获取视频信息

接口参数和返回字段请参考 GetVideoInfo

  1. using System;
  2. using Aliyun.Acs.Core;
  3. using Aliyun.Acs.Core.Exceptions;
  4. using Aliyun.Acs.vod.Model.V20170321;
  5. namespace Aliyun.Acs.vod.Sdk.GetVideoInfo
  6. {
  7. class MainClass
  8. {
  9. public static void Main(string[] args)
  10. {
  11. try
  12. {
  13. // 构造请求
  14. GetVideoInfoRequest request = new GetVideoInfoRequest();
  15. request.VideoId = "<your VideoId>";
  16. // 初始化客户端
  17. DefaultAcsClient client = InitVodClient("<Your AccessKeyId>", "<Your AccessKeySecret>");
  18. // 发起请求,并得到 response
  19. GetVideoInfoResponse response = client.GetAcsResponse(request);
  20. Console.WriteLine("RequestId = " + response.RequestId);
  21. Console.WriteLine("Title = " + response.Video.Title);
  22. Console.WriteLine("CoverURL = " + response.Video.CoverURL);
  23. }
  24. catch (ServerException ex)
  25. {
  26. Console.WriteLine(ex.ToString());
  27. }
  28. catch (ClientException ex)
  29. {
  30. Console.WriteLine(ex.ToString());
  31. }
  32. }
  33. }
  34. }

批量获取视频信息

接口参数和返回字段请参考 GetVideoInfos

  1. using System;
  2. using Aliyun.Acs.Core;
  3. using Aliyun.Acs.Core.Exceptions;
  4. using Aliyun.Acs.Core.Profile;
  5. using Aliyun.Acs.vod.Model.V20170321;
  6. namespace Aliyun.Acs.vod.Sdk.GetVideoInfos
  7. {
  8. class MainClass
  9. {
  10. public static void Main(string[] args)
  11. {
  12. try
  13. {
  14. // 构造请求
  15. GetVideoInfosRequest request = new GetVideoInfosRequest();
  16. request.VideoIds = "VideoId1,VideoId2";
  17. // 初始化客户端
  18. DefaultAcsClient client = InitVodClient("<Your AccessKeyId>", "<Your AccessKeySecret>");
  19. // 发起请求,并得到 response
  20. GetVideoInfosResponse response = client.GetAcsResponse(request);
  21. Console.WriteLine("RequestId = " + response.RequestId);
  22. if (response.NonExistVideoIds != null && response.NonExistVideoIds.Count > 0)
  23. {
  24. foreach (var videoId in response.NonExistVideoIds) {
  25. Console.WriteLine("NonExist videoId = " + videoId);
  26. }
  27. }
  28. if (response.VideoList != null && response.VideoList.Count > 0)
  29. {
  30. foreach (var video in response.VideoList)
  31. {
  32. Console.WriteLine("MediaId = " + video.VideoId);
  33. Console.WriteLine("Title = " + video.Title);
  34. Console.WriteLine("CreationTime = " + video.CreationTime);
  35. Console.WriteLine("CoverURL = " + video.CoverURL);
  36. Console.WriteLine("Status = " + video.Status);
  37. }
  38. }
  39. }
  40. catch (ServerException ex)
  41. {
  42. Console.WriteLine(ex.ToString());
  43. }
  44. catch (ClientException ex)
  45. {
  46. Console.WriteLine(ex.ToString());
  47. }
  48. }
  49. }
  50. }

修改视频信息

接口参数和返回字段请参考 UpdateVideoInfo

  1. using System;
  2. using Aliyun.Acs.Core;
  3. using Aliyun.Acs.Core.Exceptions;
  4. using Aliyun.Acs.vod.Model.V20170321;
  5. namespace Aliyun.Acs.vod.Sdk.UpdateVideoInfo
  6. {
  7. class MainClass
  8. {
  9. public static void Main(string[] args)
  10. {
  11. try
  12. {
  13. // 构造请求
  14. UpdateVideoInfoRequest request = new UpdateVideoInfoRequest();
  15. request.VideoId = "<your VideoId>";
  16. request.Title = "new Title";
  17. request.Description = "new Description";
  18. // 初始化客户端
  19. DefaultAcsClient client = InitVodClient("<Your AccessKeyId>", "<Your AccessKeySecret>");
  20. // 发起请求,并得到 response
  21. UpdateVideoInfoResponse response = client.GetAcsResponse(request);
  22. Console.WriteLine("RequestId = " + response.RequestId);
  23. }
  24. catch (ServerException ex)
  25. {
  26. Console.WriteLine(ex.ToString());
  27. }
  28. catch (ClientException ex)
  29. {
  30. Console.WriteLine(ex.ToString());
  31. }
  32. }
  33. }
  34. }

批量修改视频信息

接口参数和返回字段请参考 UpdateVideoInfos

  1. using System;
  2. using Aliyun.Acs.Core;
  3. using Aliyun.Acs.Core.Exceptions;
  4. using Aliyun.Acs.vod.Model.V20170321;
  5. namespace Aliyun.Acs.vod.Sdk.UpdateVideoInfos
  6. {
  7. class MainClass
  8. {
  9. public static void Main(string[] args)
  10. {
  11. try
  12. {
  13. // 构造请求
  14. UpdateVideoInfosRequest request = new UpdateVideoInfosRequest();
  15. request.UpdateContent = "[{\"VideoId\":\"VideoId1\",\"Title\":\"new Title\"},{\"VideoId\":\"VideoId2\",\"Description\":\"new Description\"}]";
  16. // 初始化客户端
  17. DefaultAcsClient client = InitVodClient("<Your AccessKeyId>", "<Your AccessKeySecret>");
  18. // 发起请求,并得到 response
  19. UpdateVideoInfosResponse response = client.GetAcsResponse(request);
  20. Console.WriteLine("RequestId = " + response.RequestId);
  21. if (response.NonExistVideoIds != null && response.NonExistVideoIds.Count > 0)
  22. {
  23. foreach (var videoId in response.NonExistVideoIds)
  24. {
  25. Console.WriteLine("NonExist videoId = " + videoId);
  26. }
  27. }
  28. }
  29. catch (ServerException ex)
  30. {
  31. Console.WriteLine(ex.ToString());
  32. }
  33. catch (ClientException ex)
  34. {
  35. Console.WriteLine(ex.ToString());
  36. }
  37. }
  38. }
  39. }

删除视频

接口参数和返回字段请参考 DeleteVideo

  1. using System;
  2. using Aliyun.Acs.Core;
  3. using Aliyun.Acs.Core.Exceptions;
  4. using Aliyun.Acs.vod.Model.V20170321;
  5. namespace Aliyun.Acs.vod.Sdk.DeleteVideo
  6. {
  7. class MainClass
  8. {
  9. public static void Main(string[] args)
  10. {
  11. try
  12. {
  13. // 构造请求
  14. DeleteVideoRequest request = new DeleteVideoRequest();
  15. request.VideoIds = "VideoId1,VideoId2";
  16. // 初始化客户端
  17. DefaultAcsClient client = InitVodClient("<Your AccessKeyId>", "<Your AccessKeySecret>");
  18. // 发起请求,并得到 response
  19. DeleteVideoResponse response = client.GetAcsResponse(request);
  20. Console.WriteLine("RequestId = " + response.RequestId);
  21. }
  22. catch (ServerException ex)
  23. {
  24. Console.WriteLine(ex.ToString());
  25. }
  26. catch (ClientException ex)
  27. {
  28. Console.WriteLine(ex.ToString());
  29. }
  30. }
  31. }
  32. }

获取源文件信息(含源片下载地址)

接口参数和返回字段请参考 GetMezzanineInfo

  1. using System;
  2. using Aliyun.Acs.Core;
  3. using Aliyun.Acs.Core.Exceptions;
  4. using Aliyun.Acs.vod.Model.V20170321;
  5. namespace Aliyun.Acs.vod.Sdk.GetMezzanineInfo
  6. {
  7. class MainClass
  8. {
  9. public static void Main(string[] args)
  10. {
  11. try
  12. {
  13. // 构造请求
  14. GetMezzanineInfoRequest request = new GetMezzanineInfoRequest();
  15. request.VideoId = "f45cf4eba5c84d25b290233389558c39";
  16. // 初始化客户端
  17. DefaultAcsClient client = InitVodClient("<Your AccessKeyId>", "<Your AccessKeySecret>");
  18. // 发起请求,并得到 response
  19. GetMezzanineInfoResponse response = client.GetAcsResponse(request);
  20. Console.WriteLine("RequestId = " + response.RequestId);
  21. Console.WriteLine("FileURL = " + response.Mezzanine.FileURL);
  22. Console.WriteLine("Duration = " + response.Mezzanine.Duration);
  23. }
  24. catch (ServerException ex)
  25. {
  26. Console.WriteLine(ex.ToString());
  27. }
  28. catch (ClientException ex)
  29. {
  30. Console.WriteLine(ex.ToString());
  31. }
  32. }
  33. }
  34. }

获取视频列表

接口参数和返回字段请参考 GetVideoList

  1. using System;
  2. using Aliyun.Acs.Core;
  3. using Aliyun.Acs.Core.Exceptions;
  4. using Aliyun.Acs.vod.Model.V20170321;
  5. namespace Aliyun.Acs.vod.Sdk.Sample
  6. {
  7. class MainClass
  8. {
  9. public static void Main(string[] args)
  10. {
  11. try
  12. {
  13. // 构造请求
  14. GetVideoListRequest request = new GetVideoListRequest();
  15. // 分别取一个月前、当前时间的UTC时间作为筛选视频列表的起止时间
  16. request.StartTime = DateTime.UtcNow.AddMonths(-2).ToString("yyyy-MM-ddTHH:mm:ssZ");
  17. request.EndTime = DateTime.UtcNow.ToString("yyyy-MM-ddTHH:mm:ssZ");
  18. request.Status = "Normal,Checking";
  19. request.PageNo = 1;
  20. request.PageSize = 20;
  21. // 初始化客户端
  22. DefaultAcsClient client = InitVodClient("<Your AccessKeyId>", "<Your AccessKeySecret>");
  23. // 发起请求,并得到 response
  24. GetVideoListResponse response = client.GetAcsResponse(request);
  25. Console.WriteLine("RequestId = " + response.RequestId);
  26. foreach (var videoInfo in response.VideoList)
  27. {
  28. Console.WriteLine("VideoList.VideoId = " + videoInfo.VideoId);
  29. Console.WriteLine("VideoList.Title = " + videoInfo.Title);
  30. }
  31. }
  32. catch (ServerException ex)
  33. {
  34. Console.WriteLine(ex.ToString());
  35. }
  36. catch (ClientException ex)
  37. {
  38. Console.WriteLine(ex.ToString());
  39. }
  40. }
  41. }
  42. }

删除媒体流

接口参数和返回字段请参考 DeleteStream

  1. using System;
  2. using Aliyun.Acs.Core;
  3. using Aliyun.Acs.Core.Exceptions;
  4. using Aliyun.Acs.vod.Model.V20170321;
  5. namespace Aliyun.Acs.vod.Sdk.Sample
  6. {
  7. class MainClass
  8. {
  9. public static void Main(string[] args)
  10. {
  11. try
  12. {
  13. // 构造请求
  14. DeleteStreamRequest request = new DeleteStreamRequest();
  15. request.VideoId = "<your VideoId>";
  16. request.JobIds = "JobId1,JobId2";
  17. // 初始化客户端
  18. DefaultAcsClient client = InitVodClient("<Your AccessKeyId>", "<Your AccessKeySecret>");
  19. // 发起请求,并得到 response
  20. DeleteStreamResponse response = client.GetAcsResponse(request);
  21. Console.WriteLine("RequestId = " + response.RequestId);
  22. }
  23. catch (ServerException ex)
  24. {
  25. Console.WriteLine(ex.ToString());
  26. }
  27. catch (ClientException ex)
  28. {
  29. Console.WriteLine(ex.ToString());
  30. }
  31. }
  32. }
  33. }

批量删除源文件

接口参数和返回字段请参考 DeleteMezzanines

  1. using System;
  2. using Aliyun.Acs.Core;
  3. using Aliyun.Acs.Core.Exceptions;
  4. using Aliyun.Acs.vod.Model.V20170321;
  5. namespace Aliyun.Acs.vod.Sdk.DeleteMezzanines
  6. {
  7. class MainClass
  8. {
  9. public static void Main(string[] args)
  10. {
  11. try
  12. {
  13. // 构造请求
  14. DeleteMezzaninesRequest request = new DeleteMezzaninesRequest();
  15. // 待删除的视频ID列表
  16. request.VideoIds = "VideoId1,VideoId2";
  17. // 初始化客户端
  18. DefaultAcsClient client = InitVodClient("<Your AccessKeyId>", "<Your AccessKeySecret>");
  19. // 发起请求,并得到 response
  20. DeleteMezzaninesResponse response = client.GetAcsResponse(request);
  21. // 打印本次请求ID
  22. Console.WriteLine("RequestId = " + response.RequestId);
  23. if (response.NonExistVideoIds != null && response.NonExistVideoIds.Count > 0)
  24. {
  25. foreach (var videoId in response.NonExistVideoIds)
  26. {
  27. Console.WriteLine("NonExist videoId = " + videoId);
  28. }
  29. }
  30. if (response.UnRemoveableVideoIds != null && response.UnRemoveableVideoIds.Count > 0)
  31. {
  32. foreach (var videoId in response.UnRemoveableVideoIds)
  33. {
  34. Console.WriteLine("UnRemoveable videoId = " + videoId);
  35. }
  36. }
  37. }
  38. catch (ServerException ex)
  39. {
  40. Console.WriteLine(ex.ToString());
  41. }
  42. catch (ClientException ex)
  43. {
  44. Console.WriteLine(ex.ToString());
  45. }
  46. }
  47. }
  48. }

批量更新图片信息

接口参数和返回字段请参考 UpdateImageInfos

  1. using System;
  2. using Aliyun.Acs.Core;
  3. using Aliyun.Acs.Core.Exceptions;
  4. using Aliyun.Acs.vod.Model.V20170321;
  5. namespace Aliyun.Acs.vod.Sdk.UpdateImageInfos
  6. {
  7. class MainClass
  8. {
  9. public static void Main(string[] args)
  10. {
  11. try
  12. {
  13. // 构造请求
  14. UpdateImageInfosRequest request = new UpdateImageInfosRequest();
  15. request.UpdateContent = "[{\"ImageId\":\"ImageId1\",\"Title\":\"new Title\"},{\"ImageId\":\"ImageId2\",\"Description\":\"new Description\"}]";
  16. // 初始化客户端
  17. DefaultAcsClient client = InitVodClient("<Your AccessKeyId>", "<Your AccessKeySecret>");
  18. // 发起请求,并得到 response
  19. UpdateImageInfosResponse response = client.GetAcsResponse(request);
  20. Console.WriteLine("RequestId = " + response.RequestId);
  21. if (response.NonExistImageIds != null && response.NonExistImageIds.Count > 0)
  22. {
  23. foreach (var imageId in response.NonExistImageIds)
  24. {
  25. Console.WriteLine("NonExist ImageId = " + imageId);
  26. }
  27. }
  28. }
  29. catch (ServerException ex)
  30. {
  31. Console.WriteLine(ex.ToString());
  32. }
  33. catch (ClientException ex)
  34. {
  35. Console.WriteLine(ex.ToString());
  36. }
  37. }
  38. }
  39. }

获取图片信息

接口参数和返回字段请参考 GetImageInfo

  1. using System;
  2. using Aliyun.Acs.Core;
  3. using Aliyun.Acs.Core.Exceptions;
  4. using Aliyun.Acs.vod.Model.V20170321;
  5. namespace Aliyun.Acs.vod.Sdk.GetImageInfo
  6. {
  7. class MainClass
  8. {
  9. public static void Main(string[] args)
  10. {
  11. try
  12. {
  13. // 构造请求
  14. GetImageInfoRequest request = new GetImageInfoRequest();
  15. // 图片ID
  16. request.ImageId = "ImageId";
  17. // 初始化客户端
  18. DefaultAcsClient client = InitVodClient("<Your AccessKeyId>", "<Your AccessKeySecret>");
  19. // 发起请求,并得到 response
  20. GetImageInfoResponse response = client.GetAcsResponse(request);
  21. // 打印本次请求ID
  22. Console.WriteLine("RequestId = " + response.RequestId);
  23. if (response.ImageInfo != null)
  24. {
  25. Console.WriteLine("ImageId = " + response.ImageInfo.ImageId);
  26. Console.WriteLine("ImageType = " + response.ImageInfo.ImageType);
  27. Console.WriteLine("Title = " + response.ImageInfo.Title);
  28. }
  29. }
  30. catch (ServerException ex)
  31. {
  32. Console.WriteLine(ex.ToString());
  33. }
  34. catch (ClientException ex)
  35. {
  36. Console.WriteLine(ex.ToString());
  37. }
  38. }
  39. }
  40. }

删除图片

接口参数和返回字段请参考 DeleteImage

  1. using System;
  2. using Aliyun.Acs.Core;
  3. using Aliyun.Acs.Core.Exceptions;
  4. using Aliyun.Acs.vod.Model.V20170321;
  5. namespace Aliyun.Acs.vod.Sdk.DeleteImage
  6. {
  7. class MainClass
  8. {
  9. public static void Main(string[] args)
  10. {
  11. try
  12. {
  13. // 构造请求
  14. DeleteImageRequest request = new DeleteImageRequest();
  15. //根据ImageURL删除图片文件
  16. request.DeleteImageType = "ImageURL";
  17. request.ImageURLs = "http://sample.aliyun.com/cover.jpg";
  18. //根据ImageId删除图片文件
  19. //request.DeleteImageType = "ImageId";
  20. //request.ImageIds = "ImageId1,ImageId2";
  21. //根据VideoId删除指定ImageType的图片文件
  22. //request.DeleteImageType = "VideoId";
  23. //request.VideoId = "VideoId";
  24. //request.ImageType = "SpriteSnapshot";
  25. // 初始化客户端
  26. DefaultAcsClient client = InitVodClient("<Your AccessKeyId>", "<Your AccessKeySecret>");
  27. // 发起请求,并得到 response
  28. DeleteImageResponse response = client.GetAcsResponse(request);
  29. // 打印本次请求ID
  30. Console.WriteLine("RequestId = " + response.RequestId);
  31. }
  32. catch (ServerException ex)
  33. {
  34. Console.WriteLine(ex.ToString());
  35. }
  36. catch (ClientException ex)
  37. {
  38. Console.WriteLine(ex.ToString());
  39. }
  40. }
  41. }
  42. }