示例#1
0
        /// <summary>
        /// 批量获取视频信息
        /// </summary>
        /// <returns></returns>
        public GetVideoInfosResponse GetBatchVideosInfo(GetVideoInfosRequest input)
        {
            var client = InitVodClient();
            GetVideoInfosResponse response = client.GetAcsResponse(input);

            return(response);
        }
        /// <summary>
        /// </summary>
        /// <returns></returns>
        public async Task <List <VideoResource> > SynchronousVideoVodData()
        {
            await Task.Yield();

            var dtos = new GetVideoInfosResponse
            {
                VideoList = new List <GetVideoInfosResponse.GetVideoInfos_Video>()
            };
            var maxResult = 20; //批量查询vid不能超过20条
            var request   = new SearchMediaRequest
            {
                SearchType = AliyunVodAppConts.MediaTypeConsts.Video,
                PageNo     = 1,
                PageSize   = maxResult,
                Fields     = "CreateTime"
            };

            var media       = _aliyunVodManager.SearchMediaList(request);
            var totalRecord = media.Total; //2

            if (totalRecord < maxResult)
            {
                var vidList = media.MediaList.Select(a => a.Video.VideoId).ToList();
                dtos = GetVodVideoBatchVideosInfo(vidList);

                return(ConvertToVideoResources(dtos.VideoList));
            }

            //大于了2页数据
            //获取总页数
            var totalPage = (totalRecord + maxResult - 1) / maxResult; // 3

            //模拟分页获取数据
            for (var i = 0; i < totalPage; i++)
            {
                request.PageNo = i + 1; //1+1

                var mediaList = _aliyunVodManager.SearchMediaList(request);
                var mediaIds  = mediaList.MediaList.Select(a => a.Video.VideoId).ToList();

                var subDtos = GetVodVideoBatchVideosInfo(mediaIds);

                dtos.VideoList.AddRange(subDtos.VideoList);
            }

            return(ConvertToVideoResources(dtos.VideoList));
        }
示例#3
0
        public static GetVideoInfosResponse Unmarshall(UnmarshallerContext context)
        {
            GetVideoInfosResponse getVideoInfosResponse = new GetVideoInfosResponse();

            getVideoInfosResponse.HttpResponse = context.HttpResponse;
            getVideoInfosResponse.RequestId    = context.StringValue("GetVideoInfos.RequestId");

            List <string> getVideoInfosResponse_nonExistVideoIds = new List <string>();

            for (int i = 0; i < context.Length("GetVideoInfos.NonExistVideoIds.Length"); i++)
            {
                getVideoInfosResponse_nonExistVideoIds.Add(context.StringValue("GetVideoInfos.NonExistVideoIds[" + i + "]"));
            }
            getVideoInfosResponse.NonExistVideoIds = getVideoInfosResponse_nonExistVideoIds;

            List <GetVideoInfosResponse.GetVideoInfos_Video> getVideoInfosResponse_videoList = new List <GetVideoInfosResponse.GetVideoInfos_Video>();

            for (int i = 0; i < context.Length("GetVideoInfos.VideoList.Length"); i++)
            {
                GetVideoInfosResponse.GetVideoInfos_Video video = new GetVideoInfosResponse.GetVideoInfos_Video();
                video.VideoId          = context.StringValue("GetVideoInfos.VideoList[" + i + "].VideoId");
                video.Title            = context.StringValue("GetVideoInfos.VideoList[" + i + "].Title");
                video.Tags             = context.StringValue("GetVideoInfos.VideoList[" + i + "].Tags");
                video.Status           = context.StringValue("GetVideoInfos.VideoList[" + i + "].Status");
                video.Size             = context.LongValue("GetVideoInfos.VideoList[" + i + "].Size");
                video.Duration         = context.FloatValue("GetVideoInfos.VideoList[" + i + "].Duration");
                video.Description      = context.StringValue("GetVideoInfos.VideoList[" + i + "].Description");
                video.ModificationTime = context.StringValue("GetVideoInfos.VideoList[" + i + "].ModificationTime");
                video.CreationTime     = context.StringValue("GetVideoInfos.VideoList[" + i + "].CreationTime");
                video.CoverURL         = context.StringValue("GetVideoInfos.VideoList[" + i + "].CoverURL");
                video.CateId           = context.LongValue("GetVideoInfos.VideoList[" + i + "].CateId");
                video.CateName         = context.StringValue("GetVideoInfos.VideoList[" + i + "].CateName");

                List <string> video_snapshots = new List <string>();
                for (int j = 0; j < context.Length("GetVideoInfos.VideoList[" + i + "].Snapshots.Length"); j++)
                {
                    video_snapshots.Add(context.StringValue("GetVideoInfos.VideoList[" + i + "].Snapshots[" + j + "]"));
                }
                video.Snapshots = video_snapshots;

                getVideoInfosResponse_videoList.Add(video);
            }
            getVideoInfosResponse.VideoList = getVideoInfosResponse_videoList;

            return(getVideoInfosResponse);
        }
        public static GetVideoInfosResponse Unmarshall(UnmarshallerContext context)
        {
            GetVideoInfosResponse getVideoInfosResponse = new GetVideoInfosResponse();

            getVideoInfosResponse.HttpResponse = context.HttpResponse;
            getVideoInfosResponse.RequestId    = context.StringValue("GetVideoInfos.RequestId");

            List <string> getVideoInfosResponse_nonExistVideoIds = new List <string>();

            for (int i = 0; i < context.Length("GetVideoInfos.NonExistVideoIds.Length"); i++)
            {
                getVideoInfosResponse_nonExistVideoIds.Add(context.StringValue("GetVideoInfos.NonExistVideoIds[" + i + "]"));
            }
            getVideoInfosResponse.NonExistVideoIds = getVideoInfosResponse_nonExistVideoIds;

            List <GetVideoInfosResponse.GetVideoInfos_Video> getVideoInfosResponse_videoList = new List <GetVideoInfosResponse.GetVideoInfos_Video>();

            for (int i = 0; i < context.Length("GetVideoInfos.VideoList.Length"); i++)
            {
                GetVideoInfosResponse.GetVideoInfos_Video video = new GetVideoInfosResponse.GetVideoInfos_Video();
                video.VideoId          = context.StringValue("GetVideoInfos.VideoList[" + i + "].VideoId");
                video.Title            = context.StringValue("GetVideoInfos.VideoList[" + i + "].Title");
                video.Tags             = context.StringValue("GetVideoInfos.VideoList[" + i + "].Tags");
                video.Status           = context.StringValue("GetVideoInfos.VideoList[" + i + "].Status");
                video.Size             = context.LongValue("GetVideoInfos.VideoList[" + i + "].Size");
                video.Duration         = context.FloatValue("GetVideoInfos.VideoList[" + i + "].Duration");
                video.Description      = context.StringValue("GetVideoInfos.VideoList[" + i + "].Description");
                video.ModificationTime = context.StringValue("GetVideoInfos.VideoList[" + i + "].ModificationTime");
                video.CreationTime     = context.StringValue("GetVideoInfos.VideoList[" + i + "].CreationTime");
                video.CoverURL         = context.StringValue("GetVideoInfos.VideoList[" + i + "].CoverURL");
                video.CateId           = context.LongValue("GetVideoInfos.VideoList[" + i + "].CateId");
                video.CateName         = context.StringValue("GetVideoInfos.VideoList[" + i + "].CateName");
                video.DownloadSwitch   = context.StringValue("GetVideoInfos.VideoList[" + i + "].DownloadSwitch");
                video.TemplateGroupId  = context.StringValue("GetVideoInfos.VideoList[" + i + "].TemplateGroupId");
                video.PreprocessStatus = context.StringValue("GetVideoInfos.VideoList[" + i + "].PreprocessStatus");
                video.StorageLocation  = context.StringValue("GetVideoInfos.VideoList[" + i + "].StorageLocation");
                video.RegionId         = context.StringValue("GetVideoInfos.VideoList[" + i + "].RegionId");
                video.CustomMediaInfo  = context.StringValue("GetVideoInfos.VideoList[" + i + "].CustomMediaInfo");
                video.AppId            = context.StringValue("GetVideoInfos.VideoList[" + i + "].AppId");

                List <string> video_snapshots = new List <string>();
                for (int j = 0; j < context.Length("GetVideoInfos.VideoList[" + i + "].Snapshots.Length"); j++)
                {
                    video_snapshots.Add(context.StringValue("GetVideoInfos.VideoList[" + i + "].Snapshots[" + j + "]"));
                }
                video.Snapshots = video_snapshots;

                List <GetVideoInfosResponse.GetVideoInfos_Video.GetVideoInfos_Thumbnail> video_thumbnailList = new List <GetVideoInfosResponse.GetVideoInfos_Video.GetVideoInfos_Thumbnail>();
                for (int j = 0; j < context.Length("GetVideoInfos.VideoList[" + i + "].ThumbnailList.Length"); j++)
                {
                    GetVideoInfosResponse.GetVideoInfos_Video.GetVideoInfos_Thumbnail thumbnail = new GetVideoInfosResponse.GetVideoInfos_Video.GetVideoInfos_Thumbnail();
                    thumbnail.URL = context.StringValue("GetVideoInfos.VideoList[" + i + "].ThumbnailList[" + j + "].URL");

                    video_thumbnailList.Add(thumbnail);
                }
                video.ThumbnailList = video_thumbnailList;

                getVideoInfosResponse_videoList.Add(video);
            }
            getVideoInfosResponse.VideoList = getVideoInfosResponse_videoList;

            return(getVideoInfosResponse);
        }