From 192e1676a4d8db48a15316eede2041f0b1c9b48f Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Fri, 12 Apr 2013 10:13:47 -0400 Subject: [PATCH] Added Budget, EndDate, HomePageUrl, ProductionLocations, --- .../UserLibrary/BaseItemsRequest.cs | 2 +- MediaBrowser.Controller/Entities/BaseItem.cs | 49 ++++++++++++++++++- MediaBrowser.Controller/Library/DtoBuilder.cs | 20 ++++++++ .../Providers/BaseItemXmlParser.cs | 12 +++++ .../Providers/Movies/MovieDbProvider.cs | 3 ++ .../Providers/Movies/TmdbPersonProvider.cs | 15 ++++++ MediaBrowser.Model/DTO/BaseItemDto.cs | 28 +++++++++++ MediaBrowser.Model/Querying/ItemFields.cs | 20 ++++++++ 8 files changed, 147 insertions(+), 2 deletions(-) diff --git a/MediaBrowser.Api/UserLibrary/BaseItemsRequest.cs b/MediaBrowser.Api/UserLibrary/BaseItemsRequest.cs index c9dd863811..46084ffeb4 100644 --- a/MediaBrowser.Api/UserLibrary/BaseItemsRequest.cs +++ b/MediaBrowser.Api/UserLibrary/BaseItemsRequest.cs @@ -55,7 +55,7 @@ namespace MediaBrowser.Api.UserLibrary /// Fields to return within the items, in addition to basic information /// /// The fields. - [ApiMember(Name = "Fields", Description = "Optional. Specify additional fields of information to return in the output. This allows multiple, comma delimeted. Options: AudioInfo, Chapters, DateCreated, DisplayMediaType, DisplayPreferences, Genres, ItemCounts, IndexOptions, MediaStreams, Overview, OverviewHtml, ParentId, Path, People, ProviderIds, PrimaryImageAspectRatio, SeriesInfo, SortName, Studios, Taglines, TrailerUrls, UserData", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "GET", AllowMultiple = true)] + [ApiMember(Name = "Fields", Description = "Optional. Specify additional fields of information to return in the output. This allows multiple, comma delimeted. Options: AudioInfo, Budget, Chapters, DateCreated, DisplayMediaType, DisplayPreferences, EndDate, Genres, HomePageUrl, ItemCounts, IndexOptions, Locations, MediaStreams, Overview, OverviewHtml, ParentId, Path, People, ProviderIds, PrimaryImageAspectRatio, SeriesInfo, SortName, Studios, Taglines, TrailerUrls, UserData", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "GET", AllowMultiple = true)] public string Fields { get; set; } /// diff --git a/MediaBrowser.Controller/Entities/BaseItem.cs b/MediaBrowser.Controller/Entities/BaseItem.cs index 4e63160fc6..15963a8073 100644 --- a/MediaBrowser.Controller/Entities/BaseItem.cs +++ b/MediaBrowser.Controller/Entities/BaseItem.cs @@ -477,6 +477,12 @@ namespace MediaBrowser.Controller.Entities /// The premiere date. public DateTime? PremiereDate { get; set; } + /// + /// Gets or sets the end date. + /// + /// The end date. + public DateTime? EndDate { get; set; } + /// /// Gets or sets the display type of the media. /// @@ -551,6 +557,24 @@ namespace MediaBrowser.Controller.Entities /// The genres. public virtual List Genres { get; set; } + /// + /// Gets or sets the home page URL. + /// + /// The home page URL. + public string HomePageUrl { get; set; } + + /// + /// Gets or sets the budget. + /// + /// The budget. + public double Budget { get; set; } + + /// + /// Gets or sets the production locations. + /// + /// The production locations. + public List ProductionLocations { get; set; } + /// /// Gets or sets the community rating. /// @@ -1064,7 +1088,7 @@ namespace MediaBrowser.Controller.Entities { if (string.IsNullOrWhiteSpace(name)) { - throw new ArgumentNullException(); + throw new ArgumentNullException("name"); } if (Genres == null) @@ -1078,6 +1102,29 @@ namespace MediaBrowser.Controller.Entities } } + /// + /// Adds the production location. + /// + /// The location. + /// location + public void AddProductionLocation(string location) + { + if (string.IsNullOrWhiteSpace(location)) + { + throw new ArgumentNullException("location"); + } + + if (ProductionLocations == null) + { + ProductionLocations = new List(); + } + + if (!ProductionLocations.Contains(location, StringComparer.OrdinalIgnoreCase)) + { + ProductionLocations.Add(location); + } + } + /// /// Adds genres to the item /// diff --git a/MediaBrowser.Controller/Library/DtoBuilder.cs b/MediaBrowser.Controller/Library/DtoBuilder.cs index 35aae68a07..7f9a6f1879 100644 --- a/MediaBrowser.Controller/Library/DtoBuilder.cs +++ b/MediaBrowser.Controller/Library/DtoBuilder.cs @@ -256,6 +256,26 @@ namespace MediaBrowser.Controller.Library dto.DisplayMediaType = item.DisplayMediaType; } + if (fields.Contains(ItemFields.Budget)) + { + dto.Budget = item.Budget; + } + + if (fields.Contains(ItemFields.EndDate)) + { + dto.EndDate = item.EndDate; + } + + if (fields.Contains(ItemFields.HomePageUrl)) + { + dto.HomePageUrl = item.HomePageUrl; + } + + if (fields.Contains(ItemFields.ProductionLocations)) + { + dto.ProductionLocations = item.ProductionLocations; + } + dto.AspectRatio = item.AspectRatio; dto.BackdropImageTags = GetBackdropImageTags(item); diff --git a/MediaBrowser.Controller/Providers/BaseItemXmlParser.cs b/MediaBrowser.Controller/Providers/BaseItemXmlParser.cs index cbee793991..d539ed771d 100644 --- a/MediaBrowser.Controller/Providers/BaseItemXmlParser.cs +++ b/MediaBrowser.Controller/Providers/BaseItemXmlParser.cs @@ -121,6 +121,18 @@ namespace MediaBrowser.Controller.Providers break; } + case "Website": + { + var val = reader.ReadElementContentAsString(); + + if (!string.IsNullOrWhiteSpace(val)) + { + item.HomePageUrl = val; + } + + break; + } + case "TagLines": { FetchFromTaglinesNode(reader.ReadSubtree(), item); diff --git a/MediaBrowser.Controller/Providers/Movies/MovieDbProvider.cs b/MediaBrowser.Controller/Providers/Movies/MovieDbProvider.cs index ce03923e28..00d604d8db 100644 --- a/MediaBrowser.Controller/Providers/Movies/MovieDbProvider.cs +++ b/MediaBrowser.Controller/Providers/Movies/MovieDbProvider.cs @@ -897,6 +897,9 @@ namespace MediaBrowser.Controller.Providers.Movies movie.Name = movieData.title ?? movieData.original_title ?? movie.Name; movie.Overview = movieData.overview; movie.Overview = movie.Overview != null ? movie.Overview.Replace("\n\n", "\n") : null; + movie.HomePageUrl = movieData.homepage; + movie.Budget = movieData.budget; + if (!string.IsNullOrEmpty(movieData.tagline)) movie.AddTagline(movieData.tagline); movie.SetProviderId(MetadataProviders.Imdb, movieData.imdb_id); float rating; diff --git a/MediaBrowser.Controller/Providers/Movies/TmdbPersonProvider.cs b/MediaBrowser.Controller/Providers/Movies/TmdbPersonProvider.cs index f721a04eb5..49823b9b6e 100644 --- a/MediaBrowser.Controller/Providers/Movies/TmdbPersonProvider.cs +++ b/MediaBrowser.Controller/Providers/Movies/TmdbPersonProvider.cs @@ -234,6 +234,21 @@ namespace MediaBrowser.Controller.Providers.Movies person.PremiereDate = date; } + if (DateTime.TryParseExact(searchResult.Deathday, "yyyy-MM-dd", new CultureInfo("en-US"), DateTimeStyles.None, out date)) + { + person.EndDate = date; + } + + if (!string.IsNullOrEmpty(searchResult.Homepage)) + { + person.HomePageUrl = searchResult.Homepage; + } + + if (!string.IsNullOrEmpty(searchResult.Place_Of_Birth)) + { + person.AddProductionLocation(searchResult.Place_Of_Birth); + } + person.SetProviderId(MetadataProviders.Tmdb, searchResult.Id.ToString()); } diff --git a/MediaBrowser.Model/DTO/BaseItemDto.cs b/MediaBrowser.Model/DTO/BaseItemDto.cs index 6b5103b5bc..7d4823cdd6 100644 --- a/MediaBrowser.Model/DTO/BaseItemDto.cs +++ b/MediaBrowser.Model/DTO/BaseItemDto.cs @@ -432,6 +432,34 @@ namespace MediaBrowser.Model.Dto /// The overview HTML. [ProtoMember(70)] public string OverviewHtml { get; set; } + + /// + /// Gets or sets the end date. + /// + /// The end date. + [ProtoMember(71)] + public DateTime? EndDate { get; set; } + + /// + /// Gets or sets the home page URL. + /// + /// The home page URL. + [ProtoMember(72)] + public string HomePageUrl { get; set; } + + /// + /// Gets or sets the production locations. + /// + /// The production locations. + [ProtoMember(73)] + public List ProductionLocations { get; set; } + + /// + /// Gets or sets the budget. + /// + /// The budget. + [ProtoMember(73)] + public double? Budget { get; set; } /// /// Gets a value indicating whether this instance can resume. diff --git a/MediaBrowser.Model/Querying/ItemFields.cs b/MediaBrowser.Model/Querying/ItemFields.cs index d9902d6d41..727de42f45 100644 --- a/MediaBrowser.Model/Querying/ItemFields.cs +++ b/MediaBrowser.Model/Querying/ItemFields.cs @@ -11,6 +11,11 @@ namespace MediaBrowser.Model.Querying /// AudioInfo, + /// + /// The budget + /// + Budget, + /// /// The chapters /// @@ -31,11 +36,21 @@ namespace MediaBrowser.Model.Querying /// DisplayPreferencesId, + /// + /// The end date + /// + EndDate, + /// /// Genres /// Genres, + /// + /// The home page URL + /// + HomePageUrl, + /// /// Child count, recursive child count, etc /// @@ -71,6 +86,11 @@ namespace MediaBrowser.Model.Querying /// People, + /// + /// The production locations + /// + ProductionLocations, + /// /// Imdb, tmdb, etc ///