2014-01-28 11:37:01 -07:00
|
|
|
|
using MediaBrowser.Controller.Providers;
|
|
|
|
|
using MediaBrowser.Model.Configuration;
|
2013-12-26 09:53:23 -07:00
|
|
|
|
using MediaBrowser.Model.Entities;
|
2013-05-27 18:59:26 -07:00
|
|
|
|
using System;
|
2013-02-20 18:33:05 -07:00
|
|
|
|
using System.Collections.Generic;
|
2013-02-21 10:51:17 -07:00
|
|
|
|
using System.IO;
|
2013-02-20 18:33:05 -07:00
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Threading;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
|
|
|
|
|
namespace MediaBrowser.Controller.Entities.Movies
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Class Movie
|
|
|
|
|
/// </summary>
|
2014-01-14 22:01:58 -07:00
|
|
|
|
public class Movie : Video, IHasCriticRating, IHasSoundtracks, IHasBudget, IHasKeywords, IHasTrailers, IHasThemeMedia, IHasTaglines, IHasTags, IHasPreferredMetadataLanguage, IHasAwards, IHasMetascore
|
2013-02-20 18:33:05 -07:00
|
|
|
|
{
|
2013-05-08 13:58:52 -07:00
|
|
|
|
public List<Guid> SpecialFeatureIds { get; set; }
|
|
|
|
|
|
2013-11-12 08:36:08 -07:00
|
|
|
|
public List<Guid> SoundtrackIds { get; set; }
|
|
|
|
|
|
2013-12-05 09:50:21 -07:00
|
|
|
|
public List<Guid> ThemeSongIds { get; set; }
|
|
|
|
|
public List<Guid> ThemeVideoIds { get; set; }
|
2014-01-14 22:01:58 -07:00
|
|
|
|
|
2013-12-28 09:58:13 -07:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Gets or sets the preferred metadata country code.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <value>The preferred metadata country code.</value>
|
|
|
|
|
public string PreferredMetadataCountryCode { get; set; }
|
|
|
|
|
|
2013-12-26 17:23:58 -07:00
|
|
|
|
public string PreferredMetadataLanguage { get; set; }
|
2013-12-05 09:50:21 -07:00
|
|
|
|
|
2013-05-08 13:58:52 -07:00
|
|
|
|
public Movie()
|
|
|
|
|
{
|
|
|
|
|
SpecialFeatureIds = new List<Guid>();
|
2013-11-12 08:36:08 -07:00
|
|
|
|
SoundtrackIds = new List<Guid>();
|
2013-12-02 09:46:25 -07:00
|
|
|
|
RemoteTrailers = new List<MediaUrl>();
|
|
|
|
|
LocalTrailerIds = new List<Guid>();
|
2013-12-05 09:50:21 -07:00
|
|
|
|
ThemeSongIds = new List<Guid>();
|
|
|
|
|
ThemeVideoIds = new List<Guid>();
|
|
|
|
|
Taglines = new List<string>();
|
|
|
|
|
Tags = new List<string>();
|
2014-01-14 08:50:39 -07:00
|
|
|
|
Keywords = new List<string>();
|
2013-05-08 13:58:52 -07:00
|
|
|
|
}
|
2013-06-16 12:02:57 -07:00
|
|
|
|
|
2014-01-14 22:01:58 -07:00
|
|
|
|
public string AwardSummary { get; set; }
|
|
|
|
|
|
|
|
|
|
public float? Metascore { get; set; }
|
|
|
|
|
|
2013-12-02 09:46:25 -07:00
|
|
|
|
public List<Guid> LocalTrailerIds { get; set; }
|
2014-01-14 08:50:39 -07:00
|
|
|
|
public List<string> Keywords { get; set; }
|
|
|
|
|
|
2013-12-02 09:46:25 -07:00
|
|
|
|
public List<MediaUrl> RemoteTrailers { get; set; }
|
|
|
|
|
|
2013-12-02 09:16:03 -07:00
|
|
|
|
/// <summary>
|
2013-12-05 09:50:21 -07:00
|
|
|
|
/// Gets or sets the tags.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <value>The tags.</value>
|
|
|
|
|
public List<string> Tags { get; set; }
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Gets or sets the taglines.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <value>The taglines.</value>
|
|
|
|
|
public List<string> Taglines { get; set; }
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
2013-12-02 09:16:03 -07:00
|
|
|
|
/// Gets or sets the budget.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <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; }
|
|
|
|
|
|
2013-11-06 09:06:16 -07:00
|
|
|
|
/// <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; }
|
|
|
|
|
|
2013-10-17 08:34:47 -07:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Gets or sets the name of the TMDB collection.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <value>The name of the TMDB collection.</value>
|
|
|
|
|
public string TmdbCollectionName { get; set; }
|
|
|
|
|
|
2013-02-20 18:33:05 -07:00
|
|
|
|
/// <summary>
|
2013-04-13 11:02:30 -07:00
|
|
|
|
/// Gets the user data key.
|
2013-02-20 18:33:05 -07:00
|
|
|
|
/// </summary>
|
2013-04-13 11:02:30 -07:00
|
|
|
|
/// <returns>System.String.</returns>
|
|
|
|
|
public override string GetUserDataKey()
|
2013-02-20 18:33:05 -07:00
|
|
|
|
{
|
2013-04-13 11:02:30 -07:00
|
|
|
|
return this.GetProviderId(MetadataProviders.Tmdb) ?? this.GetProviderId(MetadataProviders.Imdb) ?? base.GetUserDataKey();
|
2013-02-20 18:33:05 -07:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Overrides the base implementation to refresh metadata for special features
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="cancellationToken">The cancellation token.</param>
|
|
|
|
|
/// <param name="forceSave">if set to <c>true</c> [is new item].</param>
|
|
|
|
|
/// <param name="forceRefresh">if set to <c>true</c> [force].</param>
|
|
|
|
|
/// <returns>Task{System.Boolean}.</returns>
|
2014-01-28 11:37:01 -07:00
|
|
|
|
public override async Task<bool> RefreshMetadataDirect(CancellationToken cancellationToken, bool forceSave = false, bool forceRefresh = false)
|
2013-02-20 18:33:05 -07:00
|
|
|
|
{
|
|
|
|
|
// Kick off a task to refresh the main item
|
2014-01-28 11:37:01 -07:00
|
|
|
|
var result = await base.RefreshMetadataDirect(cancellationToken, forceSave, forceRefresh).ConfigureAwait(false);
|
2013-02-20 18:33:05 -07:00
|
|
|
|
|
2013-06-17 13:35:43 -07:00
|
|
|
|
var specialFeaturesChanged = false;
|
|
|
|
|
|
|
|
|
|
// Must have a parent to have special features
|
|
|
|
|
// In other words, it must be part of the Parent/Child tree
|
2013-08-15 09:00:39 -07:00
|
|
|
|
if (LocationType == LocationType.FileSystem && Parent != null && !IsInMixedFolder)
|
2013-06-17 13:35:43 -07:00
|
|
|
|
{
|
2014-01-28 11:37:01 -07:00
|
|
|
|
specialFeaturesChanged = await RefreshSpecialFeatures(cancellationToken, forceSave, forceRefresh).ConfigureAwait(false);
|
2013-06-17 13:35:43 -07:00
|
|
|
|
}
|
2013-02-20 18:33:05 -07:00
|
|
|
|
|
2013-05-08 13:58:52 -07:00
|
|
|
|
return specialFeaturesChanged || result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private async Task<bool> RefreshSpecialFeatures(CancellationToken cancellationToken, bool forceSave = false, bool forceRefresh = false, bool allowSlowProviders = true)
|
|
|
|
|
{
|
|
|
|
|
var newItems = LoadSpecialFeatures().ToList();
|
|
|
|
|
var newItemIds = newItems.Select(i => i.Id).ToList();
|
2013-02-20 18:33:05 -07:00
|
|
|
|
|
2013-05-08 13:58:52 -07:00
|
|
|
|
var itemsChanged = !SpecialFeatureIds.SequenceEqual(newItemIds);
|
2013-02-20 18:33:05 -07:00
|
|
|
|
|
2014-01-28 11:37:01 -07:00
|
|
|
|
var tasks = newItems.Select(i => i.RefreshMetadata(new MetadataRefreshOptions
|
|
|
|
|
{
|
|
|
|
|
ForceSave = forceSave,
|
|
|
|
|
ReplaceAllMetadata = forceRefresh,
|
|
|
|
|
ResetResolveArgs = false
|
|
|
|
|
|
|
|
|
|
}, cancellationToken));
|
2013-04-10 08:56:36 -07:00
|
|
|
|
|
2013-05-08 13:58:52 -07:00
|
|
|
|
var results = await Task.WhenAll(tasks).ConfigureAwait(false);
|
|
|
|
|
|
|
|
|
|
SpecialFeatureIds = newItemIds;
|
|
|
|
|
|
|
|
|
|
return itemsChanged || results.Contains(true);
|
|
|
|
|
}
|
2013-06-16 12:02:57 -07:00
|
|
|
|
|
2013-02-21 10:51:17 -07:00
|
|
|
|
/// <summary>
|
2013-04-10 08:56:36 -07:00
|
|
|
|
/// Loads the special features.
|
2013-02-21 10:51:17 -07:00
|
|
|
|
/// </summary>
|
2013-04-10 08:56:36 -07:00
|
|
|
|
/// <returns>IEnumerable{Video}.</returns>
|
2013-02-21 10:51:17 -07:00
|
|
|
|
private IEnumerable<Video> LoadSpecialFeatures()
|
|
|
|
|
{
|
2013-04-27 22:29:27 -07:00
|
|
|
|
FileSystemInfo folder;
|
2013-02-21 10:51:17 -07:00
|
|
|
|
|
|
|
|
|
try
|
|
|
|
|
{
|
2014-01-29 15:26:14 -07:00
|
|
|
|
folder = ResolveArgs.GetFileSystemEntryByName("extras") ??
|
|
|
|
|
ResolveArgs.GetFileSystemEntryByName("specials");
|
2013-02-21 10:51:17 -07:00
|
|
|
|
}
|
|
|
|
|
catch (IOException ex)
|
|
|
|
|
{
|
2013-02-21 13:26:35 -07:00
|
|
|
|
Logger.ErrorException("Error getting ResolveArgs for {0}", ex, Path);
|
2013-04-10 08:56:36 -07:00
|
|
|
|
return new List<Video>();
|
2013-02-21 10:51:17 -07:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Path doesn't exist. No biggie
|
|
|
|
|
if (folder == null)
|
|
|
|
|
{
|
2013-04-10 08:56:36 -07:00
|
|
|
|
return new List<Video>();
|
2013-02-21 10:51:17 -07:00
|
|
|
|
}
|
|
|
|
|
|
2013-04-27 22:29:27 -07:00
|
|
|
|
IEnumerable<FileSystemInfo> files;
|
2013-02-21 10:51:17 -07:00
|
|
|
|
|
|
|
|
|
try
|
|
|
|
|
{
|
2013-04-27 22:29:27 -07:00
|
|
|
|
files = new DirectoryInfo(folder.FullName).EnumerateFiles();
|
2013-02-21 10:51:17 -07:00
|
|
|
|
}
|
|
|
|
|
catch (IOException ex)
|
|
|
|
|
{
|
2013-06-12 14:46:50 -07:00
|
|
|
|
Logger.ErrorException("Error loading special features for {0}", ex, Name);
|
2013-04-10 08:56:36 -07:00
|
|
|
|
return new List<Video>();
|
2013-02-21 10:51:17 -07:00
|
|
|
|
}
|
|
|
|
|
|
2013-02-28 12:32:41 -07:00
|
|
|
|
return LibraryManager.ResolvePaths<Video>(files, null).Select(video =>
|
2013-02-21 10:51:17 -07:00
|
|
|
|
{
|
|
|
|
|
// Try to retrieve it from the db. If we don't find it, use the resolved version
|
2014-01-14 13:03:35 -07:00
|
|
|
|
var dbItem = LibraryManager.GetItemById(video.Id) as Video;
|
2013-02-21 10:51:17 -07:00
|
|
|
|
|
|
|
|
|
if (dbItem != null)
|
|
|
|
|
{
|
2013-09-25 11:05:21 -07:00
|
|
|
|
dbItem.ResetResolveArgs(video.ResolveArgs);
|
2013-02-21 10:51:17 -07:00
|
|
|
|
video = dbItem;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return video;
|
|
|
|
|
});
|
2013-02-20 18:33:05 -07:00
|
|
|
|
}
|
2013-02-21 10:51:17 -07:00
|
|
|
|
|
2013-12-26 09:53:23 -07:00
|
|
|
|
protected override bool GetBlockUnratedValue(UserConfiguration config)
|
|
|
|
|
{
|
|
|
|
|
return config.BlockUnratedMovies;
|
|
|
|
|
}
|
2013-02-20 18:33:05 -07:00
|
|
|
|
}
|
|
|
|
|
}
|