From d6cf7b51acda145d32c9944f1b66728c7e09a9f8 Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Sun, 23 Jun 2013 13:48:30 -0400 Subject: added movie, series, folder and episode xml saving support --- .../Providers/BaseItemXmlParser.cs | 37 ++++++++++++++++------ .../Providers/IProviderManager.cs | 19 +++++++++-- 2 files changed, 45 insertions(+), 11 deletions(-) (limited to 'MediaBrowser.Controller/Providers') diff --git a/MediaBrowser.Controller/Providers/BaseItemXmlParser.cs b/MediaBrowser.Controller/Providers/BaseItemXmlParser.cs index 645987437..d06c89a01 100644 --- a/MediaBrowser.Controller/Providers/BaseItemXmlParser.cs +++ b/MediaBrowser.Controller/Providers/BaseItemXmlParser.cs @@ -89,7 +89,7 @@ namespace MediaBrowser.Controller.Providers } private readonly CultureInfo _usCulture = new CultureInfo("en-US"); - + /// /// Fetches metadata from one Xml Element /// @@ -205,6 +205,17 @@ namespace MediaBrowser.Controller.Providers break; } + case "MPAADescription": + { + var rating = reader.ReadElementContentAsString(); + + if (!string.IsNullOrWhiteSpace(rating)) + { + item.OfficialRatingDescription = rating; + } + break; + } + case "CustomRating": { var val = reader.ReadElementContentAsString(); @@ -306,7 +317,7 @@ namespace MediaBrowser.Controller.Providers { var actors = reader.ReadInnerXml(); - + if (actors.Contains("<")) { // This is one of the mis-named "Actors" full nodes created by MB2 @@ -378,7 +389,7 @@ namespace MediaBrowser.Controller.Providers { float val; // All external meta is saving this as '.' for decimal I believe...but just to be sure - if (float.TryParse(rating.Replace(',','.'), NumberStyles.AllowDecimalPoint, CultureInfo.InvariantCulture, out val)) + if (float.TryParse(rating.Replace(',', '.'), NumberStyles.AllowDecimalPoint, CultureInfo.InvariantCulture, out val)) { item.CommunityRating = val; } @@ -412,6 +423,14 @@ namespace MediaBrowser.Controller.Providers } break; + case "CollectionNumber": + var tmdbCollection = reader.ReadElementContentAsString(); + if (!string.IsNullOrWhiteSpace(tmdbCollection)) + { + item.SetProviderId(MetadataProviders.TmdbCollection, tmdbCollection); + } + break; + case "TVcomId": var TVcomId = reader.ReadElementContentAsString(); if (!string.IsNullOrWhiteSpace(TVcomId)) @@ -602,8 +621,8 @@ namespace MediaBrowser.Controller.Providers { switch (reader.Name) { - // Removed support for "Value" tag as it conflicted with MPAA rating but leaving this function for possible - // future support of "Description" -ebr + // Removed support for "Value" tag as it conflicted with MPAA rating but leaving this function for possible + // future support of "Description" -ebr default: reader.Skip(); @@ -679,7 +698,7 @@ namespace MediaBrowser.Controller.Providers // Only split by comma if there is no pipe in the string // We have to be careful to not split names like Matthew, Jr. - var separator = value.IndexOf('|') == -1 ? ',' : '|'; + var separator = value.IndexOf('|') == -1 && value.IndexOf(';') == -1 ? new[] { ',' } : new[] { '|', ';' }; value = value.Trim().Trim(separator); @@ -690,12 +709,12 @@ namespace MediaBrowser.Controller.Providers /// Provides an additional overload for string.split /// /// The val. - /// The separator. + /// The separators. /// The options. /// System.String[][]. - private static string[] Split(string val, char separator, StringSplitOptions options) + private static string[] Split(string val, char[] separators, StringSplitOptions options) { - return val.Split(new[] { separator }, options); + return val.Split(separators, options); } } diff --git a/MediaBrowser.Controller/Providers/IProviderManager.cs b/MediaBrowser.Controller/Providers/IProviderManager.cs index 99860bac0..7f80973e9 100644 --- a/MediaBrowser.Controller/Providers/IProviderManager.cs +++ b/MediaBrowser.Controller/Providers/IProviderManager.cs @@ -1,4 +1,5 @@ using MediaBrowser.Controller.Entities; +using MediaBrowser.Controller.Library; using System.Collections.Generic; using System.IO; using System.Threading; @@ -6,6 +7,9 @@ using System.Threading.Tasks; namespace MediaBrowser.Controller.Providers { + /// + /// Interface IProviderManager + /// public interface IProviderManager { /// @@ -21,8 +25,17 @@ namespace MediaBrowser.Controller.Providers /// item Task DownloadAndSaveImage(BaseItem item, string source, string targetName, bool saveLocally, SemaphoreSlim resourcePool, CancellationToken cancellationToken); + /// + /// Saves the image. + /// + /// The item. + /// The source. + /// Name of the target. + /// if set to true [save locally]. + /// The cancellation token. + /// Task{System.String}. Task SaveImage(BaseItem item, Stream source, string targetName, bool saveLocally, CancellationToken cancellationToken); - + /// /// Saves to library filesystem. /// @@ -48,7 +61,9 @@ namespace MediaBrowser.Controller.Providers /// Adds the metadata providers. /// /// The providers. - void AddMetadataProviders(IEnumerable providers); + /// The savers. + void AddParts(IEnumerable providers, + IEnumerable savers); /// /// Gets the save path. -- cgit v1.2.3