diff --git a/MediaBrowser.Controller/Entities/IHasOriginalTitle.cs b/MediaBrowser.Controller/Entities/IHasOriginalTitle.cs new file mode 100644 index 0000000000..6f5cb59bc0 --- /dev/null +++ b/MediaBrowser.Controller/Entities/IHasOriginalTitle.cs @@ -0,0 +1,8 @@ + +namespace MediaBrowser.Controller.Entities +{ + public interface IHasOriginalTitle + { + string OriginalTitle { get; set; } + } +} diff --git a/MediaBrowser.Controller/Entities/Movies/Movie.cs b/MediaBrowser.Controller/Entities/Movies/Movie.cs index cfe008bd7c..4110047821 100644 --- a/MediaBrowser.Controller/Entities/Movies/Movie.cs +++ b/MediaBrowser.Controller/Entities/Movies/Movie.cs @@ -6,7 +6,6 @@ using System; using System.Collections.Generic; using System.IO; using System.Linq; -using System.Runtime.Serialization; using System.Threading; using System.Threading.Tasks; @@ -15,10 +14,11 @@ namespace MediaBrowser.Controller.Entities.Movies /// /// Class Movie /// - public class Movie : Video, IHasCriticRating, IHasSoundtracks, IHasSpecialFeatures, IHasProductionLocations, IHasBudget, IHasKeywords, IHasTrailers, IHasThemeMedia, IHasTaglines, IHasAwards, IHasMetascore, IHasLookupInfo, ISupportsBoxSetGrouping + public class Movie : Video, IHasCriticRating, IHasSoundtracks, IHasSpecialFeatures, IHasProductionLocations, IHasBudget, IHasKeywords, IHasTrailers, IHasThemeMedia, IHasTaglines, IHasAwards, IHasMetascore, IHasLookupInfo, ISupportsBoxSetGrouping, IHasOriginalTitle { public List SpecialFeatureIds { get; set; } + public string OriginalTitle { get; set; } public List SoundtrackIds { get; set; } public List ThemeSongIds { get; set; } diff --git a/MediaBrowser.Controller/Entities/TV/Series.cs b/MediaBrowser.Controller/Entities/TV/Series.cs index 4c34460d7c..2b3674e806 100644 --- a/MediaBrowser.Controller/Entities/TV/Series.cs +++ b/MediaBrowser.Controller/Entities/TV/Series.cs @@ -15,11 +15,12 @@ namespace MediaBrowser.Controller.Entities.TV /// /// Class Series /// - public class Series : Folder, IHasSoundtracks, IHasTrailers, IHasDisplayOrder, IHasLookupInfo, IHasSpecialFeatures, IMetadataContainer + public class Series : Folder, IHasSoundtracks, IHasTrailers, IHasDisplayOrder, IHasLookupInfo, IHasSpecialFeatures, IMetadataContainer, IHasOriginalTitle { public List SpecialFeatureIds { get; set; } public List SoundtrackIds { get; set; } + public string OriginalTitle { get; set; } public int SeasonCount { get; set; } public int? AnimeSeriesIndex { get; set; } diff --git a/MediaBrowser.Controller/MediaBrowser.Controller.csproj b/MediaBrowser.Controller/MediaBrowser.Controller.csproj index 72b9bfe9e6..314b981d52 100644 --- a/MediaBrowser.Controller/MediaBrowser.Controller.csproj +++ b/MediaBrowser.Controller/MediaBrowser.Controller.csproj @@ -139,6 +139,7 @@ + diff --git a/MediaBrowser.Controller/Providers/BaseItemXmlParser.cs b/MediaBrowser.Controller/Providers/BaseItemXmlParser.cs index ddd650e3e1..6facc1074a 100644 --- a/MediaBrowser.Controller/Providers/BaseItemXmlParser.cs +++ b/MediaBrowser.Controller/Providers/BaseItemXmlParser.cs @@ -126,6 +126,21 @@ namespace MediaBrowser.Controller.Providers break; } + case "OriginalTitle": + { + var val = reader.ReadElementContentAsString(); + + var hasOriginalTitle = item as IHasOriginalTitle; + if (hasOriginalTitle != null) + { + if (!string.IsNullOrEmpty(hasOriginalTitle.OriginalTitle)) + { + hasOriginalTitle.OriginalTitle = val; + } + } + break; + } + case "LocalTitle": item.Name = reader.ReadElementContentAsString(); break; diff --git a/MediaBrowser.LocalMetadata/Savers/XmlSaverHelpers.cs b/MediaBrowser.LocalMetadata/Savers/XmlSaverHelpers.cs index 9818338030..c59d574bf4 100644 --- a/MediaBrowser.LocalMetadata/Savers/XmlSaverHelpers.cs +++ b/MediaBrowser.LocalMetadata/Savers/XmlSaverHelpers.cs @@ -57,6 +57,7 @@ namespace MediaBrowser.LocalMetadata.Savers "Language", "LocalTitle", + "OriginalTitle", "LockData", "LockedFields", "Format3D", @@ -273,6 +274,15 @@ namespace MediaBrowser.LocalMetadata.Savers { builder.Append(""); } + + var hasOriginalTitle = item as IHasOriginalTitle; + if (hasOriginalTitle != null) + { + if (!string.IsNullOrEmpty(hasOriginalTitle.OriginalTitle)) + { + builder.Append("" + SecurityElement.Escape(hasOriginalTitle.OriginalTitle) + ""); + } + } var hasShortOverview = item as IHasShortOverview; if (hasShortOverview != null) diff --git a/MediaBrowser.Providers/Movies/GenericMovieDbInfo.cs b/MediaBrowser.Providers/Movies/GenericMovieDbInfo.cs index 87b2290909..68cbf85e9d 100644 --- a/MediaBrowser.Providers/Movies/GenericMovieDbInfo.cs +++ b/MediaBrowser.Providers/Movies/GenericMovieDbInfo.cs @@ -111,7 +111,13 @@ namespace MediaBrowser.Providers.Movies /// The movie data. private void ProcessMainInfo(T movie, string preferredCountryCode, MovieDbProvider.CompleteMovieData movieData) { - movie.Name = movieData.title ?? movieData.original_title ?? movieData.name ?? movie.Name; + movie.Name = movieData.GetTitle() ?? movie.Name; + + var hasOriginalTitle = movie as IHasOriginalTitle; + if (hasOriginalTitle != null) + { + hasOriginalTitle.OriginalTitle = movieData.GetOriginalTitle(); + } // Bug in Mono: WebUtility.HtmlDecode should return null if the string is null but in Mono it generate an System.ArgumentNullException. movie.Overview = movieData.overview != null ? WebUtility.HtmlDecode(movieData.overview) : null; diff --git a/MediaBrowser.Providers/Movies/MovieDbProvider.cs b/MediaBrowser.Providers/Movies/MovieDbProvider.cs index ed15a2eeff..b8f9a7fa28 100644 --- a/MediaBrowser.Providers/Movies/MovieDbProvider.cs +++ b/MediaBrowser.Providers/Movies/MovieDbProvider.cs @@ -77,7 +77,7 @@ namespace MediaBrowser.Providers.Movies var remoteResult = new RemoteSearchResult { - Name = obj.title ?? obj.original_title ?? obj.name, + Name = obj.GetTitle(), SearchProviderName = Name, ImageUrl = string.IsNullOrWhiteSpace(obj.poster_path) ? null : tmdbImageUrl + obj.poster_path }; @@ -560,6 +560,7 @@ namespace MediaBrowser.Providers.Movies public int id { get; set; } public string imdb_id { get; set; } public string original_title { get; set; } + public string original_name { get; set; } public string overview { get; set; } public double popularity { get; set; } public string poster_path { get; set; } @@ -580,6 +581,16 @@ namespace MediaBrowser.Providers.Movies public Images images { get; set; } public Keywords keywords { get; set; } public Trailers trailers { get; set; } + + public string GetOriginalTitle() + { + return original_name ?? original_title; + } + + public string GetTitle() + { + return name ?? title ?? GetOriginalTitle(); + } } public int Order diff --git a/MediaBrowser.Providers/Movies/MovieDbSearch.cs b/MediaBrowser.Providers/Movies/MovieDbSearch.cs index f1a4d7bba7..8a59d7a1b2 100644 --- a/MediaBrowser.Providers/Movies/MovieDbSearch.cs +++ b/MediaBrowser.Providers/Movies/MovieDbSearch.cs @@ -147,7 +147,7 @@ namespace MediaBrowser.Providers.Movies var remoteResult = new RemoteSearchResult { SearchProviderName = MovieDbProvider.Current.Name, - Name = i.title ?? i.original_title ?? i.name, + Name = i.title ?? i.name ?? i.original_title, ImageUrl = string.IsNullOrWhiteSpace(i.poster_path) ? null : baseImageUrl + i.poster_path }; @@ -215,6 +215,11 @@ namespace MediaBrowser.Providers.Movies /// The original_title. public string original_title { get; set; } /// + /// Gets or sets the original_name. + /// + /// The original_name. + public string original_name { get; set; } + /// /// Gets or sets the release_date. /// /// The release_date. diff --git a/MediaBrowser.XbmcMetadata/Parsers/BaseNfoParser.cs b/MediaBrowser.XbmcMetadata/Parsers/BaseNfoParser.cs index 66efd7c780..682175f793 100644 --- a/MediaBrowser.XbmcMetadata/Parsers/BaseNfoParser.cs +++ b/MediaBrowser.XbmcMetadata/Parsers/BaseNfoParser.cs @@ -193,6 +193,21 @@ namespace MediaBrowser.XbmcMetadata.Parsers break; } + case "originaltitle": + { + var val = reader.ReadElementContentAsString(); + + var hasOriginalTitle = item as IHasOriginalTitle; + if (hasOriginalTitle != null) + { + if (!string.IsNullOrEmpty(hasOriginalTitle.OriginalTitle)) + { + hasOriginalTitle.OriginalTitle = val; + } + } + break; + } + case "title": case "localtitle": item.Name = reader.ReadElementContentAsString(); diff --git a/MediaBrowser.XbmcMetadata/Savers/BaseNfoSaver.cs b/MediaBrowser.XbmcMetadata/Savers/BaseNfoSaver.cs index 13108a486e..3224f36bc6 100644 --- a/MediaBrowser.XbmcMetadata/Savers/BaseNfoSaver.cs +++ b/MediaBrowser.XbmcMetadata/Savers/BaseNfoSaver.cs @@ -459,6 +459,15 @@ namespace MediaBrowser.XbmcMetadata.Savers writer.WriteElementString("title", item.Name ?? string.Empty); writer.WriteElementString("originaltitle", item.Name ?? string.Empty); + var hasOriginalTitle = item as IHasOriginalTitle; + if (hasOriginalTitle != null) + { + if (!string.IsNullOrEmpty(hasOriginalTitle.OriginalTitle)) + { + writer.WriteElementString("originaltitle", hasOriginalTitle.OriginalTitle ?? string.Empty); + } + } + var directors = item.People .Where(i => IsPersonType(i, PersonType.Director)) .Select(i => i.Name)