public static async Task ProcessAsync(IOwinContext context, WebOnlineVideosMediaType mediatype, string id, int maxWidth, int maxHeight, string borders = null) { if (id == null) { throw new BadRequestException("GetOnlineVideosArtworkResized: id is null"); } ImageCache.CacheIdentifier identifier = ImageCache.GetIdentifier(StringToGuid(id), false, maxWidth, maxHeight, borders, 0, FanArtTypes.Thumbnail, FanArtMediaTypes.Undefined); Stream resourceStream; byte[] data; if (ImageCache.TryGetImageFromCache(context, identifier, out data)) { Logger.Info("GetOnlineVideosArtworkResized: got image from cache"); resourceStream = ImageFile(data); context.Response.ContentType = "image/*"; await SendWholeFileAsync(context, resourceStream, false); resourceStream.Dispose(); } byte[] resizedImage = Plugins.MP2Extended.WSS.Images.ResizeImage(OnlineVideosThumbs.GetThumb(mediatype, id), maxWidth, maxHeight, borders); resourceStream = ImageFile(resizedImage); context.Response.ContentType = "image/*"; await SendWholeFileAsync(context, resourceStream, false); resourceStream.Dispose(); }
internal static byte[] GetThumb(WebOnlineVideosMediaType mediaType, string id) { string file = string.Empty; switch (mediaType) { case WebOnlineVideosMediaType.Site: file = GetSiteThumbPath(id); break; case WebOnlineVideosMediaType.GlobalSite: file = GetGlobalSiteThumbPath(id); break; case WebOnlineVideosMediaType.Category: case WebOnlineVideosMediaType.SubCategory: file = GetCategoryThumbPath(id, mediaType); break; case WebOnlineVideosMediaType.Video: file = GetVideoThumbPath(id); break; } return(File.Exists(file) ? File.ReadAllBytes(file) : GetDummyImage()); }
private static string GetCategoryThumbPath(string id, WebOnlineVideosMediaType mediaType) { string siteName; string categoryRecrusiveName; OnlineVideosIdGenerator.DecodeCategoryId(id, out siteName, out categoryRecrusiveName); Category category; if (mediaType == WebOnlineVideosMediaType.Category) { category = MP2Extended.OnlineVideosManager.GetSiteCategories(siteName).Single(x => x.RecursiveName() == categoryRecrusiveName); } else { category = MP2Extended.OnlineVideosManager.GetSubCategories(siteName, categoryRecrusiveName).Single(x => x.RecursiveName() == categoryRecrusiveName); } // Download the thumb in case it doesn't exist if (category.ThumbnailImage == null) { ImageDownloader.DownloadImages(new List <Category> { category }); } return(category.ThumbnailImage); }
public static async Task ProcessAsync(IOwinContext context, WebOnlineVideosMediaType mediatype, string id) { if (id == null) { throw new BadRequestException("GetOnlineVideosArtwork: id is null"); } Stream resourceStream = ImageFile(OnlineVideosThumbs.GetThumb(mediatype, id)); context.Response.ContentType = "image/*"; await SendWholeFileAsync(context, resourceStream, false); resourceStream.Dispose(); }
public async Task GetOnlineVideosArtworkResized(WebOnlineVideosMediaType mediatype, string id, int maxWidth, int maxHeight, string borders = null) { Logger.Debug("WSS Request: {0}", Request.GetOwinContext().Request.Uri); await ResourceAccess.WSS.stream.Images.GetOnlineVideosArtworkResized.ProcessAsync(Request.GetOwinContext(), mediatype, id, maxWidth, maxHeight, borders); }
public async Task GetOnlineVideosArtwork(WebOnlineVideosMediaType mediatype, string id) { Logger.Debug("WSS Request: {0}", Request.GetOwinContext().Request.Uri); await ResourceAccess.WSS.stream.Images.GetOnlineVideosArtwork.ProcessAsync(Request.GetOwinContext(), mediatype, id); }