diff options
| author | Luke Pulverenti <luke.pulverenti@gmail.com> | 2013-10-04 13:04:18 -0400 |
|---|---|---|
| committer | Luke Pulverenti <luke.pulverenti@gmail.com> | 2013-10-04 13:04:18 -0400 |
| commit | fe2eb6cb01564662df01aef87afe2bff51971c1b (patch) | |
| tree | 60fa3d02315405f75e2ef14c53d4e37aeead0c38 /MediaBrowser.Server.Implementations/Library/LibraryManager.cs | |
| parent | cbbb98416084f80ae4e311b69a63f59139584688 (diff) | |
fixes #573 - Support media info for intros
Diffstat (limited to 'MediaBrowser.Server.Implementations/Library/LibraryManager.cs')
| -rw-r--r-- | MediaBrowser.Server.Implementations/Library/LibraryManager.cs | 70 |
1 files changed, 68 insertions, 2 deletions
diff --git a/MediaBrowser.Server.Implementations/Library/LibraryManager.cs b/MediaBrowser.Server.Implementations/Library/LibraryManager.cs index d54bb94de..e9c824198 100644 --- a/MediaBrowser.Server.Implementations/Library/LibraryManager.cs +++ b/MediaBrowser.Server.Implementations/Library/LibraryManager.cs @@ -1129,9 +1129,75 @@ namespace MediaBrowser.Server.Implementations.Library /// <param name="item">The item.</param> /// <param name="user">The user.</param> /// <returns>IEnumerable{System.String}.</returns> - public IEnumerable<string> GetIntros(BaseItem item, User user) + public IEnumerable<Video> GetIntros(BaseItem item, User user) { - return IntroProviders.SelectMany(i => i.GetIntros(item, user)); + return IntroProviders.SelectMany(i => i.GetIntros(item, user)) + .Select(ResolveIntro) + .Where(i => i != null); + } + + /// <summary> + /// Gets all intro files. + /// </summary> + /// <returns>IEnumerable{System.String}.</returns> + public IEnumerable<string> GetAllIntroFiles() + { + return IntroProviders.SelectMany(i => i.GetAllIntroFiles()); + } + + /// <summary> + /// Resolves the intro. + /// </summary> + /// <param name="info">The info.</param> + /// <returns>Video.</returns> + private Video ResolveIntro(IntroInfo info) + { + Video video = null; + + if (info.ItemId.HasValue) + { + // Get an existing item by Id + video = GetItemById(info.ItemId.Value) as Video; + + if (video == null) + { + _logger.Error("Unable to locate item with Id {0}.", info.ItemId.Value); + } + } + else if (!string.IsNullOrEmpty(info.Path)) + { + try + { + // Try to resolve the path into a video + video = ResolvePath(FileSystem.GetFileSystemInfo(info.Path)) as Video; + + if (video == null) + { + _logger.Error("Intro resolver returned null for {0}.", info.Path); + } + else + { + // Pull the saved db item that will include metadata + var dbItem = GetItemById(video.Id) as Video; + + if (dbItem != null) + { + dbItem.ResetResolveArgs(video.ResolveArgs); + video = dbItem; + } + } + } + catch (Exception ex) + { + _logger.ErrorException("Error resolving path {0}.", ex, info.Path); + } + } + else + { + _logger.Error("IntroProvider returned an IntroInfo with null Path and ItemId."); + } + + return video; } /// <summary> |
