support storage of original title

This commit is contained in:
Luke Pulverenti 2015-03-09 21:30:20 -04:00
parent 1b46fb62c4
commit 7fdc6e7e91
11 changed files with 87 additions and 6 deletions

View File

@ -0,0 +1,8 @@

namespace MediaBrowser.Controller.Entities
{
public interface IHasOriginalTitle
{
string OriginalTitle { get; set; }
}
}

View File

@ -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
/// <summary>
/// Class Movie
/// </summary>
public class Movie : Video, IHasCriticRating, IHasSoundtracks, IHasSpecialFeatures, IHasProductionLocations, IHasBudget, IHasKeywords, IHasTrailers, IHasThemeMedia, IHasTaglines, IHasAwards, IHasMetascore, IHasLookupInfo<MovieInfo>, ISupportsBoxSetGrouping
public class Movie : Video, IHasCriticRating, IHasSoundtracks, IHasSpecialFeatures, IHasProductionLocations, IHasBudget, IHasKeywords, IHasTrailers, IHasThemeMedia, IHasTaglines, IHasAwards, IHasMetascore, IHasLookupInfo<MovieInfo>, ISupportsBoxSetGrouping, IHasOriginalTitle
{
public List<Guid> SpecialFeatureIds { get; set; }
public string OriginalTitle { get; set; }
public List<Guid> SoundtrackIds { get; set; }
public List<Guid> ThemeSongIds { get; set; }

View File

@ -15,11 +15,12 @@ namespace MediaBrowser.Controller.Entities.TV
/// <summary>
/// Class Series
/// </summary>
public class Series : Folder, IHasSoundtracks, IHasTrailers, IHasDisplayOrder, IHasLookupInfo<SeriesInfo>, IHasSpecialFeatures, IMetadataContainer
public class Series : Folder, IHasSoundtracks, IHasTrailers, IHasDisplayOrder, IHasLookupInfo<SeriesInfo>, IHasSpecialFeatures, IMetadataContainer, IHasOriginalTitle
{
public List<Guid> SpecialFeatureIds { get; set; }
public List<Guid> SoundtrackIds { get; set; }
public string OriginalTitle { get; set; }
public int SeasonCount { get; set; }
public int? AnimeSeriesIndex { get; set; }

View File

@ -139,6 +139,7 @@
<Compile Include="Entities\IHasKeywords.cs" />
<Compile Include="Entities\IHasMediaSources.cs" />
<Compile Include="Entities\IHasMetascore.cs" />
<Compile Include="Entities\IHasOriginalTitle.cs" />
<Compile Include="Entities\IHasPreferredMetadataLanguage.cs" />
<Compile Include="Entities\IHasProductionLocations.cs" />
<Compile Include="Entities\IHasScreenshots.cs" />

View File

@ -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;

View File

@ -57,6 +57,7 @@ namespace MediaBrowser.LocalMetadata.Savers
"Language",
"LocalTitle",
"OriginalTitle",
"LockData",
"LockedFields",
"Format3D",
@ -274,6 +275,15 @@ namespace MediaBrowser.LocalMetadata.Savers
builder.Append("<Overview><![CDATA[" + item.Overview + "]]></Overview>");
}
var hasOriginalTitle = item as IHasOriginalTitle;
if (hasOriginalTitle != null)
{
if (!string.IsNullOrEmpty(hasOriginalTitle.OriginalTitle))
{
builder.Append("<OriginalTitle>" + SecurityElement.Escape(hasOriginalTitle.OriginalTitle) + "</OriginalTitle>");
}
}
var hasShortOverview = item as IHasShortOverview;
if (hasShortOverview != null)
{

View File

@ -111,7 +111,13 @@ namespace MediaBrowser.Providers.Movies
/// <param name="movieData">The movie data.</param>
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;

View File

@ -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

View File

@ -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
/// <value>The original_title.</value>
public string original_title { get; set; }
/// <summary>
/// Gets or sets the original_name.
/// </summary>
/// <value>The original_name.</value>
public string original_name { get; set; }
/// <summary>
/// Gets or sets the release_date.
/// </summary>
/// <value>The release_date.</value>

View File

@ -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();

View File

@ -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)