diff options
Diffstat (limited to 'MediaBrowser.Server.Implementations')
3 files changed, 57 insertions, 0 deletions
diff --git a/MediaBrowser.Server.Implementations/Dto/DtoService.cs b/MediaBrowser.Server.Implementations/Dto/DtoService.cs index 9cf21c534f..7fa2990506 100644 --- a/MediaBrowser.Server.Implementations/Dto/DtoService.cs +++ b/MediaBrowser.Server.Implementations/Dto/DtoService.cs @@ -722,6 +722,21 @@ namespace MediaBrowser.Server.Implementations.Dto dto.AspectRatio = hasAspectRatio.AspectRatio; } + var hasMetascore = item as IHasMetascore; + if (hasMetascore != null) + { + dto.Metascore = hasMetascore.Metascore; + } + + if (fields.Contains(ItemFields.AwardSummary)) + { + var hasAwards = item as IHasAwards; + if (hasAwards != null) + { + dto.AwardSummary = hasAwards.AwardSummary; + } + } + dto.BackdropImageTags = GetBackdropImageTags(item); if (fields.Contains(ItemFields.ScreenshotImageTags)) diff --git a/MediaBrowser.Server.Implementations/MediaBrowser.Server.Implementations.csproj b/MediaBrowser.Server.Implementations/MediaBrowser.Server.Implementations.csproj index f1e0d6a8db..e530eca46c 100644 --- a/MediaBrowser.Server.Implementations/MediaBrowser.Server.Implementations.csproj +++ b/MediaBrowser.Server.Implementations/MediaBrowser.Server.Implementations.csproj @@ -211,6 +211,7 @@ <Compile Include="Sorting\EpisodeCountComparer.cs" /> <Compile Include="Sorting\IsFolderComparer.cs" /> <Compile Include="Sorting\IsUnplayedComparer.cs" /> + <Compile Include="Sorting\MetascoreComparer.cs" /> <Compile Include="Sorting\MovieCountComparer.cs" /> <Compile Include="Sorting\MusicVideoCountComparer.cs" /> <Compile Include="Sorting\NameComparer.cs" /> diff --git a/MediaBrowser.Server.Implementations/Sorting/MetascoreComparer.cs b/MediaBrowser.Server.Implementations/Sorting/MetascoreComparer.cs new file mode 100644 index 0000000000..bfd1626615 --- /dev/null +++ b/MediaBrowser.Server.Implementations/Sorting/MetascoreComparer.cs @@ -0,0 +1,41 @@ +using MediaBrowser.Controller.Entities; +using MediaBrowser.Controller.Sorting; +using MediaBrowser.Model.Querying; + +namespace MediaBrowser.Server.Implementations.Sorting +{ + public class MetascoreComparer : 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 GetValue(x).CompareTo(GetValue(y)); + } + + private float GetValue(BaseItem x) + { + var hasMetascore = x as IHasMetascore; + + if (hasMetascore != null) + { + return hasMetascore.Metascore ?? 0; + } + + return 0; + } + + /// <summary> + /// Gets the name. + /// </summary> + /// <value>The name.</value> + public string Name + { + get { return ItemSortBy.Metascore; } + } + } +} |
