Capture revenue and add it as a sort order

pull/702/head
Luke Pulverenti 11 years ago
parent aa8c3d9cf0
commit dea10e5040

@ -55,7 +55,7 @@ namespace MediaBrowser.Api.UserLibrary
/// Fields to return within the items, in addition to basic information
/// </summary>
/// <value>The fields.</value>
[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)]
[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, Revenue, SeriesInfo, SortName, Studios, Taglines, TrailerUrls, UserData", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "GET", AllowMultiple = true)]
public string Fields { get; set; }
/// <summary>

@ -32,7 +32,7 @@ namespace MediaBrowser.Api.UserLibrary
/// What to sort the results by
/// </summary>
/// <value>The sort by.</value>
[ApiMember(Name = "SortBy", Description = "Optional. Specify one or more sort orders, comma delimeted. Options: Album, AlbumArtist, Artist, Budget, CommunityRating, DateCreated, DatePlayed, PlayCount, PremiereDate, ProductionYear, SortName, Random, Runtime", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "GET", AllowMultiple = true)]
[ApiMember(Name = "SortBy", Description = "Optional. Specify one or more sort orders, comma delimeted. Options: Album, AlbumArtist, Artist, Budget, CommunityRating, DateCreated, DatePlayed, PlayCount, PremiereDate, ProductionYear, SortName, Random, Revenue, Runtime", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "GET", AllowMultiple = true)]
public string SortBy { get; set; }
/// <summary>

@ -264,6 +264,11 @@ namespace MediaBrowser.Controller.Dto
dto.Budget = item.Budget;
}
if (fields.Contains(ItemFields.Revenue))
{
dto.Revenue = item.Revenue;
}
if (fields.Contains(ItemFields.EndDate))
{
dto.EndDate = item.EndDate;

@ -564,6 +564,12 @@ namespace MediaBrowser.Controller.Entities
/// <value>The budget.</value>
public double? Budget { get; set; }
/// <summary>
/// Gets or sets the revenue.
/// </summary>
/// <value>The revenue.</value>
public double? Revenue { get; set; }
/// <summary>
/// Gets or sets the production locations.
/// </summary>

@ -907,6 +907,7 @@ namespace MediaBrowser.Controller.Providers.Movies
movie.Overview = movie.Overview != null ? movie.Overview.Replace("\n\n", "\n") : null;
movie.HomePageUrl = movieData.homepage;
movie.Budget = movieData.budget;
movie.Revenue = movieData.revenue;
if (!string.IsNullOrEmpty(movieData.tagline)) movie.AddTagline(movieData.tagline);
movie.SetProviderId(MetadataProviders.Imdb, movieData.imdb_id);

@ -458,8 +458,15 @@ namespace MediaBrowser.Model.Dto
/// Gets or sets the budget.
/// </summary>
/// <value>The budget.</value>
[ProtoMember(73)]
[ProtoMember(74)]
public double? Budget { get; set; }
/// <summary>
/// Gets or sets the revenue.
/// </summary>
/// <value>The revenue.</value>
[ProtoMember(75)]
public double? Revenue { get; set; }
/// <summary>
/// Gets a value indicating whether this instance can resume.

@ -100,6 +100,11 @@ namespace MediaBrowser.Model.Querying
/// The aspect ratio of the primary image
/// </summary>
PrimaryImageAspectRatio,
/// <summary>
/// The revenue
/// </summary>
Revenue,
/// <summary>
/// AirDays, status, SeriesName, etc

@ -23,6 +23,10 @@ namespace MediaBrowser.Model.Querying
/// </summary>
public const string Budget = "Budget";
/// <summary>
/// The revenue
/// </summary>
public const string Revenue = "Revenue";
/// <summary>
/// The date created
/// </summary>
public const string DateCreated = "DateCreated";

@ -164,6 +164,7 @@
<Compile Include="Sorting\PremiereDateComparer.cs" />
<Compile Include="Sorting\ProductionYearComparer.cs" />
<Compile Include="Sorting\RandomComparer.cs" />
<Compile Include="Sorting\RevenueComparer.cs" />
<Compile Include="Sorting\RuntimeComparer.cs" />
<Compile Include="Sorting\SortNameComparer.cs" />
<Compile Include="Sqlite\SQLiteDisplayPreferencesRepository.cs" />

@ -4,7 +4,7 @@ using MediaBrowser.Model.Querying;
namespace MediaBrowser.Server.Implementations.Sorting
{
public class BudgetDateComparer : IBaseItemComparer
public class BudgetComparer : IBaseItemComparer
{
/// <summary>
/// Compares the specified x.

@ -0,0 +1,29 @@
using MediaBrowser.Controller.Entities;
using MediaBrowser.Controller.Sorting;
using MediaBrowser.Model.Querying;
namespace MediaBrowser.Server.Implementations.Sorting
{
public class RevenueComparer : IBaseItemComparer
{
/// <summary>
/// Compares the specified x.
/// </summary>
/// <param name="x">The x.</param>
/// <param name="y">The y.</param>
/// <returns>System.Int32.</returns>
public int Compare(BaseItem x, BaseItem y)
{
return (x.Revenue ?? 0).CompareTo(y.Revenue ?? 0);
}
/// <summary>
/// Gets the name.
/// </summary>
/// <value>The name.</value>
public string Name
{
get { return ItemSortBy.Revenue; }
}
}
}
Loading…
Cancel
Save