private ILibrary GetLibrary(int?provider, WebMediaType type) { switch (type) { case WebMediaType.Movie: return(MovieLibraries[provider]); case WebMediaType.MusicTrack: case WebMediaType.MusicAlbum: case WebMediaType.MusicArtist: return(MusicLibraries[provider]); case WebMediaType.Picture: return(PictureLibraries[provider]); case WebMediaType.TVShow: case WebMediaType.TVSeason: case WebMediaType.TVEpisode: return(TVShowLibraries[provider]); case WebMediaType.File: case WebMediaType.Folder: case WebMediaType.Drive: return(FileSystemLibraries[provider]); default: throw new ArgumentException(); } }
public WebMediaItem GetMediaItem(int?provider, WebMediaType type, string id) { switch (type) { case WebMediaType.Movie: return(GetMovieDetailedById(provider, id).Finalize(provider, ProviderType.Movie).ToWebMediaItem()); case WebMediaType.MusicTrack: return(GetMusicTrackDetailedById(provider, id).Finalize(provider, ProviderType.Music).ToWebMediaItem()); case WebMediaType.Picture: return(GetPictureDetailedById(provider, id).Finalize(provider, ProviderType.Picture).ToWebMediaItem()); case WebMediaType.TVEpisode: return(GetTVEpisodeDetailedById(provider, id).Finalize(provider, ProviderType.TVShow).ToWebMediaItem()); case WebMediaType.Drive: return(GetFileSystemDriveBasicById(provider, id).Finalize(provider, ProviderType.Filesystem).ToWebMediaItem()); case WebMediaType.Folder: return(GetFileSystemFolderBasicById(provider, id).Finalize(provider, ProviderType.Filesystem).ToWebMediaItem()); case WebMediaType.File: return(GetFileSystemFileBasicById(provider, id).Finalize(provider, ProviderType.Filesystem).ToWebMediaItem()); default: throw new ArgumentException(); } }
public ActionResult Playlist(WebMediaType type, string itemId, string transcoder = null) { // save stream request if (!PlayerOpenedBy.Contains(Request.UserHostAddress)) { PlayerOpenedBy.Add(Request.UserHostAddress); } // get profile var defaultProfile = type == WebMediaType.TV || type == WebMediaType.Recording ? Settings.ActiveSettings.DefaultTVProfile : Settings.ActiveSettings.DefaultMediaProfile; var profile = GetProfile(GetStreamControl(type), transcoder ?? defaultProfile); // generate url RouteValueDictionary parameters = new RouteValueDictionary(); parameters["item"] = itemId; parameters["transcoder"] = profile.Name; parameters["continuationId"] = "playlist-" + randomGenerator.Next(10000, 99999); string url = Url.Action(Enum.GetName(typeof(WebMediaType), type), "Stream", parameters, Request.Url.Scheme, Request.Url.Host); // create playlist StringBuilder m3u = new StringBuilder(); m3u.AppendLine("#EXTM3U"); m3u.AppendLine("#EXTINF:-1, " + MediaName.GetMediaName(type, itemId)); m3u.AppendLine(url); // return it byte[] data = Encoding.UTF8.GetBytes(m3u.ToString()); return(File(data, "audio/x-mpegurl", "stream.m3u")); }
public Stream GetArtworkResized(WebMediaType mediatype, int?provider, string id, WebFileType artworktype, int offset, int maxWidth, int maxHeight, string borders = null, string format = null) { int?calcMaxWidth = maxWidth == 0 ? null : (int?)maxWidth; int?calcMaxHeight = maxHeight == 0 ? null : (int?)maxHeight; return(Images.GetResizedImage(new ImageMediaSource(mediatype, provider, id, artworktype, offset), calcMaxWidth, calcMaxHeight, borders, format)); }
// // HTTP Live Streaming public ActionResult StartHttpLiveStream(WebMediaType type, string itemId, string transcoder, string continuationId) { if (!IsUserAuthenticated()) { Log.Warn("User {0} (host {1}) requested a HLS stream but isn't authenticated - denying access", HttpContext.User.Identity.Name, Request.UserHostAddress); return(new HttpUnauthorizedResult()); } var profile = GetProfile(GetStreamControl(type), transcoder); string identifier = ActuallyStartHttpLiveStream(type, itemId, profile, 0, continuationId); if (identifier != null) { string url = GetStreamMode() == StreamType.Direct ? HttpLiveUrls[identifier] : Url.Action(Enum.GetName(typeof(WebMediaType), type), new RouteValueDictionary() { { "item", itemId }, { "transcoder", transcoder }, { "continuationId", continuationId } }); return(Json(new { Success = true, URL = url }, JsonRequestBehavior.AllowGet)); } else { return(Json(new { Succes = false }, JsonRequestBehavior.AllowGet)); } }
public WebBoolResult InitStream(WebMediaType type, int?provider, string itemId, int?offset, string clientDescription, string identifier, int?idleTimeout) { AuthorizeStreaming(); if (type == WebMediaType.TV) { int channelId = Int32.Parse(itemId); lock (_timeshiftings) { StreamLog.Info(identifier, "Starting timeshifting on channel {0} for client {1}", channelId, clientDescription); var card = Connections.TAS.SwitchTVServerToChannelAndGetVirtualCard("mpextended-" + identifier, channelId); if (card == null) { StreamLog.Error(identifier, "Failed to start timeshifting for stream"); return(false); } else { StreamLog.Debug(identifier, "Timeshifting started!"); _timeshiftings[identifier] = card; itemId = card.TimeShiftFileName; } } } StreamLog.Info(identifier, "Called InitStream with type={0}; provider={1}; itemId={2}; offset={3}; clientDescription={4}; idleTimeout={5}", type, provider, itemId, offset, clientDescription, idleTimeout); return(_stream.InitStream(identifier, clientDescription, new MediaSource(type, provider, itemId, offset), idleTimeout.HasValue ? idleTimeout.Value : 5 * 60)); }
public static Task <Stream> ProcessAsync(IOwinContext context, WebMediaType mediatype, WebFileType filetype, string id, int offset) { ISet <Guid> necessaryMIATypes = new HashSet <Guid>(); necessaryMIATypes.Add(MediaAspect.ASPECT_ID); necessaryMIATypes.Add(ProviderResourceAspect.ASPECT_ID); necessaryMIATypes.Add(ImporterAspect.ASPECT_ID); MediaItem item = MediaLibraryAccess.GetMediaItemById(context, id, necessaryMIATypes, null); if (item == null) { throw new NotFoundException("RetrieveFile: no media item found"); } var files = ResourceAccessUtils.GetResourcePaths(item); var ra = GetResourceAccessor(files[offset]); IFileSystemResourceAccessor fsra = ra as IFileSystemResourceAccessor; if (fsra == null) { throw new InternalServerException("RetrieveFile: failed to create IFileSystemResourceAccessor"); } return(fsra.OpenReadAsync()); }
private static string ArtworkImplementation(this UrlHelper helper, WebMediaType mediaType, string id, Func<string, string, RouteValueDictionary, string> actionMethod) { switch (mediaType) { case WebMediaType.Movie: return actionMethod("Cover", "MovieLibrary", new RouteValueDictionary(new { movie = id })); case WebMediaType.MusicAlbum: return actionMethod("AlbumImage", "MusicLibrary", new RouteValueDictionary(new { album = id })); case WebMediaType.MusicArtist: return actionMethod("ArtistImage", "MusicLibrary", new RouteValueDictionary(new { artist = id })); case WebMediaType.MusicTrack: return actionMethod("TrackImage", "MusicLibrary", new RouteValueDictionary(new { track = id })); case WebMediaType.Radio: case WebMediaType.TV: return actionMethod("ChannelLogo", "Television", new RouteValueDictionary(new { channelId = id })); case WebMediaType.Recording: // TODO: Make width configurable with a parameter (object attributes or something like it) return actionMethod("PreviewImage", "Recording", new RouteValueDictionary(new { id = id, width = 640 })); case WebMediaType.TVEpisode: return actionMethod("EpisodeImage", "TVShowsLibrary", new RouteValueDictionary(new { episode = id })); case WebMediaType.TVSeason: return actionMethod("SeasonImage", "TVShowsLibrary", new RouteValueDictionary(new { season = id })); case WebMediaType.TVShow: return actionMethod("SeriesPoster", "TVShowsLibrary", new RouteValueDictionary(new { season = id })); default: return String.Empty; } }
public MediaSource(WebMediaType type, int? provider, string id) { this.MediaType = (WebStreamMediaType)type; this.Id = id; this.Offset = 0; this.Provider = provider; }
public WebBoolResult RequestImageResize(WebMediaType mediatype, int?provider, string id, WebFileType imagetype, int offset, int maxWidth, int maxHeight, string borders = null, string format = null) { int?calcMaxWidth = maxWidth == 0 ? null : (int?)maxWidth; int?calcMaxHeight = maxHeight == 0 ? null : (int?)maxHeight; return(Images.CacheImage(new ImageMediaSource(mediatype, provider, id, imagetype, offset), calcMaxWidth, calcMaxHeight, borders, format)); }
public string GenerateDownloadToken(WebMediaType mediaType, string itemId) { string tokenData = String.Format("{0}_{1}_{2}", mediaType, itemId, viewContext.HttpContext.Application["randomToken"]); byte[] tokenBytes = SHA256.Create().ComputeHash(Encoding.UTF8.GetBytes(tokenData)); return(tokenBytes.ToHexString()); }
public static async Task ProcessAsync(IOwinContext context, WebMediaType mediatype, string id, WebFileType artworktype, int offset) { int offsetInt = 0; if (id == null) { throw new BadRequestException("GetArtwork: id is null"); } string fanartType; string fanArtMediaType; MapTypes(artworktype, mediatype, out fanartType, out fanArtMediaType); bool isTvRadio = fanArtMediaType == FanArtMediaTypes.ChannelTv || fanArtMediaType == FanArtMediaTypes.ChannelRadio; bool isRecording = mediatype == WebMediaType.Recording; IList <FanArtImage> fanart = GetFanArtImages(context, id, isTvRadio, isRecording, fanartType, fanArtMediaType); // get offset if (offsetInt >= fanart.Count) { Logger.Warn("GetArtwork: offset is too big! FanArt: {0} Offset: {1}", fanart.Count, offsetInt); offsetInt = 0; } Stream resourceStream = ImageFile(fanart[offsetInt].BinaryData); context.Response.ContentType = "image/*"; await SendWholeFileAsync(context, resourceStream, false); resourceStream.Dispose(); }
public Stream ExtractImageResized(WebMediaType type, int?provider, string itemId, long position, int maxWidth, int maxHeight, string borders = null, string format = null) { int?calcMaxWidth = maxWidth == 0 ? null : (int?)maxWidth; int?calcMaxHeight = maxHeight == 0 ? null : (int?)maxHeight; return(Images.ExtractImage(new MediaSource(type, provider, itemId), position, calcMaxWidth, calcMaxHeight, borders, format)); }
public static ProviderType ToProviderType(this WebMediaType mediatype) { switch (mediatype) { case WebMediaType.File: return(ProviderType.Filesystem); case WebMediaType.Movie: return(ProviderType.Movie); case WebMediaType.MusicAlbum: case WebMediaType.MusicArtist: case WebMediaType.MusicTrack: return(ProviderType.Music); case WebMediaType.Picture: return(ProviderType.Picture); case WebMediaType.TVEpisode: case WebMediaType.TVSeason: case WebMediaType.TVShow: return(ProviderType.TVShow); default: throw new ArgumentException(); } }
public static string GetMediaName(WebMediaType type, string id) { try { switch (type) { case WebMediaType.Movie: return Connections.Current.MAS.GetMovieDetailedById(Settings.ActiveSettings.MovieProvider, id).Title; case WebMediaType.MusicAlbum: return Connections.Current.MAS.GetMusicAlbumBasicById(Settings.ActiveSettings.MusicProvider, id).Title; case WebMediaType.MusicTrack: return Connections.Current.MAS.GetMusicTrackDetailedById(Settings.ActiveSettings.MusicProvider, id).Title; case WebMediaType.Recording: return Connections.Current.TAS.GetRecordingById(Int32.Parse(id)).Title; case WebMediaType.TV: return Connections.Current.TAS.GetChannelDetailedById(Int32.Parse(id)).Title; case WebMediaType.TVEpisode: return Connections.Current.MAS.GetTVEpisodeDetailedById(Settings.ActiveSettings.TVShowProvider, id).Title; case WebMediaType.TVShow: return Connections.Current.MAS.GetTVShowDetailedById(Settings.ActiveSettings.TVShowProvider, id).Title; case WebMediaType.TVSeason: default: return ""; } } catch (Exception ex) { Log.Warn("Could not load display name of media", ex); } return ""; }
// // Util protected int?GetProvider(WebMediaType type) { switch (type) { case WebMediaType.File: return(Settings.ActiveSettings.FileSystemProvider); case WebMediaType.Movie: return(Settings.ActiveSettings.MovieProvider); case WebMediaType.MusicAlbum: case WebMediaType.MusicTrack: return(Settings.ActiveSettings.MusicProvider); case WebMediaType.Picture: return(Settings.ActiveSettings.PicturesProvider); case WebMediaType.Recording: case WebMediaType.TV: return(0); case WebMediaType.TVEpisode: case WebMediaType.TVSeason: case WebMediaType.TVShow: return(Settings.ActiveSettings.TVShowProvider); default: // this cannot happen return(0); } }
public ActionResult Download(WebMediaType type, string item) { // Create URL to GetMediaItem Log.Debug("User wants to download type={0}; item={1}", type, item); var queryString = HttpUtility.ParseQueryString(String.Empty); // you can't instantiate that class manually for some reason queryString["clientDescription"] = String.Format("WebMediaPortal download (user {0})", HttpContext.User.Identity.Name); queryString["type"] = ((int)type).ToString(); queryString["itemId"] = item; string address = type == WebMediaType.TV || type == WebMediaType.Recording ? Connections.Current.Addresses.TAS : Connections.Current.Addresses.MAS; string fullUrl = String.Format("http://{0}/MPExtended/StreamingService/stream/GetMediaItem?{1}", address, queryString.ToString()); UriBuilder fullUri = new UriBuilder(fullUrl); // If we connect to the services at localhost, actually give the extern IP address to users if (NetworkInformation.IsLocalAddress(fullUri.Host, false)) fullUri.Host = NetworkInformation.GetIPAddress(false); // Do the actual streaming if (GetStreamMode() == StreamType.Proxied) { Log.Debug("Proxying download at {0}", fullUri.ToString()); GetStreamControl(type).AuthorizeStreaming(); ProxyStream(fullUri.ToString()); } else if (GetStreamMode() == StreamType.Direct) { Log.Debug("Redirecting user to download at {0}", fullUri.ToString()); GetStreamControl(type).AuthorizeRemoteHostForStreaming(HttpContext.Request.UserHostAddress); return Redirect(fullUri.ToString()); } return new EmptyResult(); }
public WebDictionary <string> GetExternalMediaInfo(WebMediaType type, string id) { if (type == WebMediaType.MusicAlbum) { var album = GetAlbumBasicById(id); return(new WebDictionary <string>() { { "Type", "mpmusic album" }, { "Album", album.Title }, { "Artist", album.AlbumArtist } }); } else if (type == WebMediaType.MusicTrack) { return(new WebDictionary <string>() { { "Type", "mpmusic track" }, { "Id", GetTrackBasicById(id).Id } }); } else if (type == WebMediaType.MusicArtist) { return(new WebDictionary <string>() { { "Type", "mpmusic artist" }, { "Artist", GetArtistBasicById(id).Title } }); } throw new ArgumentException(); }
// // HTTP Live Streaming public ActionResult StartHttpLiveStream(WebMediaType type, string itemId, int fileindex, string transcoder, string continuationId) { if (!IsUserAuthenticated()) { Log.Warn("User {0} (host {1}) requested a HLS stream but isn't authenticated - denying access", HttpContext.User.Identity.Name, Request.UserHostAddress); return(new HttpUnauthorizedResult()); } var profile = GetProfile(GetStreamControl(type), transcoder); string identifier = ActuallyStartHttpLiveStream(type, itemId, fileindex, profile, 0, continuationId); if (identifier != null) { string url = GetStreamMode() == StreamType.Direct ? HttpLiveUrls[identifier] : Url.Action(Enum.GetName(typeof(WebMediaType), type), new RouteValueDictionary() { { "item", itemId }, { "fileindex", fileindex }, { "transcoder", transcoder }, { "continuationId", continuationId } }); // iOS does not display poster images with relative paths string posterUrl = Url.AbsoluteArtwork(type, itemId); Log.Debug("HLS: Replying to explicit AJAX HLS start request for continuationId={0} with mode={1}; url={2}", continuationId, GetStreamMode(), url); return(Json(new { Success = true, URL = url, Poster = posterUrl }, JsonRequestBehavior.AllowGet)); } else { return(Json(new { Succes = false }, JsonRequestBehavior.AllowGet)); } }
public Stream GetImageResized(WebMediaType type, int?provider, string id, int maxWidth, int maxHeight, string borders = null, string format = null) { int?calcMaxWidth = maxWidth == 0 ? null : (int?)maxWidth; int?calcMaxHeight = maxHeight == 0 ? null : (int?)maxHeight; return(Images.GetResizedImage(new ImageMediaSource(type, provider, id, WebFileType.Content, 0), calcMaxWidth, calcMaxHeight, borders, format)); }
protected virtual bool CheckArguments(WebMediaType mediatype, WebFileType filetype) { return(!( (mediatype == WebMediaType.TV && FileType != WebFileType.Content) || (mediatype == WebMediaType.Recording && FileType != WebFileType.Content) )); }
public static Task <IList <string> > ProcessAsync(IOwinContext context, WebMediaType mediatype, WebFileType filetype, string id) { if (id == null) { throw new BadRequestException("GetPathList: id is null"); } ISet <Guid> necessaryMIATypes = new HashSet <Guid>(); necessaryMIATypes.Add(MediaAspect.ASPECT_ID); necessaryMIATypes.Add(ProviderResourceAspect.ASPECT_ID); necessaryMIATypes.Add(ImporterAspect.ASPECT_ID); ISet <Guid> optionalMIATypes = new HashSet <Guid>(); optionalMIATypes.Add(VideoAspect.ASPECT_ID); optionalMIATypes.Add(MovieAspect.ASPECT_ID); optionalMIATypes.Add(SeriesAspect.ASPECT_ID); optionalMIATypes.Add(AudioAspect.ASPECT_ID); optionalMIATypes.Add(ImageAspect.ASPECT_ID); MediaItem item = MediaLibraryAccess.GetMediaItemById(context, Guid.Parse(id), necessaryMIATypes, optionalMIATypes); if (item == null) { throw new NotFoundException(String.Format("GetPathList: No MediaItem found with id: {0}", id)); } var output = ResourceAccessUtils.GetPaths(item); return(System.Threading.Tasks.Task.FromResult(output)); }
public static Task <WebItemSupportStatus> ProcessAsync(IOwinContext context, WebMediaType type, int?provider, string itemId, int?offset) { if (itemId == null) { throw new BadRequestException("GetItemSupportStatus: itemId is null"); } ISet <Guid> necessaryMIATypes = new HashSet <Guid>(); necessaryMIATypes.Add(MediaAspect.ASPECT_ID); necessaryMIATypes.Add(ProviderResourceAspect.ASPECT_ID); necessaryMIATypes.Add(ImporterAspect.ASPECT_ID); ISet <Guid> optionalMIATypes = new HashSet <Guid>(); optionalMIATypes.Add(VideoAspect.ASPECT_ID); optionalMIATypes.Add(MovieAspect.ASPECT_ID); optionalMIATypes.Add(SeriesAspect.ASPECT_ID); optionalMIATypes.Add(AudioAspect.ASPECT_ID); optionalMIATypes.Add(ImageAspect.ASPECT_ID); MediaItem item = MediaLibraryAccess.GetMediaItemById(context, itemId, necessaryMIATypes, optionalMIATypes); bool result = item != null; WebItemSupportStatus webItemSupportStatus = new WebItemSupportStatus { Supported = result, Reason = "" }; return(Task.FromResult(webItemSupportStatus)); }
public ActionResult Download(WebMediaType type, string item) { // Create URL to GetMediaItem Log.Debug("User wants to download type={0}; item={1}", type, item); var queryString = HttpUtility.ParseQueryString(String.Empty); // you can't instantiate that class manually for some reason queryString["clientDescription"] = String.Format("WebMediaPortal download (user {0})", HttpContext.User.Identity.Name); queryString["type"] = ((int)type).ToString(); queryString["itemId"] = item; string address = type == WebMediaType.TV || type == WebMediaType.Recording ? Connections.Current.Addresses.TAS : Connections.Current.Addresses.MAS; string fullUrl = String.Format("http://{0}/MPExtended/StreamingService/stream/GetMediaItem?{1}", address, queryString.ToString()); UriBuilder fullUri = new UriBuilder(fullUrl); // If we connect to the services at localhost, actually give the extern IP address to users if (fullUri.Host == "localhost" || fullUri.Host == "127.0.0.1") { fullUri.Host = NetworkInformation.GetIPAddress(); } // Do the actual streaming if (GetStreamMode() == StreamType.Proxied) { Log.Debug("Proxying download at {0}", fullUri.ToString()); GetStreamControl(type).AuthorizeStreaming(); ProxyStream(fullUri.ToString()); } else if (GetStreamMode() == StreamType.Direct) { Log.Debug("Redirecting user to download at {0}", fullUri.ToString()); GetStreamControl(type).AuthorizeRemoteHostForStreaming(HttpContext.Request.UserHostAddress); return(Redirect(fullUri.ToString())); } return(new EmptyResult()); }
protected override bool CheckArguments(WebMediaType mediatype, WebFileType filetype) { if ((mediatype == WebMediaType.TV || mediatype == WebMediaType.Recording) && filetype == WebFileType.Logo) { return(true); } return(base.CheckArguments(mediatype, filetype)); }
public WebDictionary <string> GetExternalMediaInfo(WebMediaType type, string id) { return(new WebDictionary <string>() { { "Type", "file" }, { "Path", GetPictureBasic(id).Path.First() }, }); }
public WebDictionary <string> GetExternalMediaInfo(WebMediaType type, string id) { return(new WebDictionary <string>() { { "Type", "moving pictures" }, { "Id", id } }); }
public SerializableDictionary <string> GetExternalMediaInfo(WebMediaType type, string id) { return(new SerializableDictionary <string>() { { "Type", "myvideos" }, { "Id", id } }); }
public static async Task <WebIntResult> ProcessAsync(IOwinContext context, WebMediaType mediaType, string filterField, string op, int?limit) { IList <string> output = await GetFilterValues.ProcessAsync(context, mediaType, filterField, op, limit, null); return(new WebIntResult { Result = output.Count }); }
public SerializableDictionary<string> GetExternalMediaInfo(WebMediaType type, string id) { return new SerializableDictionary<string>() { { "Type", "file" }, { "Path", GetFileBasic(id).Path.First() } }; }
// // Streaming public ActionResult Download(WebMediaType type, string item, string token = null) { // Check authentication if (!IsUserAuthenticated()) { string expectedData = String.Format("{0}_{1}_{2}", type, item, HttpContext.Application["randomToken"]); byte[] expectedBytes = SHA256.Create().ComputeHash(Encoding.UTF8.GetBytes(expectedData)); string expectedToken = expectedBytes.ToHexString(); if (token == null || expectedToken != token) { Log.Error("Denying download type={0}, item={1}, token={2}, ip={3}: user is not logged in and token is invalid", type, item, token, Request.UserHostAddress); return new HttpUnauthorizedResult(); } } // Create URL to GetMediaItem Log.Debug("User wants to download type={0}; item={1}", type, item); var queryString = HttpUtility.ParseQueryString(String.Empty); // you can't instantiate that class manually for some reason var userDescription = !String.IsNullOrEmpty(HttpContext.User.Identity.Name) ? String.Format(" (user {0})", HttpContext.User.Identity) : // TODO: also grab the user from the Authorization header here !String.IsNullOrEmpty(token) ? " (token-based download)" : String.Empty; queryString["clientDescription"] = "WebMediaPortal download" + userDescription; queryString["type"] = ((int)type).ToString(); queryString["itemId"] = item; string address = type == WebMediaType.TV || type == WebMediaType.Recording ? Connections.Current.Addresses.TAS : Connections.Current.Addresses.MAS; string fullUrl = String.Format("http://{0}/MPExtended/StreamingService/stream/GetMediaItem?{1}", address, queryString.ToString()); UriBuilder fullUri = new UriBuilder(fullUrl); // If we can access the file without any problems, let IIS stream it; that is a lot faster if (NetworkInformation.IsLocalAddress(fullUri.Host) && type != WebMediaType.TV) { var path = type == WebMediaType.Recording ? Connections.Current.TAS.GetRecordingFileInfo(Int32.Parse(item)).Path : Connections.Current.MAS.GetMediaItem(GetProvider(type), type, item).Path[0]; if (System.IO.File.Exists(path)) return File(path, MIME.GetFromFilename(path, "application/octet-stream"), Path.GetFileName(path)); } // If we connect to the services at localhost, actually give the extern IP address to users if (NetworkInformation.IsLocalAddress(fullUri.Host)) fullUri.Host = NetworkInformation.GetIPAddressForUri(); // Do the actual streaming if (GetStreamMode() == StreamType.Proxied) { Log.Debug("Proxying download at {0}", fullUri.ToString()); GetStreamControl(type).AuthorizeStreaming(); ProxyStream(fullUri.ToString()); } else if (GetStreamMode() == StreamType.Direct) { Log.Debug("Redirecting user to download at {0}", fullUri.ToString()); GetStreamControl(type).AuthorizeRemoteHostForStreaming(HttpContext.Request.UserHostAddress); return Redirect(fullUri.ToString()); } return new EmptyResult(); }
public object GetDownloadArguments(WebMediaType mediaType, string itemId) { return new { item = itemId, type = mediaType, token = GenerateDownloadToken(mediaType, itemId) }; }
public object GetDownloadArguments(WebMediaType mediaType, string itemId) { return(new { item = itemId, type = mediaType, token = GenerateDownloadToken(mediaType, itemId) }); }
public Stream Download(string clientDescription, WebMediaType type, int?provider, string itemId, long?position) { // validate source first MediaSource source = new MediaSource(type, provider, itemId); if (!source.Exists) { throw new FileNotFoundException(); } // create context DownloadContext context = new DownloadContext() { ClientDescription = clientDescription, Source = source, StartTime = DateTime.Now, Stream = new ReadTrackingStreamWrapper(source.Retrieve()), MediaInfo = MediaInfoHelper.LoadMediaInfoOrSurrogate(source) // for playerposition view }; // seek to start position if wanted/needed if (position != null && position > 0) { if (context.Stream.CanSeek) { context.Stream.Seek(position.Value, SeekOrigin.Begin); } else { Log.Warn("Download: Cannot seek on stream, failed to set start position to {0}", position); } } // see comment in Streaming.cs:151 string realIp = WCFUtil.GetHeaderValue("forwardedFor", "X-Forwarded-For"); context.ClientIP = realIp == null?WCFUtil.GetClientIPAddress() : String.Format("{0} (via {1})", realIp, WCFUtil.GetClientIPAddress()); // set headers for downloading WCFUtil.AddHeader("Content-Disposition", "attachment; filename=\"" + source.GetFileInfo().Name + "\""); if (source.MediaType != WebMediaType.TV) { WCFUtil.SetContentLength(source.GetFileInfo().Size); } // FIXME: there has to be a better way to do this string mime = MIME.GetFromFilename(source.GetFileInfo().Name); if (mime != null) { WCFUtil.SetContentType(mime); } // finally, save the context and return runningDownloads.Add(context); return(context.Stream); }
public static async Task <bool> ProcessAsync(IOwinContext context, WebMediaType type, string id) { if (id == null) { throw new BadRequestException("GetImage: id is null"); } ISet <Guid> necessaryMIATypes = new HashSet <Guid>(); necessaryMIATypes.Add(MediaAspect.ASPECT_ID); necessaryMIATypes.Add(ProviderResourceAspect.ASPECT_ID); necessaryMIATypes.Add(ImporterAspect.ASPECT_ID); necessaryMIATypes.Add(ImageAspect.ASPECT_ID); MediaItem item = MediaLibraryAccess.GetMediaItemById(context, id, necessaryMIATypes, null); var resourcePathStr = item.PrimaryResources[item.ActiveResourceLocatorIndex].GetAttributeValue(ProviderResourceAspect.ATTR_RESOURCE_ACCESSOR_PATH); var resourcePath = ResourcePath.Deserialize(resourcePathStr.ToString()); var ra = GetResourceAccessor(resourcePath); IFileSystemResourceAccessor fsra = ra as IFileSystemResourceAccessor; if (fsra == null) { throw new InternalServerException("GetImage: failed to create IFileSystemResourceAccessor"); } using (var resourceStream = fsra.OpenRead()) { // HTTP/1.1 RFC2616 section 14.25 'If-Modified-Since' if (!string.IsNullOrEmpty(context.Request.Headers["If-Modified-Since"])) { DateTime lastRequest = DateTime.Parse(context.Request.Headers["If-Modified-Since"]); if (lastRequest.CompareTo(fsra.LastChanged) <= 0) { context.Response.StatusCode = (int)HttpStatusCode.NotModified; } } // HTTP/1.1 RFC2616 section 14.29 'Last-Modified' context.Response.Headers["Last-Modified"] = fsra.LastChanged.ToUniversalTime().ToString("r"); string byteRangesSpecifier = context.Request.Headers["Range"]; IList <Range> ranges = ParseByteRanges(byteRangesSpecifier, resourceStream.Length); bool onlyHeaders = context.Request.Method == "HEAD" || context.Response.StatusCode == (int)HttpStatusCode.NotModified; if (ranges != null && ranges.Count > 0) { // We only support last range await SendRangeAsync(context, resourceStream, ranges[ranges.Count - 1], onlyHeaders); } else { await SendWholeFileAsync(context, resourceStream, onlyHeaders); } } return(true); }
public WebItemSupportStatus GetItemSupportStatus(WebMediaType type, int?provider, string itemId, int?offset) { // check if we actually now about this file MediaSource source = new MediaSource(type, provider, itemId, offset); string error = source.CheckAvailability(); return(error != null ? new WebItemSupportStatus(false, error) : new WebItemSupportStatus(true, null)); }
public SerializableDictionary<string> GetExternalMediaInfo(WebMediaType type, string id) { string path = GetFileBasic(id).Path.First(); return new SerializableDictionary<string>() { { "Type", File.Exists(path) ? "file" : "folder" }, { "Path", path }, { "Extensions", ".*" } }; }
public WebBoolResult AddPlaylistItems(int? provider, string playlistId, WebMediaType type, int? position, string ids) { IList<WebPlaylistItem> playlist = GetAllPlaylistItems(provider, playlistId).Finalize(provider, type); int pos = position != null ? (int)position : playlist.Count - 1; string[] splitIds = ids.Split(new char[] { '|' }, StringSplitOptions.RemoveEmptyEntries); for (int i = 0; i < splitIds.Length; i++) { AddPlaylistItemToPlaylist(provider, splitIds[i], pos + i, playlist); } return PlaylistLibraries[provider].SavePlaylist(playlistId, playlist); }
public async Task DoStream(WebMediaType type, int?provider, string itemId, string clientDescription, string profileName, long startPosition, int?idleTimeout) { Logger.Debug("WSS Request: {0}", Request.GetOwinContext().Request.Uri); string identifier = Guid.NewGuid().ToString(); var result = await ResourceAccess.WSS.json.Control.InitStream.ProcessAsync(Request.GetOwinContext(), itemId, clientDescription, identifier, type, idleTimeout); if (result.Result) { await ResourceAccess.WSS.json.Control.StartStream.ProcessAsync(Request.GetOwinContext(), identifier, profileName, startPosition); } }
public Stream Download(string clientDescription, WebMediaType type, int? provider, string itemId, long? position) { // validate source first MediaSource source = new MediaSource(type, provider, itemId); if (!source.Exists) { throw new FileNotFoundException(); } // create context DownloadContext context = new DownloadContext() { ClientDescription = clientDescription, Source = source, StartTime = DateTime.Now, Stream = new ReadTrackingStreamWrapper(source.Retrieve()), MediaInfo = MediaInfoHelper.LoadMediaInfoOrSurrogate(source) // for playerposition view }; // seek to start position if wanted/needed if (position != null && position > 0) { if (context.Stream.CanSeek) { context.Stream.Seek(position.Value, SeekOrigin.Begin); } else { Log.Warn("Download: Cannot seek on stream, failed to set start position to {0}", position); } } // see comment in Streaming.cs:151 string realIp = WCFUtil.GetHeaderValue("forwardedFor", "X-Forwarded-For"); context.ClientIP = realIp == null ? WCFUtil.GetClientIPAddress() : String.Format("{0} (via {1})", realIp, WCFUtil.GetClientIPAddress()); // set headers for downloading WCFUtil.AddHeader("Content-Disposition", "attachment; filename=\"" + source.GetFileInfo().Name + "\""); if (source.MediaType != WebMediaType.TV) WCFUtil.SetContentLength(source.GetFileInfo().Size); // FIXME: there has to be a better way to do this string mime = MIME.GetFromFilename(source.GetFileInfo().Name); if (mime != null) { WCFUtil.SetContentType(mime); } // finally, save the context and return runningDownloads.Add(context); return context.Stream; }
public WebBoolResult AddPlaylistItem(int? provider, string playlistId, WebMediaType type, string id, int? position) { IList<WebPlaylistItem> playlist = GetAllPlaylistItems(provider, playlistId).Finalize(provider, type); if (AddPlaylistItemToPlaylist(provider, id, position, playlist)) { return PlaylistLibraries[provider].SavePlaylist(playlistId, playlist); } else { return false; } }
public MediaSource(WebMediaType type, int? provider, string id, WebFileType filetype, int offset) { this.MediaType = type; this.Id = id; this.Provider = provider; this.Offset = offset; this.FileType = filetype; if (!CheckArguments(type, filetype)) { throw new ArgumentException("Invalid combination of mediatype and filetype"); } }
public static ActionResult ReturnFromService(WebMediaType mediaType, string id, WebFileType artworkType, int maxWidth, int maxHeight, string defaultFile = null) { IStreamingService service; int? provider = null; switch (mediaType) { case WebMediaType.Drive: case WebMediaType.File: case WebMediaType.Folder: service = Connections.Current.MASStream; provider = Settings.ActiveSettings.FileSystemProvider; break; case WebMediaType.Movie: service = Connections.Current.MASStream; provider = Settings.ActiveSettings.MovieProvider; break; case WebMediaType.MusicAlbum: case WebMediaType.MusicArtist: case WebMediaType.MusicTrack: service = Connections.Current.MASStream; provider = Settings.ActiveSettings.MusicProvider; break; case WebMediaType.Picture: service = Connections.Current.MASStream; provider = Settings.ActiveSettings.PicturesProvider; break; case WebMediaType.TVShow: case WebMediaType.TVSeason: case WebMediaType.TVEpisode: service = Connections.Current.MASStream; provider = Settings.ActiveSettings.TVShowProvider; break; case WebMediaType.TV: service = Connections.Current.TASStream; break; case WebMediaType.Recording: service = Connections.Current.TASStream; return ReturnFromService(service, () => service.ExtractImageResized(mediaType, provider, id, 15, maxWidth, maxHeight), defaultFile); default: throw new ArgumentException("Tried to load image for unknown mediatype " + mediaType); } string etag = String.Format("{0}_{1}_{2}_{3}_{4}_{5}", mediaType, provider, id, artworkType, maxWidth, maxHeight); return ReturnFromService(service, () => service.GetArtworkResized(mediaType, provider, id, artworkType, 0, maxWidth, maxHeight), defaultFile, etag); }
public ActionResult Download(WebMediaType type, string item) { // Create URL to GetMediaItem Log.Debug("User wants to download type={0}; item={1}", type, item); var queryString = HttpUtility.ParseQueryString(String.Empty); // you can't instantiate that class manually for some reason queryString["clientDescription"] = String.Format("WebMediaPortal download (user {0})", HttpContext.User.Identity.Name); queryString["type"] = ((int)type).ToString(); queryString["itemId"] = item; string address = type == WebMediaType.TV || type == WebMediaType.Recording ? Connections.Current.Addresses.TAS : Connections.Current.Addresses.MAS; string fullUrl = String.Format("http://{0}/MPExtended/StreamingService/stream/GetMediaItem?{1}", address, queryString.ToString()); UriBuilder fullUri = new UriBuilder(fullUrl); // If we can access the file without any problems, let IIS stream it; that is a lot faster if (NetworkInformation.IsLocalAddress(fullUri.Host, false) && type != WebMediaType.TV) { var path = type == WebMediaType.Recording ? Connections.Current.TAS.GetRecordingFileInfo(Int32.Parse(item)).Path : Connections.Current.MAS.GetMediaItem(GetProvider(type), type, item).Path[0]; if (System.IO.File.Exists(path)) return File(path, MIME.GetFromFilename(path, "application/octet-stream"), Path.GetFileName(path)); } // If we connect to the services at localhost, actually give the extern IP address to users if (NetworkInformation.IsLocalAddress(fullUri.Host, false)) fullUri.Host = NetworkInformation.GetIPAddress(false); // Do the actual streaming if (GetStreamMode() == StreamType.Proxied) { Log.Debug("Proxying download at {0}", fullUri.ToString()); GetStreamControl(type).AuthorizeStreaming(); ProxyStream(fullUri.ToString()); } else if (GetStreamMode() == StreamType.Direct) { Log.Debug("Redirecting user to download at {0}", fullUri.ToString()); GetStreamControl(type).AuthorizeRemoteHostForStreaming(HttpContext.Request.UserHostAddress); return Redirect(fullUri.ToString()); } return new EmptyResult(); }
private ILibrary GetLibrary(int? provider, WebMediaType type) { switch (type) { case WebMediaType.Movie: return MovieLibraries[provider]; case WebMediaType.MusicTrack: case WebMediaType.MusicAlbum: case WebMediaType.MusicArtist: return MusicLibraries[provider]; case WebMediaType.Picture: return PictureLibraries[provider]; case WebMediaType.TVShow: case WebMediaType.TVSeason: case WebMediaType.TVEpisode: return TVShowLibraries[provider]; case WebMediaType.File: case WebMediaType.Folder: case WebMediaType.Drive: return FileSystemLibraries[provider]; default: throw new ArgumentException(); } }
public Stream RetrieveFile(int? provider, WebMediaType mediatype, WebFileType filetype, string id, int offset) { try { string path = GetPathList(provider, mediatype, filetype, id).ElementAt(offset); WebFileInfo info = GetFileInfo(provider, mediatype, filetype, id, offset); // first try to read the file if (info.IsLocalFile && File.Exists(path)) { return new FileStream(path, FileMode.Open, FileAccess.Read); } // maybe the plugin has some magic if (!info.IsLocalFile && info.Exists && !info.OnNetworkDrive) { return GetLibrary(provider, mediatype).GetFile(path); } // try to load it from a network drive if (info.OnNetworkDrive && info.Exists) { using (NetworkShareImpersonator impersonator = new NetworkShareImpersonator()) { return new FileStream(path, FileMode.Open, FileAccess.Read); } } // fail Log.Warn("Requested non-existing or non-accessible file mediatype={0} filetype={1} id={2} offset={3}", mediatype, filetype, id, offset); WCFUtil.SetResponseCode(System.Net.HttpStatusCode.NotFound); return Stream.Null; } catch (Exception ex) { Log.Info("Failed to retrieve file for mediatype=" + mediatype + ", filetype=" + filetype + ", id=" + id + " and offset=" + offset, ex); WCFUtil.SetResponseCode(System.Net.HttpStatusCode.InternalServerError); return Stream.Null; } }
public WebBoolResult IsLocalFile(int? provider, WebMediaType mediatype, WebFileType filetype, string id, int offset) { WebFileInfo info = GetFileInfo(provider, mediatype, filetype, id, offset); return info.Exists && info.IsLocalFile; }
public static ActionResult ReturnFromService(WebMediaType mediaType, string id, WebFileType artworkType, string defaultFile = null) { return ReturnFromService(mediaType, id, artworkType, 0, 0, defaultFile); }
public ImageMediaSource(WebMediaType type, int? provider, string id, WebFileType filetype, int offset) : base(type, provider, id, filetype, offset) { }
public WebIntResult GetFilterValuesCount(int? provider, WebMediaType mediaType, string filterField, string op = null, int? limit = null) { return GetFilterValues(provider, mediaType, filterField, op, limit).Count(); }
public MediaSource(WebMediaType type, int? provider, string id) : this(type, provider, id, WebFileType.Content, 0) { }
/// <summary> /// Get all available values for a given field /// </summary> public IList<string> GetFilterValues(int? provider, WebMediaType mediaType, string filterField, string op, int? limit, WebSortOrder? order = WebSortOrder.Asc) { switch (mediaType) { case WebMediaType.Drive: return AutoSuggestion.GetValuesForField(filterField, GetFileSystemDrives(provider), op, limit).OrderBy(x => x, order).ToList(); case WebMediaType.Movie: return AutoSuggestion.GetValuesForField(filterField, GetMoviesDetailed(provider), op, limit).OrderBy(x => x, order).ToList(); case WebMediaType.MusicAlbum: return AutoSuggestion.GetValuesForField(filterField, GetMusicAlbumsBasic(provider), op, limit).OrderBy(x => x, order).ToList(); case WebMediaType.MusicArtist: return AutoSuggestion.GetValuesForField(filterField, GetMusicArtistsDetailed(provider), op, limit).OrderBy(x => x, order).ToList(); case WebMediaType.MusicTrack: return AutoSuggestion.GetValuesForField(filterField, GetMusicTracksDetailed(provider), op, limit).OrderBy(x => x, order).ToList(); case WebMediaType.Picture: return AutoSuggestion.GetValuesForField(filterField, GetPicturesDetailed(provider), op, limit).OrderBy(x => x, order).ToList(); case WebMediaType.Playlist: return AutoSuggestion.GetValuesForField(filterField, GetPlaylists(provider), op, limit).OrderBy(x => x, order).ToList(); case WebMediaType.TVEpisode: return AutoSuggestion.GetValuesForField(filterField, GetTVEpisodesDetailed(provider), op, limit).OrderBy(x => x, order).ToList(); case WebMediaType.TVShow: return AutoSuggestion.GetValuesForField(filterField, GetTVShowsDetailed(provider), op, limit).OrderBy(x => x, order).ToList(); default: Log.Info("GetFilterValues() called with unsupported mediaType='{0}' filterField='{1}' op='{2}' limit='{3}'", mediaType, filterField, op, limit); throw new ArgumentException("Unsupported MediaType for GetFilterValues()"); } }
public WebFileInfo GetFileInfo(int? provider, WebMediaType mediatype, WebFileType filetype, string id, int offset) { string path = ""; try { path = GetPathList(provider, mediatype, filetype, id).ElementAt(offset); WebFileInfo retVal = null; bool tryImpersonation = false; try { // first try it the usual way retVal = GetLibrary(provider, mediatype).GetFileInfo(path).Finalize(provider, mediatype); tryImpersonation = retVal == null || !retVal.Exists; } catch (UnauthorizedAccessException) { // access denied, try impersonation tryImpersonation = true; } if (tryImpersonation && new Uri(path).IsUnc && !FileUtil.IsAccessible(path)) { using (var impersonator = new NetworkShareImpersonator()) { retVal = new WebFileInfo(path); retVal.IsLocalFile = Configuration.Services.NetworkImpersonation.ReadInStreamingService; retVal.OnNetworkDrive = true; } } // Make sure to always the path property, even if the file doesn't exist. This makes debugging a lot easier, as you get actual paths in your logs now. retVal.Path = path; return retVal; } catch (ArgumentOutOfRangeException) { Log.Info("Cannot resolve mediatype={0}, filetype={1}, provider={2}, id={3}, offset={4}", mediatype, filetype, provider, id, offset); } catch (FileNotFoundException) { Log.Info("Failed to load fileinfo for non-existing file mediatype={0}, filetype={1}, provider={5}, id={2}, offset={3} (resulting in path={4})", mediatype, filetype, id, offset, path, provider); } catch (Exception ex) { Log.Info(String.Format("Failed to load fileinfo for mediatype={0}, filetype={1}, provider={5}, id={2}, offset={3} (resulting in path={4})", mediatype, filetype, id, offset, path, provider), ex); } return new WebFileInfo() { Exists = false, Path = String.IsNullOrWhiteSpace(path) ? null : path }; }
public WebDictionary<string> GetExternalMediaInfo(int? provider, WebMediaType type, string id) { return GetLibrary(provider, type).GetExternalMediaInfo(type, id); }
/// <summary> /// Return external media info for recording /// </summary> /// <param name="type">Type of item</param> /// <param name="id">Id of recording</param> /// <returns>A dictionary object that can be sent to e.g. WifiRemote</returns> public WebDictionary<string> GetExternalMediaInfo(WebMediaType? type, string id) { if (type == WebMediaType.Recording) { return new WebDictionary<string>() { { "Type", "mp recording" }, { "Id", id } }; } else if (type == WebMediaType.TV) { return new WebDictionary<string>() { { "Type", "mp tvchannel" }, { "Id", id } }; } return null; }
public WebMediaItem GetMediaItem(int? provider, WebMediaType type, string id) { switch (type) { case WebMediaType.Movie: return GetMovieDetailedById(provider, id).Finalize(provider, ProviderType.Movie).ToWebMediaItem(); case WebMediaType.MusicTrack: return GetMusicTrackDetailedById(provider, id).Finalize(provider, ProviderType.Music).ToWebMediaItem(); case WebMediaType.Picture: return GetPictureDetailedById(provider, id).Finalize(provider, ProviderType.Picture).ToWebMediaItem(); case WebMediaType.TVEpisode: return GetTVEpisodeDetailedById(provider, id).Finalize(provider, ProviderType.TVShow).ToWebMediaItem(); case WebMediaType.Drive: return GetFileSystemDriveBasicById(provider, id).Finalize(provider, ProviderType.Filesystem).ToWebMediaItem(); case WebMediaType.Folder: return GetFileSystemFolderBasicById(provider, id).Finalize(provider, ProviderType.Filesystem).ToWebMediaItem(); case WebMediaType.File: return GetFileSystemFileBasicById(provider, id).Finalize(provider, ProviderType.Filesystem).ToWebMediaItem(); default: throw new ArgumentException(); } }
protected override bool CheckArguments(WebMediaType mediatype, WebFileType filetype) { if ((mediatype == WebMediaType.TV || mediatype == WebMediaType.Recording) && filetype == WebFileType.Logo) return true; return base.CheckArguments(mediatype, filetype); }
public IList<string> GetPathList(int? provider, WebMediaType mediatype, WebFileType filetype, string id) { if (mediatype == WebMediaType.File && filetype == WebFileType.Content) return FileSystemLibraries[provider].GetFileBasic(id).Path; else if (mediatype == WebMediaType.Movie && filetype == WebFileType.Content) return MovieLibraries[provider].GetMovieDetailedById(id).Path; else if (mediatype == WebMediaType.Movie && filetype == WebFileType.Backdrop) return MovieLibraries[provider].GetMovieDetailedById(id).Artwork.Where(x => x.Type == WebFileType.Backdrop).Select(x => ((WebArtworkDetailed)x).Path).ToList(); else if (mediatype == WebMediaType.Movie && filetype == WebFileType.Cover) return MovieLibraries[provider].GetMovieDetailedById(id).Artwork.Where(x => x.Type == WebFileType.Cover).Select(x => ((WebArtworkDetailed)x).Path).ToList(); else if (mediatype == WebMediaType.TVShow && filetype == WebFileType.Banner) return TVShowLibraries[provider].GetTVShowDetailed(id).Artwork.Where(x => x.Type == WebFileType.Banner).Select(x => ((WebArtworkDetailed)x).Path).ToList(); else if (mediatype == WebMediaType.TVShow && filetype == WebFileType.Backdrop) return TVShowLibraries[provider].GetTVShowDetailed(id).Artwork.Where(x => x.Type == WebFileType.Backdrop).Select(x => ((WebArtworkDetailed)x).Path).ToList(); else if (mediatype == WebMediaType.TVShow && filetype == WebFileType.Poster) return TVShowLibraries[provider].GetTVShowDetailed(id).Artwork.Where(x => x.Type == WebFileType.Poster).Select(x => ((WebArtworkDetailed)x).Path).ToList(); else if (mediatype == WebMediaType.TVSeason && filetype == WebFileType.Backdrop) return TVShowLibraries[provider].GetSeasonDetailed(id).Artwork.Where(x => x.Type == WebFileType.Backdrop).Select(x => ((WebArtworkDetailed)x).Path).ToList(); else if (mediatype == WebMediaType.TVSeason && filetype == WebFileType.Banner) return TVShowLibraries[provider].GetSeasonDetailed(id).Artwork.Where(x => x.Type == WebFileType.Banner).Select(x => ((WebArtworkDetailed)x).Path).ToList(); else if (mediatype == WebMediaType.TVSeason && filetype == WebFileType.Poster) return TVShowLibraries[provider].GetSeasonDetailed(id).Artwork.Where(x => x.Type == WebFileType.Poster).Select(x => ((WebArtworkDetailed)x).Path).ToList(); else if (mediatype == WebMediaType.TVEpisode && filetype == WebFileType.Content) return TVShowLibraries[provider].GetEpisodeBasic(id).Path; else if (mediatype == WebMediaType.TVEpisode && filetype == WebFileType.Banner) return TVShowLibraries[provider].GetEpisodeDetailed(id).Artwork.Where(x => x.Type == WebFileType.Banner).Select(x => ((WebArtworkDetailed)x).Path).ToList(); else if (mediatype == WebMediaType.Picture && filetype == WebFileType.Content) return PictureLibraries[provider].GetPictureDetailed(id).Path; else if (mediatype == WebMediaType.MusicArtist && filetype == WebFileType.Cover) return MusicLibraries[provider].GetArtistBasicById(id).Artwork.Where(x => x.Type == WebFileType.Cover).Select(x => ((WebArtworkDetailed)x).Path).ToList(); else if (mediatype == WebMediaType.MusicAlbum && filetype == WebFileType.Cover) return MusicLibraries[provider].GetAlbumBasicById(id).Artwork.Where(x => x.Type == WebFileType.Cover).Select(x => ((WebArtworkDetailed)x).Path).ToList(); else if (mediatype == WebMediaType.MusicTrack && filetype == WebFileType.Cover) return MusicLibraries[provider].GetTrackBasicById(id).Artwork.Where(x => x.Type == WebFileType.Cover).Select(x => ((WebArtworkDetailed)x).Path).ToList(); else if (mediatype == WebMediaType.MusicTrack && filetype == WebFileType.Content) return MusicLibraries[provider].GetTrackBasicById(id).Path; Log.Warn("Invalid combination of filetype {0} and mediatype {1} requested", filetype, mediatype); return null; }
public IList<string> GetFilterValuesByRange(int? provider, int start, int end, WebMediaType mediaType, string filterField, string op = null, int? limit = null, WebSortOrder? order = WebSortOrder.Asc) { return GetFilterValues(provider, mediaType, filterField, op, limit, order).TakeRange(start, end).ToList(); }
public WebDictionary<string> GetExternalMediaInfo(WebMediaType type, string id) { string path = GetPath(id); return new WebDictionary<string>() { { "Type", File.Exists(path) ? "file" : "folder" }, { "Path", path }, { "Extensions", String.Join("|", GetShare(id).Extensions) } }; }