2014-03-14 21:14:07 -07:00
|
|
|
|
using MediaBrowser.Controller.Providers;
|
2014-01-28 11:37:01 -07:00
|
|
|
|
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;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Threading;
|
|
|
|
|
using System.Threading.Tasks;
|
2016-10-25 12:02:04 -07:00
|
|
|
|
using MediaBrowser.Common.IO;
|
|
|
|
|
using MediaBrowser.Controller.IO;
|
|
|
|
|
using MediaBrowser.Model.IO;
|
2016-05-28 23:03:09 -07:00
|
|
|
|
using MediaBrowser.Model.Providers;
|
2016-10-25 12:02:04 -07:00
|
|
|
|
using MediaBrowser.Model.Serialization;
|
2013-02-20 18:33:05 -07:00
|
|
|
|
|
|
|
|
|
namespace MediaBrowser.Controller.Entities.Movies
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Class Movie
|
|
|
|
|
/// </summary>
|
2016-10-30 21:28:23 -07:00
|
|
|
|
public class Movie : Video, IHasSpecialFeatures, IHasBudget, IHasTrailers, IHasAwards, IHasMetascore, IHasLookupInfo<MovieInfo>, ISupportsBoxSetGrouping
|
2013-02-20 18:33:05 -07:00
|
|
|
|
{
|
2013-05-08 13:58:52 -07:00
|
|
|
|
public List<Guid> SpecialFeatureIds { get; set; }
|
|
|
|
|
|
|
|
|
|
public Movie()
|
|
|
|
|
{
|
|
|
|
|
SpecialFeatureIds = new List<Guid>();
|
2013-12-02 09:46:25 -07:00
|
|
|
|
RemoteTrailers = new List<MediaUrl>();
|
|
|
|
|
LocalTrailerIds = new List<Guid>();
|
2014-12-10 23:20:28 -07:00
|
|
|
|
RemoteTrailerIds = new List<Guid>();
|
2013-12-05 09:50:21 -07:00
|
|
|
|
Taglines = 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-12-10 23:20:28 -07:00
|
|
|
|
public List<Guid> RemoteTrailerIds { get; set; }
|
2014-02-05 21:39:16 -07:00
|
|
|
|
|
2013-12-02 09:46:25 -07:00
|
|
|
|
public List<MediaUrl> RemoteTrailers { get; set; }
|
|
|
|
|
|
2013-12-05 09:50:21 -07:00
|
|
|
|
/// <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-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; }
|
|
|
|
|
|
2016-03-13 18:34:24 -07:00
|
|
|
|
[IgnoreDataMember]
|
|
|
|
|
public string CollectionName
|
|
|
|
|
{
|
|
|
|
|
get { return TmdbCollectionName; }
|
|
|
|
|
set { TmdbCollectionName = value; }
|
|
|
|
|
}
|
2013-02-20 18:33:05 -07:00
|
|
|
|
|
2016-10-11 14:33:38 -07:00
|
|
|
|
[IgnoreDataMember]
|
|
|
|
|
protected override bool SupportsIsInMixedFolderDetection
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2015-10-03 20:38:46 -07:00
|
|
|
|
protected override async Task<bool> RefreshedOwnedItems(MetadataRefreshOptions options, List<FileSystemMetadata> fileSystemChildren, CancellationToken cancellationToken)
|
2013-02-20 18:33:05 -07:00
|
|
|
|
{
|
2014-02-10 11:39:41 -07:00
|
|
|
|
var hasChanges = await base.RefreshedOwnedItems(options, fileSystemChildren, cancellationToken).ConfigureAwait(false);
|
2013-06-17 13:35:43 -07:00
|
|
|
|
|
|
|
|
|
// Must have a parent to have special features
|
|
|
|
|
// In other words, it must be part of the Parent/Child tree
|
2016-10-07 08:08:13 -07:00
|
|
|
|
if (LocationType == LocationType.FileSystem && GetParent() != null && !DetectIsInMixedFolder())
|
2013-06-17 13:35:43 -07:00
|
|
|
|
{
|
2014-02-05 21:39:16 -07:00
|
|
|
|
var specialFeaturesChanged = await RefreshSpecialFeatures(options, fileSystemChildren, cancellationToken).ConfigureAwait(false);
|
2013-02-20 18:33:05 -07:00
|
|
|
|
|
2014-02-05 21:39:16 -07:00
|
|
|
|
if (specialFeaturesChanged)
|
|
|
|
|
{
|
2014-02-10 11:39:41 -07:00
|
|
|
|
hasChanges = true;
|
2014-02-05 21:39:16 -07:00
|
|
|
|
}
|
|
|
|
|
}
|
2014-02-10 11:39:41 -07:00
|
|
|
|
|
|
|
|
|
return hasChanges;
|
2013-05-08 13:58:52 -07:00
|
|
|
|
}
|
|
|
|
|
|
2015-10-03 20:38:46 -07:00
|
|
|
|
private async Task<bool> RefreshSpecialFeatures(MetadataRefreshOptions options, List<FileSystemMetadata> fileSystemChildren, CancellationToken cancellationToken)
|
2013-05-08 13:58:52 -07:00
|
|
|
|
{
|
2014-12-01 11:42:07 -07:00
|
|
|
|
var newItems = LibraryManager.FindExtras(this, fileSystemChildren, options.DirectoryService).ToList();
|
2013-05-08 13:58:52 -07:00
|
|
|
|
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
|
|
|
|
|
2016-10-16 10:11:32 -07:00
|
|
|
|
var tasks = newItems.Select(i => RefreshMetadataForOwnedItem(i, false, options, cancellationToken));
|
2013-04-10 08:56:36 -07:00
|
|
|
|
|
2014-02-05 21:39:16 -07:00
|
|
|
|
await Task.WhenAll(tasks).ConfigureAwait(false);
|
2013-05-08 13:58:52 -07:00
|
|
|
|
|
|
|
|
|
SpecialFeatureIds = newItemIds;
|
|
|
|
|
|
2014-02-05 21:39:16 -07:00
|
|
|
|
return itemsChanged;
|
2013-05-08 13:58:52 -07:00
|
|
|
|
}
|
2013-06-16 12:02:57 -07:00
|
|
|
|
|
2015-11-06 08:02:22 -07:00
|
|
|
|
public override UnratedItem GetBlockUnratedType()
|
2013-12-26 09:53:23 -07:00
|
|
|
|
{
|
2015-11-06 08:02:22 -07:00
|
|
|
|
return UnratedItem.Movie;
|
2013-12-26 09:53:23 -07:00
|
|
|
|
}
|
2014-02-06 20:10:13 -07:00
|
|
|
|
|
|
|
|
|
public MovieInfo GetLookupInfo()
|
|
|
|
|
{
|
2014-12-18 21:20:07 -07:00
|
|
|
|
var info = GetItemLookupInfo<MovieInfo>();
|
|
|
|
|
|
2016-10-07 08:08:13 -07:00
|
|
|
|
if (!DetectIsInMixedFolder())
|
2014-12-18 21:20:07 -07:00
|
|
|
|
{
|
2016-12-09 00:23:09 -07:00
|
|
|
|
var name = System.IO.Path.GetFileName(ContainingFolderPath);
|
|
|
|
|
|
|
|
|
|
if (VideoType == VideoType.VideoFile || VideoType == VideoType.Iso)
|
|
|
|
|
{
|
|
|
|
|
if (string.Equals(name, System.IO.Path.GetFileName(Path), StringComparison.OrdinalIgnoreCase))
|
|
|
|
|
{
|
|
|
|
|
// if the folder has the file extension, strip it
|
|
|
|
|
name = System.IO.Path.GetFileNameWithoutExtension(name);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
info.Name = name;
|
2014-12-18 21:20:07 -07:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return info;
|
2014-02-06 20:10:13 -07:00
|
|
|
|
}
|
2014-02-12 22:11:54 -07:00
|
|
|
|
|
|
|
|
|
public override bool BeforeMetadataRefresh()
|
|
|
|
|
{
|
|
|
|
|
var hasChanges = base.BeforeMetadataRefresh();
|
|
|
|
|
|
|
|
|
|
if (!ProductionYear.HasValue)
|
|
|
|
|
{
|
2014-11-16 15:46:01 -07:00
|
|
|
|
var info = LibraryManager.ParseName(Name);
|
2014-02-12 22:11:54 -07:00
|
|
|
|
|
2014-11-16 15:46:01 -07:00
|
|
|
|
var yearInName = info.Year;
|
2014-02-12 22:11:54 -07:00
|
|
|
|
|
|
|
|
|
if (yearInName.HasValue)
|
|
|
|
|
{
|
|
|
|
|
ProductionYear = yearInName;
|
|
|
|
|
hasChanges = true;
|
|
|
|
|
}
|
2014-12-08 21:57:18 -07:00
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
// Try to get the year from the folder name
|
2016-10-07 08:08:13 -07:00
|
|
|
|
if (!DetectIsInMixedFolder())
|
2014-12-08 21:57:18 -07:00
|
|
|
|
{
|
|
|
|
|
info = LibraryManager.ParseName(System.IO.Path.GetFileName(ContainingFolderPath));
|
|
|
|
|
|
|
|
|
|
yearInName = info.Year;
|
|
|
|
|
|
|
|
|
|
if (yearInName.HasValue)
|
|
|
|
|
{
|
|
|
|
|
ProductionYear = yearInName;
|
|
|
|
|
hasChanges = true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2014-02-12 22:11:54 -07:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return hasChanges;
|
|
|
|
|
}
|
2016-05-28 23:03:09 -07:00
|
|
|
|
|
|
|
|
|
public override List<ExternalUrl> GetRelatedUrls()
|
|
|
|
|
{
|
|
|
|
|
var list = base.GetRelatedUrls();
|
|
|
|
|
|
|
|
|
|
var imdbId = this.GetProviderId(MetadataProviders.Imdb);
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(imdbId))
|
|
|
|
|
{
|
|
|
|
|
list.Add(new ExternalUrl
|
|
|
|
|
{
|
|
|
|
|
Name = "Trakt",
|
|
|
|
|
Url = string.Format("https://trakt.tv/movies/{0}", imdbId)
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return list;
|
|
|
|
|
}
|
2016-08-14 14:29:35 -07:00
|
|
|
|
|
|
|
|
|
[IgnoreDataMember]
|
|
|
|
|
public override bool StopRefreshIfLocalMetadataFound
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
|
|
|
|
// Need people id's from internet metadata
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
}
|
2013-02-20 18:33:05 -07:00
|
|
|
|
}
|
|
|
|
|
}
|