add new fields from omdb

This commit is contained in:
Luke Pulverenti 2014-01-15 00:01:58 -05:00
parent 5898627254
commit 7d4f33f0e0
16 changed files with 188 additions and 11 deletions

View File

@ -345,6 +345,18 @@ namespace MediaBrowser.Api
video.Video3DFormat = request.Video3DFormat;
}
var hasMetascore = item as IHasMetascore;
if (hasMetascore != null)
{
hasMetascore.Metascore = request.Metascore;
}
var hasAwards = item as IHasAwards;
if (hasAwards != null)
{
hasAwards.AwardSummary = request.AwardSummary;
}
var game = item as Game;
if (game != null)

View File

@ -287,9 +287,9 @@ namespace MediaBrowser.Api.Playback
case EncodingQuality.HighSpeed:
return 2;
case EncodingQuality.HighQuality:
return isWebm ? Math.Min(3, Environment.ProcessorCount - 1) : 2;
return 2;
case EncodingQuality.MaxQuality:
return isWebm ? Math.Max(2, Environment.ProcessorCount - 1) : 0;
return isWebm ? 2 : 0;
default:
throw new Exception("Unrecognized MediaEncodingQuality value.");
}

View File

@ -0,0 +1,15 @@

namespace MediaBrowser.Controller.Entities
{
/// <summary>
/// Interface IHasAwards
/// </summary>
public interface IHasAwards
{
/// <summary>
/// Gets or sets the awards summary.
/// </summary>
/// <value>The awards summary.</value>
string AwardSummary { get; set; }
}
}

View File

@ -0,0 +1,15 @@

namespace MediaBrowser.Controller.Entities
{
/// <summary>
/// Interface IHasMetascore
/// </summary>
public interface IHasMetascore
{
/// <summary>
/// Gets or sets the metascore.
/// </summary>
/// <value>The metascore.</value>
float? Metascore { get; set; }
}
}

View File

@ -12,7 +12,7 @@ namespace MediaBrowser.Controller.Entities.Movies
/// <summary>
/// Class Movie
/// </summary>
public class Movie : Video, IHasCriticRating, IHasSoundtracks, IHasBudget, IHasKeywords, IHasTrailers, IHasThemeMedia, IHasTaglines, IHasTags, IHasPreferredMetadataLanguage
public class Movie : Video, IHasCriticRating, IHasSoundtracks, IHasBudget, IHasKeywords, IHasTrailers, IHasThemeMedia, IHasTaglines, IHasTags, IHasPreferredMetadataLanguage, IHasAwards, IHasMetascore
{
public List<Guid> SpecialFeatureIds { get; set; }
@ -20,7 +20,7 @@ namespace MediaBrowser.Controller.Entities.Movies
public List<Guid> ThemeSongIds { get; set; }
public List<Guid> ThemeVideoIds { get; set; }
/// <summary>
/// Gets or sets the preferred metadata country code.
/// </summary>
@ -42,6 +42,10 @@ namespace MediaBrowser.Controller.Entities.Movies
Keywords = new List<string>();
}
public string AwardSummary { get; set; }
public float? Metascore { get; set; }
public List<Guid> LocalTrailerIds { get; set; }
public List<string> Keywords { get; set; }

View File

@ -9,7 +9,7 @@ namespace MediaBrowser.Controller.Entities
/// <summary>
/// Class Trailer
/// </summary>
public class Trailer : Video, IHasCriticRating, IHasSoundtracks, IHasBudget, IHasTrailers, IHasKeywords, IHasTaglines, IHasTags, IHasPreferredMetadataLanguage
public class Trailer : Video, IHasCriticRating, IHasSoundtracks, IHasBudget, IHasTrailers, IHasKeywords, IHasTaglines, IHasTags, IHasPreferredMetadataLanguage, IHasMetascore
{
public List<Guid> SoundtrackIds { get; set; }
@ -31,6 +31,8 @@ namespace MediaBrowser.Controller.Entities
Keywords = new List<string>();
}
public float? Metascore { get; set; }
public List<Guid> LocalTrailerIds { get; set; }
public List<MediaUrl> RemoteTrailers { get; set; }

View File

@ -89,6 +89,7 @@
<Compile Include="Entities\IHasImages.cs" />
<Compile Include="Entities\IHasKeywords.cs" />
<Compile Include="Entities\IHasMediaStreams.cs" />
<Compile Include="Entities\IHasMetascore.cs" />
<Compile Include="Entities\IHasPreferredMetadataLanguage.cs" />
<Compile Include="Entities\IHasProductionLocations.cs" />
<Compile Include="Entities\IHasScreenshots.cs" />
@ -103,6 +104,7 @@
<Compile Include="Entities\ImageSourceInfo.cs" />
<Compile Include="Entities\LinkedChild.cs" />
<Compile Include="Entities\MusicVideo.cs" />
<Compile Include="Entities\IHasAwards.cs" />
<Compile Include="Library\ILibraryPostScanTask.cs" />
<Compile Include="Library\ILibraryPrescanTask.cs" />
<Compile Include="Library\IMetadataSaver.cs" />

View File

@ -212,14 +212,41 @@ namespace MediaBrowser.Controller.Providers
break;
}
case "Metascore":
{
var text = reader.ReadElementContentAsString();
var hasMetascore = item as IHasMetascore;
if (hasMetascore != null)
{
float value;
if (float.TryParse(text, NumberStyles.Any, _usCulture, out value))
{
hasMetascore.Metascore = value;
}
}
break;
}
case "AwardSummary":
{
var text = reader.ReadElementContentAsString();
var hasAwards = item as IHasAwards;
if (hasAwards != null)
{
if (!string.IsNullOrWhiteSpace(text))
{
hasAwards.AwardSummary = text;
}
}
break;
}
case "SortTitle":
{
var val = reader.ReadElementContentAsString();
if (!string.IsNullOrWhiteSpace(val))
{
item.ForcedSortName = val;
}
break;
}

View File

@ -1,8 +1,8 @@
using System.Diagnostics;
using MediaBrowser.Model.Entities;
using MediaBrowser.Model.Entities;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;
using System.Runtime.Serialization;
namespace MediaBrowser.Model.Dto
@ -40,6 +40,10 @@ namespace MediaBrowser.Model.Dto
public string PreferredMetadataLanguage { get; set; }
public string PreferredMetadataCountryCode { get; set; }
public string AwardSummary { get; set; }
public float? Metascore { get; set; }
/// <summary>
/// Gets or sets the DVD season number.

View File

@ -6,6 +6,11 @@ namespace MediaBrowser.Model.Querying
/// </summary>
public enum ItemFields
{
/// <summary>
/// The awards summary
/// </summary>
AwardSummary,
/// <summary>
/// The budget
/// </summary>

View File

@ -85,5 +85,6 @@ namespace MediaBrowser.Model.Querying
public const string SeriesSortName = "SeriesSortName";
public const string VideoBitRate = "VideoBitRate";
public const string AirTime = "AirTime";
public const string Metascore = "Metascore";
}
}

View File

@ -203,6 +203,24 @@ namespace MediaBrowser.Providers.Movies
item.AddGenre(genre);
}
}
var hasMetascore = item as IHasMetascore;
if (hasMetascore != null)
{
float metascore;
if (!string.IsNullOrEmpty(result.Metascore) && float.TryParse(result.Metascore, NumberStyles.Any, UsCulture, out metascore) && metascore >= 0)
{
hasMetascore.Metascore = metascore;
}
}
var hasAwards = item as IHasAwards;
if (hasAwards != null && !string.IsNullOrEmpty(result.Awards) &&
!string.Equals(result.Awards, "n/a", StringComparison.OrdinalIgnoreCase))
{
hasAwards.AwardSummary = WebUtility.HtmlDecode(result.Awards);
}
}
private bool ShouldFetchGenres(BaseItem item)

View File

@ -22,6 +22,7 @@ namespace MediaBrowser.Providers.Savers
"Added",
"AspectRatio",
"AwardSummary",
"BirthDate",
"Budget",
"certification",
@ -44,11 +45,13 @@ namespace MediaBrowser.Providers.Savers
"LockData",
"LockedFields",
"Format3D",
"Metascore",
"MPAARating",
"MusicbrainzId",
"MusicBrainzReleaseGroupId",
"Overview",
"Persons",
"PlotKeywords",
"PremiereDate",
"ProductionYear",
"Rating",
@ -290,6 +293,18 @@ namespace MediaBrowser.Providers.Savers
{
builder.Append("<DisplayOrder>" + SecurityElement.Escape(hasDisplayOrder.DisplayOrder) + "</DisplayOrder>");
}
var hasMetascore = item as IHasMetascore;
if (hasMetascore != null && hasMetascore.Metascore.HasValue)
{
builder.Append("<Metascore>" + SecurityElement.Escape(hasMetascore.Metascore.Value.ToString(UsCulture)) + "</Metascore>");
}
var hasAwards = item as IHasAwards;
if (hasAwards != null && !string.IsNullOrEmpty(hasAwards.AwardSummary))
{
builder.Append("<AwardSummary>" + SecurityElement.Escape(hasAwards.AwardSummary) + "</AwardSummary>");
}
var hasBudget = item as IHasBudget;
if (hasBudget != null)

View File

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

View File

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

View File

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