From c21c2f85181f47cabf5ef4dc5a63acd0346ccd04 Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Thu, 30 May 2013 14:19:30 -0400 Subject: [PATCH] support plex/xbmc theme song convention --- MediaBrowser.Controller/Entities/BaseItem.cs | 28 +++++++++++--------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/MediaBrowser.Controller/Entities/BaseItem.cs b/MediaBrowser.Controller/Entities/BaseItem.cs index 4bd1b1aba..de272ca64 100644 --- a/MediaBrowser.Controller/Entities/BaseItem.cs +++ b/MediaBrowser.Controller/Entities/BaseItem.cs @@ -798,25 +798,27 @@ namespace MediaBrowser.Controller.Entities return new List(); } + var files = new List(); + var folder = resolveArgs.GetFileSystemEntryByName(ThemeSongsFolderName); // Path doesn't exist. No biggie - if (folder == null) + if (folder != null) { - return new List(); + try + { + files.AddRange(new DirectoryInfo(folder.FullName).EnumerateFiles()); + } + catch (IOException ex) + { + Logger.ErrorException("Error loading theme songs for {0}", ex, Name); + } } - IEnumerable files; - - try - { - files = new DirectoryInfo(folder.FullName).EnumerateFiles(); - } - catch (IOException ex) - { - Logger.ErrorException("Error loading theme songs for {0}", ex, Name); - return new List(); - } + // Support plex/xbmc convention + files.AddRange(resolveArgs.FileSystemChildren + .Where(i => string.Equals(System.IO.Path.GetFileNameWithoutExtension(i.FullName), "theme", StringComparison.OrdinalIgnoreCase) && EntityResolutionHelper.IsAudioFile(i.FullName)) + ); return LibraryManager.ResolvePaths(files, null).Select(audio => {