From f3a7307ebb9a1a484a82563c4cfab6bf461c7631 Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Mon, 20 May 2013 23:16:43 -0400 Subject: reduce requests against tvdb by getting entire series metadata at once --- MediaBrowser.Controller/Library/ILibraryManager.cs | 11 ++++++++--- .../Library/ILibraryPrescanTask.cs | 20 ++++++++++++++++++++ MediaBrowser.Controller/Library/TVUtils.cs | 20 ++++++++++++++++---- 3 files changed, 44 insertions(+), 7 deletions(-) create mode 100644 MediaBrowser.Controller/Library/ILibraryPrescanTask.cs (limited to 'MediaBrowser.Controller/Library') diff --git a/MediaBrowser.Controller/Library/ILibraryManager.cs b/MediaBrowser.Controller/Library/ILibraryManager.cs index 89d17758e..0917fa276 100644 --- a/MediaBrowser.Controller/Library/ILibraryManager.cs +++ b/MediaBrowser.Controller/Library/ILibraryManager.cs @@ -11,6 +11,9 @@ using System.Threading.Tasks; namespace MediaBrowser.Controller.Library { + /// + /// Interface ILibraryManager + /// public interface ILibraryManager { /// @@ -140,11 +143,13 @@ namespace MediaBrowser.Controller.Library /// The resolvers. /// The intro providers. /// The item comparers. + /// The prescan tasks. void AddParts(IEnumerable rules, IEnumerable pluginFolders, IEnumerable resolvers, IEnumerable introProviders, - IEnumerable itemComparers); + IEnumerable itemComparers, + IEnumerable prescanTasks); /// /// Sorts the specified items. @@ -160,7 +165,7 @@ namespace MediaBrowser.Controller.Library /// /// Ensure supplied item has only one instance throughout /// - /// + /// The item. /// The proper instance to the item BaseItem GetOrAddByReferenceItem(BaseItem item); @@ -186,7 +191,7 @@ namespace MediaBrowser.Controller.Library /// The cancellation token. /// Task. Task UpdateItem(BaseItem item, CancellationToken cancellationToken); - + /// /// Retrieves the item. /// diff --git a/MediaBrowser.Controller/Library/ILibraryPrescanTask.cs b/MediaBrowser.Controller/Library/ILibraryPrescanTask.cs new file mode 100644 index 000000000..6a48ba777 --- /dev/null +++ b/MediaBrowser.Controller/Library/ILibraryPrescanTask.cs @@ -0,0 +1,20 @@ +using System; +using System.Threading; +using System.Threading.Tasks; + +namespace MediaBrowser.Controller.Library +{ + /// + /// An interface for tasks that run prior to the media library scan + /// + public interface ILibraryPrescanTask + { + /// + /// Runs the specified progress. + /// + /// The progress. + /// The cancellation token. + /// Task. + Task Run(IProgress progress, CancellationToken cancellationToken); + } +} diff --git a/MediaBrowser.Controller/Library/TVUtils.cs b/MediaBrowser.Controller/Library/TVUtils.cs index 8bd1c270d..6a220c6d7 100644 --- a/MediaBrowser.Controller/Library/TVUtils.cs +++ b/MediaBrowser.Controller/Library/TVUtils.cs @@ -1,7 +1,7 @@ -using System.Globalization; -using MediaBrowser.Controller.Resolvers; +using MediaBrowser.Controller.Resolvers; using System; using System.Collections.Generic; +using System.Globalization; using System.IO; using System.Linq; using System.Text.RegularExpressions; @@ -243,7 +243,7 @@ namespace MediaBrowser.Controller.Library /// /// The full path. /// System.String. - public static string SeasonNumberFromEpisodeFile(string fullPath) + public static int? GetSeasonNumberFromEpisodeFile(string fullPath) { string fl = fullPath.ToLower(); foreach (var r in EpisodeExpressions) @@ -253,7 +253,19 @@ namespace MediaBrowser.Controller.Library { Group g = m.Groups["seasonnumber"]; if (g != null) - return g.Value; + { + var val = g.Value; + + if (!string.IsNullOrWhiteSpace(val)) + { + int num; + + if (int.TryParse(val, NumberStyles.Integer, UsCulture, out num)) + { + return num; + } + } + } return null; } } -- cgit v1.2.3