예제 #1
0
        private Blob CreateThumbnail(YouTubeVideo video)
        {
            // Delete previous generated blobs
            BlobFactory.Instance.Delete(video.BinaryDataContainer);

            // Download thumbnail and creat blob
            var webClient     = new WebClient();
            var imageData     = webClient.DownloadData(video.ThumbnailUrl);
            var thumbNailBlob = BlobFactory.Instance.CreateBlob(video.BinaryDataContainer, ".jpg");

            using (var stream = new MemoryStream(imageData))
            {
                thumbNailBlob.Write(stream);
            }

            // Create thumbnail
            var attribute = video.GetType().GetProperty("Thumbnail").GetCustomAttribute <ImageDescriptorAttribute>();

            return(_thumbnailManager.CreateImageBlob(thumbNailBlob, "Thumbnail", attribute));
        }