From 1ddc193e588f6231c327a769b580f48cba03a77f Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Thu, 6 Jun 2013 10:33:11 -0400 Subject: [PATCH] support xbmc naming convention for subtitles --- MediaBrowser.Api/LocalizationService.cs | 53 +++++---------- .../Localization/ILocalizationManager.cs | 28 ++++++++ .../MediaBrowser.Controller.csproj | 1 + .../MediaInfo/FFProbeVideoInfoProvider.cs | 57 ++++++++++++---- .../Localization/LocalizationManager.cs | 65 +++++++++++++++++++ ...MediaBrowser.Server.Implementations.csproj | 1 + .../ApplicationHost.cs | 4 ++ 7 files changed, 160 insertions(+), 49 deletions(-) create mode 100644 MediaBrowser.Controller/Localization/ILocalizationManager.cs create mode 100644 MediaBrowser.Server.Implementations/Localization/LocalizationManager.cs diff --git a/MediaBrowser.Api/LocalizationService.cs b/MediaBrowser.Api/LocalizationService.cs index aa01f3f13..d52f94b3c 100644 --- a/MediaBrowser.Api/LocalizationService.cs +++ b/MediaBrowser.Api/LocalizationService.cs @@ -1,10 +1,8 @@ using MediaBrowser.Controller.Localization; using MediaBrowser.Model.Entities; using MediaBrowser.Model.Globalization; -using MoreLinq; using ServiceStack.ServiceHost; using System.Collections.Generic; -using System.Globalization; using System.Linq; namespace MediaBrowser.Api @@ -41,6 +39,20 @@ namespace MediaBrowser.Api /// public class LocalizationService : BaseApiService { + /// + /// The _localization + /// + private readonly ILocalizationManager _localization; + + /// + /// Initializes a new instance of the class. + /// + /// The localization. + public LocalizationService(ILocalizationManager localization) + { + _localization = localization; + } + /// /// Gets the specified request. /// @@ -48,10 +60,7 @@ namespace MediaBrowser.Api /// System.Object. public object Get(GetParentalRatings request) { - var ratings = - Ratings.RatingsDict.Select(k => new ParentalRating { Name = k.Key, Value = k.Value }); - - var result = ratings.OrderBy(p => p.Value).Where(p => p.Value > 0).ToList(); + var result = _localization.GetParentalRatings().ToList(); return ToOptimizedResult(result); } @@ -63,22 +72,7 @@ namespace MediaBrowser.Api /// System.Object. public object Get(GetCountries request) { - var result = CultureInfo.GetCultures(CultureTypes.SpecificCultures) - - .Select(c => new RegionInfo(c.LCID)) - .OrderBy(c => c.DisplayName) - - // Try to eliminate dupes - .DistinctBy(c => c.TwoLetterISORegionName) - - .Select(c => new CountryInfo - { - Name = c.Name, - DisplayName = c.DisplayName, - TwoLetterISORegionName = c.TwoLetterISORegionName, - ThreeLetterISORegionName = c.ThreeLetterISORegionName - }) - .ToList(); + var result = _localization.GetCountries().ToList(); return ToOptimizedResult(result); } @@ -90,20 +84,7 @@ namespace MediaBrowser.Api /// System.Object. public object Get(GetCultures request) { - var result = CultureInfo.GetCultures(CultureTypes.AllCultures) - .OrderBy(c => c.DisplayName) - - // Try to eliminate dupes - .DistinctBy(c => c.TwoLetterISOLanguageName + c.ThreeLetterISOLanguageName) - - .Select(c => new CultureDto - { - Name = c.Name, - DisplayName = c.DisplayName, - ThreeLetterISOLanguageName = c.ThreeLetterISOLanguageName, - TwoLetterISOLanguageName = c.TwoLetterISOLanguageName - }) - .ToList(); + var result = _localization.GetCultures().ToList(); return ToOptimizedResult(result); } diff --git a/MediaBrowser.Controller/Localization/ILocalizationManager.cs b/MediaBrowser.Controller/Localization/ILocalizationManager.cs new file mode 100644 index 000000000..487c4a48e --- /dev/null +++ b/MediaBrowser.Controller/Localization/ILocalizationManager.cs @@ -0,0 +1,28 @@ +using MediaBrowser.Model.Entities; +using MediaBrowser.Model.Globalization; +using System.Collections.Generic; + +namespace MediaBrowser.Controller.Localization +{ + /// + /// Interface ILocalizationManager + /// + public interface ILocalizationManager + { + /// + /// Gets the cultures. + /// + /// IEnumerable{CultureDto}. + IEnumerable GetCultures(); + /// + /// Gets the countries. + /// + /// IEnumerable{CountryInfo}. + IEnumerable GetCountries(); + /// + /// Gets the parental ratings. + /// + /// IEnumerable{ParentalRating}. + IEnumerable GetParentalRatings(); + } +} diff --git a/MediaBrowser.Controller/MediaBrowser.Controller.csproj b/MediaBrowser.Controller/MediaBrowser.Controller.csproj index cdcc45622..04e0a31ac 100644 --- a/MediaBrowser.Controller/MediaBrowser.Controller.csproj +++ b/MediaBrowser.Controller/MediaBrowser.Controller.csproj @@ -76,6 +76,7 @@ + diff --git a/MediaBrowser.Controller/Providers/MediaInfo/FFProbeVideoInfoProvider.cs b/MediaBrowser.Controller/Providers/MediaInfo/FFProbeVideoInfoProvider.cs index c95f0771f..91fd29b24 100644 --- a/MediaBrowser.Controller/Providers/MediaInfo/FFProbeVideoInfoProvider.cs +++ b/MediaBrowser.Controller/Providers/MediaInfo/FFProbeVideoInfoProvider.cs @@ -3,6 +3,7 @@ using MediaBrowser.Common.MediaInfo; using MediaBrowser.Controller.Configuration; using MediaBrowser.Controller.Entities; using MediaBrowser.Controller.Entities.Movies; +using MediaBrowser.Controller.Localization; using MediaBrowser.Model.Entities; using MediaBrowser.Model.Logging; using MediaBrowser.Model.MediaInfo; @@ -21,7 +22,7 @@ namespace MediaBrowser.Controller.Providers.MediaInfo /// public class FFProbeVideoInfoProvider : BaseFFProbeProvider