adding stubs for rotten tomatoes
This commit is contained in:
parent
9fb1e8c00f
commit
2d5f8a3edf
|
@ -29,6 +29,7 @@ namespace MediaBrowser.Controller.Entities
|
|||
TrailerUrls = new List<string>();
|
||||
Studios = new List<string>();
|
||||
People = new List<PersonInfo>();
|
||||
CriticReviews = new List<ItemReview>();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -587,6 +588,18 @@ namespace MediaBrowser.Controller.Entities
|
|||
/// <value>The production locations.</value>
|
||||
public List<string> ProductionLocations { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the critic rating.
|
||||
/// </summary>
|
||||
/// <value>The critic rating.</value>
|
||||
public float? CriticRating { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the critic rating summary.
|
||||
/// </summary>
|
||||
/// <value>The critic rating summary.</value>
|
||||
public string CriticRatingSummary { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the community rating.
|
||||
/// </summary>
|
||||
|
@ -622,6 +635,12 @@ namespace MediaBrowser.Controller.Entities
|
|||
/// <value>The parent index number.</value>
|
||||
public int? ParentIndexNumber { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the critic reviews.
|
||||
/// </summary>
|
||||
/// <value>The critic reviews.</value>
|
||||
public List<ItemReview> CriticReviews { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The _local trailers
|
||||
/// </summary>
|
||||
|
|
|
@ -115,6 +115,7 @@
|
|||
<Compile Include="Providers\IProviderManager.cs" />
|
||||
<Compile Include="Providers\MediaInfo\MediaEncoderHelpers.cs" />
|
||||
<Compile Include="Providers\MetadataProviderPriority.cs" />
|
||||
<Compile Include="Providers\Movies\RottenTomatoesMovieProvider.cs" />
|
||||
<Compile Include="Providers\Music\FanArtArtistByNameProvider.cs" />
|
||||
<Compile Include="Providers\Music\LastfmAlbumProvider.cs" />
|
||||
<Compile Include="Providers\Music\FanArtAlbumProvider.cs" />
|
||||
|
|
|
@ -0,0 +1,168 @@
|
|||
using MediaBrowser.Common.Net;
|
||||
using MediaBrowser.Controller.Configuration;
|
||||
using MediaBrowser.Controller.Entities;
|
||||
using MediaBrowser.Controller.Entities.Movies;
|
||||
using MediaBrowser.Model.Entities;
|
||||
using MediaBrowser.Model.Logging;
|
||||
using MediaBrowser.Model.Serialization;
|
||||
using System;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace MediaBrowser.Controller.Providers.Movies
|
||||
{
|
||||
/// <summary>
|
||||
/// Class RottenTomatoesMovieProvider
|
||||
/// </summary>
|
||||
public class RottenTomatoesMovieProvider : BaseMetadataProvider
|
||||
{
|
||||
// http://developer.rottentomatoes.com/iodocs
|
||||
/// <summary>
|
||||
/// The API key
|
||||
/// </summary>
|
||||
private const string ApiKey = "x9wjnvv39ntjmt9zs95nm7bg";
|
||||
|
||||
/// <summary>
|
||||
/// The _rotten tomatoes resource pool
|
||||
/// </summary>
|
||||
private SemaphoreSlim _rottenTomatoesResourcePool = new SemaphoreSlim(3, 3);
|
||||
|
||||
/// <summary>
|
||||
/// Gets the json serializer.
|
||||
/// </summary>
|
||||
/// <value>The json serializer.</value>
|
||||
protected IJsonSerializer JsonSerializer { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the HTTP client.
|
||||
/// </summary>
|
||||
/// <value>The HTTP client.</value>
|
||||
protected IHttpClient HttpClient { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="RottenTomatoesMovieProvider"/> class.
|
||||
/// </summary>
|
||||
/// <param name="logManager">The log manager.</param>
|
||||
/// <param name="configurationManager">The configuration manager.</param>
|
||||
/// <param name="jsonSerializer">The json serializer.</param>
|
||||
/// <param name="httpClient">The HTTP client.</param>
|
||||
public RottenTomatoesMovieProvider(ILogManager logManager, IServerConfigurationManager configurationManager, IJsonSerializer jsonSerializer, IHttpClient httpClient)
|
||||
: base(logManager, configurationManager)
|
||||
{
|
||||
JsonSerializer = jsonSerializer;
|
||||
HttpClient = httpClient;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the provider version.
|
||||
/// </summary>
|
||||
/// <value>The provider version.</value>
|
||||
protected override string ProviderVersion
|
||||
{
|
||||
get
|
||||
{
|
||||
return "1";
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets a value indicating whether [requires internet].
|
||||
/// </summary>
|
||||
/// <value><c>true</c> if [requires internet]; otherwise, <c>false</c>.</value>
|
||||
public override bool RequiresInternet
|
||||
{
|
||||
get
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets a value indicating whether [refresh on version change].
|
||||
/// </summary>
|
||||
/// <value><c>true</c> if [refresh on version change]; otherwise, <c>false</c>.</value>
|
||||
protected override bool RefreshOnVersionChange
|
||||
{
|
||||
get
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Supportses the specified item.
|
||||
/// </summary>
|
||||
/// <param name="item">The item.</param>
|
||||
/// <returns><c>true</c> if XXXX, <c>false</c> otherwise</returns>
|
||||
public override bool Supports(BaseItem item)
|
||||
{
|
||||
return item is Movie;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Needses the refresh internal.
|
||||
/// </summary>
|
||||
/// <param name="item">The item.</param>
|
||||
/// <param name="providerInfo">The provider info.</param>
|
||||
/// <returns><c>true</c> if XXXX, <c>false</c> otherwise</returns>
|
||||
protected override bool NeedsRefreshInternal(BaseItem item, BaseProviderInfo providerInfo)
|
||||
{
|
||||
if (providerInfo.LastRefreshStatus != ProviderRefreshStatus.Success)
|
||||
{
|
||||
Logger.Debug("RottenTomatoesMovieProvider for {0} - last attempt had errors. Will try again.", item.Path);
|
||||
return true;
|
||||
}
|
||||
|
||||
// Refresh if imdb id has changed
|
||||
if (!string.Equals(item.GetProviderId(MetadataProviders.Imdb), providerInfo.CustomData))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
if (DateTime.Today.Subtract(providerInfo.LastRefreshed).TotalDays < ConfigurationManager.Configuration.MetadataRefreshDays)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return base.NeedsRefreshInternal(item, providerInfo);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Fetches metadata and returns true or false indicating if any work that requires persistence was done
|
||||
/// </summary>
|
||||
/// <param name="item">The item.</param>
|
||||
/// <param name="force">if set to <c>true</c> [force].</param>
|
||||
/// <param name="cancellationToken">The cancellation token.</param>
|
||||
/// <returns>Task{System.Boolean}.</returns>
|
||||
public override Task<bool> FetchAsync(BaseItem item, bool force, CancellationToken cancellationToken)
|
||||
{
|
||||
// Do work here
|
||||
|
||||
|
||||
// Lastly, record the Imdb id here
|
||||
BaseProviderInfo data;
|
||||
|
||||
if (item.ProviderData.TryGetValue(Id, out data))
|
||||
{
|
||||
data.CustomData = item.GetProviderId(MetadataProviders.Imdb);
|
||||
}
|
||||
|
||||
SetLastRefreshed(item, DateTime.UtcNow);
|
||||
|
||||
return Task.FromResult(true);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the priority.
|
||||
/// </summary>
|
||||
/// <value>The priority.</value>
|
||||
public override MetadataProviderPriority Priority
|
||||
{
|
||||
get
|
||||
{
|
||||
// Run after moviedb and xml providers
|
||||
return MetadataProviderPriority.Last;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
52
MediaBrowser.Model/Entities/ItemReview.cs
Normal file
52
MediaBrowser.Model/Entities/ItemReview.cs
Normal file
|
@ -0,0 +1,52 @@
|
|||
using System;
|
||||
|
||||
namespace MediaBrowser.Model.Entities
|
||||
{
|
||||
/// <summary>
|
||||
/// Class ItemReview
|
||||
/// </summary>
|
||||
public class ItemReview
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets or sets the name of the reviewer.
|
||||
/// </summary>
|
||||
/// <value>The name of the reviewer.</value>
|
||||
public string ReviewerName { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the publisher.
|
||||
/// </summary>
|
||||
/// <value>The publisher.</value>
|
||||
public string Publisher { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the date.
|
||||
/// </summary>
|
||||
/// <value>The date.</value>
|
||||
public DateTime Date { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the score.
|
||||
/// </summary>
|
||||
/// <value>The score.</value>
|
||||
public float Score { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the URL.
|
||||
/// </summary>
|
||||
/// <value>The URL.</value>
|
||||
public string Url { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the caption.
|
||||
/// </summary>
|
||||
/// <value>The caption.</value>
|
||||
public string Caption { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the text.
|
||||
/// </summary>
|
||||
/// <value>The text.</value>
|
||||
public string Text { get; set; }
|
||||
}
|
||||
}
|
|
@ -25,6 +25,10 @@ namespace MediaBrowser.Model.Entities
|
|||
/// <summary>
|
||||
/// MusicBrainz
|
||||
/// </summary>
|
||||
Musicbrainz
|
||||
Musicbrainz,
|
||||
/// <summary>
|
||||
/// The rotten tomatoes
|
||||
/// </summary>
|
||||
RottenTomatoes
|
||||
}
|
||||
}
|
||||
|
|
|
@ -47,6 +47,7 @@
|
|||
<Compile Include="Dto\IItemDto.cs" />
|
||||
<Compile Include="Dto\ItemByNameCounts.cs" />
|
||||
<Compile Include="Entities\IByReferenceItem.cs" />
|
||||
<Compile Include="Entities\ItemReview.cs" />
|
||||
<Compile Include="Net\WebSocketMessage.cs" />
|
||||
<Compile Include="Net\WebSocketMessageType.cs" />
|
||||
<Compile Include="Net\WebSocketState.cs" />
|
||||
|
|
Loading…
Reference in New Issue
Block a user