2014-02-13 05:11:54 +00:00
|
|
|
|
using MediaBrowser.Controller.Library;
|
|
|
|
|
using MediaBrowser.Controller.Providers;
|
2014-01-28 18:37:01 +00:00
|
|
|
|
using MediaBrowser.Model.Configuration;
|
2013-12-26 16:53:23 +00:00
|
|
|
|
using MediaBrowser.Model.Entities;
|
2013-05-28 01:59:26 +00:00
|
|
|
|
using System;
|
2013-02-21 01:33:05 +00:00
|
|
|
|
using System.Collections.Generic;
|
2013-02-21 17:51:17 +00:00
|
|
|
|
using System.IO;
|
2013-02-21 01:33:05 +00:00
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Threading;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
|
|
|
|
|
namespace MediaBrowser.Controller.Entities.Movies
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Class Movie
|
|
|
|
|
/// </summary>
|
2014-02-08 20:02:35 +00:00
|
|
|
|
public class Movie : Video, IHasCriticRating, IHasSoundtracks, IHasBudget, IHasKeywords, IHasTrailers, IHasThemeMedia, IHasTaglines, IHasPreferredMetadataLanguage, IHasAwards, IHasMetascore, IHasLookupInfo<MovieInfo>
|
2013-02-21 01:33:05 +00:00
|
|
|
|
{
|
2013-05-08 20:58:52 +00:00
|
|
|
|
public List<Guid> SpecialFeatureIds { get; set; }
|
|
|
|
|
|
2013-11-12 15:36:08 +00:00
|
|
|
|
public List<Guid> SoundtrackIds { get; set; }
|
|
|
|
|
|
2013-12-05 16:50:21 +00:00
|
|
|
|
public List<Guid> ThemeSongIds { get; set; }
|
|
|
|
|
public List<Guid> ThemeVideoIds { get; set; }
|
2014-02-06 04:39:16 +00:00
|
|
|
|
|
2013-12-28 16:58:13 +00: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-27 00:23:58 +00:00
|
|
|
|
public string PreferredMetadataLanguage { get; set; }
|
2014-02-06 04:39:16 +00:00
|
|
|
|
|
2013-05-08 20:58:52 +00:00
|
|
|
|
public Movie()
|
|
|
|
|
{
|
|
|
|
|
SpecialFeatureIds = new List<Guid>();
|
2013-11-12 15:36:08 +00:00
|
|
|
|
SoundtrackIds = new List<Guid>();
|
2013-12-02 16:46:25 +00:00
|
|
|
|
RemoteTrailers = new List<MediaUrl>();
|
|
|
|
|
LocalTrailerIds = new List<Guid>();
|
2013-12-05 16:50:21 +00:00
|
|
|
|
ThemeSongIds = new List<Guid>();
|
|
|
|
|
ThemeVideoIds = new List<Guid>();
|
|
|
|
|
Taglines = new List<string>();
|
2014-01-14 15:50:39 +00:00
|
|
|
|
Keywords = new List<string>();
|
2013-05-08 20:58:52 +00:00
|
|
|
|
}
|
2013-06-16 19:02:57 +00:00
|
|
|
|
|
2014-01-15 05:01:58 +00:00
|
|
|
|
public string AwardSummary { get; set; }
|
|
|
|
|
|
|
|
|
|
public float? Metascore { get; set; }
|
|
|
|
|
|
2013-12-02 16:46:25 +00:00
|
|
|
|
public List<Guid> LocalTrailerIds { get; set; }
|
2014-01-14 15:50:39 +00:00
|
|
|
|
public List<string> Keywords { get; set; }
|
2014-02-06 04:39:16 +00:00
|
|
|
|
|
2013-12-02 16:46:25 +00:00
|
|
|
|
public List<MediaUrl> RemoteTrailers { get; set; }
|
|
|
|
|
|
2013-12-05 16:50:21 +00:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Gets or sets the taglines.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <value>The taglines.</value>
|
|
|
|
|
public List<string> Taglines { get; set; }
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
2013-12-02 16:16:03 +00: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 16:06:16 +00: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 15:34:47 +00: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-21 01:33:05 +00:00
|
|
|
|
/// <summary>
|
2013-04-13 18:02:30 +00:00
|
|
|
|
/// Gets the user data key.
|
2013-02-21 01:33:05 +00:00
|
|
|
|
/// </summary>
|
2013-04-13 18:02:30 +00:00
|
|
|
|
/// <returns>System.String.</returns>
|
|
|
|
|
public override string GetUserDataKey()
|
2013-02-21 01:33:05 +00:00
|
|
|
|
{
|
2013-04-13 18:02:30 +00:00
|
|
|
|
return this.GetProviderId(MetadataProviders.Tmdb) ?? this.GetProviderId(MetadataProviders.Imdb) ?? base.GetUserDataKey();
|
2013-02-21 01:33:05 +00:00
|
|
|
|
}
|
|
|
|
|
|
2014-02-10 18:39:41 +00:00
|
|
|
|
protected override async Task<bool> RefreshedOwnedItems(MetadataRefreshOptions options, List<FileSystemInfo> fileSystemChildren, CancellationToken cancellationToken)
|
2013-02-21 01:33:05 +00:00
|
|
|
|
{
|
2014-02-10 18:39:41 +00:00
|
|
|
|
var hasChanges = await base.RefreshedOwnedItems(options, fileSystemChildren, cancellationToken).ConfigureAwait(false);
|
2013-06-17 20:35:43 +00:00
|
|
|
|
|
|
|
|
|
// Must have a parent to have special features
|
|
|
|
|
// In other words, it must be part of the Parent/Child tree
|
2013-08-15 16:00:39 +00:00
|
|
|
|
if (LocationType == LocationType.FileSystem && Parent != null && !IsInMixedFolder)
|
2013-06-17 20:35:43 +00:00
|
|
|
|
{
|
2014-02-06 04:39:16 +00:00
|
|
|
|
var specialFeaturesChanged = await RefreshSpecialFeatures(options, fileSystemChildren, cancellationToken).ConfigureAwait(false);
|
2013-02-21 01:33:05 +00:00
|
|
|
|
|
2014-02-06 04:39:16 +00:00
|
|
|
|
if (specialFeaturesChanged)
|
|
|
|
|
{
|
2014-02-10 18:39:41 +00:00
|
|
|
|
hasChanges = true;
|
2014-02-06 04:39:16 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2014-02-10 18:39:41 +00:00
|
|
|
|
|
|
|
|
|
return hasChanges;
|
2013-05-08 20:58:52 +00:00
|
|
|
|
}
|
|
|
|
|
|
2014-02-08 22:38:02 +00:00
|
|
|
|
private async Task<bool> RefreshSpecialFeatures(MetadataRefreshOptions options, IEnumerable<FileSystemInfo> fileSystemChildren, CancellationToken cancellationToken)
|
2013-05-08 20:58:52 +00:00
|
|
|
|
{
|
2014-02-13 05:11:54 +00:00
|
|
|
|
var newItems = LoadSpecialFeatures(fileSystemChildren, options.DirectoryService).ToList();
|
2013-05-08 20:58:52 +00:00
|
|
|
|
var newItemIds = newItems.Select(i => i.Id).ToList();
|
2013-02-21 01:33:05 +00:00
|
|
|
|
|
2013-05-08 20:58:52 +00:00
|
|
|
|
var itemsChanged = !SpecialFeatureIds.SequenceEqual(newItemIds);
|
2013-02-21 01:33:05 +00:00
|
|
|
|
|
2014-02-06 04:39:16 +00:00
|
|
|
|
var tasks = newItems.Select(i => i.RefreshMetadata(options, cancellationToken));
|
2013-04-10 15:56:36 +00:00
|
|
|
|
|
2014-02-06 04:39:16 +00:00
|
|
|
|
await Task.WhenAll(tasks).ConfigureAwait(false);
|
2013-05-08 20:58:52 +00:00
|
|
|
|
|
|
|
|
|
SpecialFeatureIds = newItemIds;
|
|
|
|
|
|
2014-02-06 04:39:16 +00:00
|
|
|
|
return itemsChanged;
|
2013-05-08 20:58:52 +00:00
|
|
|
|
}
|
2013-06-16 19:02:57 +00:00
|
|
|
|
|
2013-02-21 17:51:17 +00:00
|
|
|
|
/// <summary>
|
2013-04-10 15:56:36 +00:00
|
|
|
|
/// Loads the special features.
|
2013-02-21 17:51:17 +00:00
|
|
|
|
/// </summary>
|
2013-04-10 15:56:36 +00:00
|
|
|
|
/// <returns>IEnumerable{Video}.</returns>
|
2014-02-13 05:11:54 +00:00
|
|
|
|
private IEnumerable<Video> LoadSpecialFeatures(IEnumerable<FileSystemInfo> fileSystemChildren, IDirectoryService directoryService)
|
2013-02-21 17:51:17 +00:00
|
|
|
|
{
|
2014-02-06 04:39:16 +00:00
|
|
|
|
var files = fileSystemChildren.OfType<DirectoryInfo>()
|
|
|
|
|
.Where(i => string.Equals(i.Name, "extras", StringComparison.OrdinalIgnoreCase) || string.Equals(i.Name, "specials", StringComparison.OrdinalIgnoreCase))
|
|
|
|
|
.SelectMany(i => i.EnumerateFiles("*", SearchOption.TopDirectoryOnly));
|
2013-02-21 17:51:17 +00:00
|
|
|
|
|
2014-02-13 05:11:54 +00:00
|
|
|
|
return LibraryManager.ResolvePaths<Video>(files, directoryService, null).Select(video =>
|
2013-02-21 17:51:17 +00:00
|
|
|
|
{
|
|
|
|
|
// Try to retrieve it from the db. If we don't find it, use the resolved version
|
2014-01-14 20:03:35 +00:00
|
|
|
|
var dbItem = LibraryManager.GetItemById(video.Id) as Video;
|
2013-02-21 17:51:17 +00:00
|
|
|
|
|
|
|
|
|
if (dbItem != null)
|
|
|
|
|
{
|
|
|
|
|
video = dbItem;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return video;
|
2014-02-06 16:46:26 +00:00
|
|
|
|
|
|
|
|
|
// Sort them so that the list can be easily compared for changes
|
|
|
|
|
}).OrderBy(i => i.Path).ToList();
|
2013-02-21 01:33:05 +00:00
|
|
|
|
}
|
2013-02-21 17:51:17 +00:00
|
|
|
|
|
2013-12-26 16:53:23 +00:00
|
|
|
|
protected override bool GetBlockUnratedValue(UserConfiguration config)
|
|
|
|
|
{
|
2014-02-21 15:24:29 +00:00
|
|
|
|
return config.BlockUnratedItems.Contains(UnratedItem.Movie);
|
2013-12-26 16:53:23 +00:00
|
|
|
|
}
|
2014-02-07 03:10:13 +00:00
|
|
|
|
|
|
|
|
|
public MovieInfo GetLookupInfo()
|
|
|
|
|
{
|
|
|
|
|
return GetItemLookupInfo<MovieInfo>();
|
|
|
|
|
}
|
2014-02-13 05:11:54 +00:00
|
|
|
|
|
|
|
|
|
public override bool BeforeMetadataRefresh()
|
|
|
|
|
{
|
|
|
|
|
var hasChanges = base.BeforeMetadataRefresh();
|
|
|
|
|
|
|
|
|
|
if (!ProductionYear.HasValue)
|
|
|
|
|
{
|
|
|
|
|
int? yearInName = null;
|
|
|
|
|
string name;
|
|
|
|
|
|
|
|
|
|
NameParser.ParseName(Name, out name, out yearInName);
|
|
|
|
|
|
|
|
|
|
if (yearInName.HasValue)
|
|
|
|
|
{
|
|
|
|
|
ProductionYear = yearInName;
|
|
|
|
|
hasChanges = true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return hasChanges;
|
|
|
|
|
}
|
2013-02-21 01:33:05 +00:00
|
|
|
|
}
|
|
|
|
|
}
|