mirror of
https://github.com/jellyfin/jellyfin.git
synced 2026-04-20 09:04:42 +01:00
removed local trailers and special features from memory
This commit is contained in:
@@ -331,7 +331,7 @@ namespace MediaBrowser.Controller.Dto
|
||||
dto.CriticRatingSummary = item.CriticRatingSummary;
|
||||
}
|
||||
|
||||
var localTrailerCount = item.LocalTrailers == null ? 0 : item.LocalTrailers.Count;
|
||||
var localTrailerCount = item.LocalTrailerIds.Count;
|
||||
|
||||
if (localTrailerCount > 0)
|
||||
{
|
||||
@@ -492,7 +492,7 @@ namespace MediaBrowser.Controller.Dto
|
||||
|
||||
if (movie != null)
|
||||
{
|
||||
var specialFeatureCount = movie.SpecialFeatures == null ? 0 : movie.SpecialFeatures.Count;
|
||||
var specialFeatureCount = movie.SpecialFeatureIds.Count;
|
||||
|
||||
if (specialFeatureCount > 0)
|
||||
{
|
||||
|
||||
@@ -38,6 +38,9 @@ namespace MediaBrowser.Controller.Entities
|
||||
Images = new Dictionary<ImageType, string>();
|
||||
ProviderIds = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase);
|
||||
Tags = new List<string>();
|
||||
ThemeSongIds = new List<Guid>();
|
||||
ThemeVideoIds = new List<Guid>();
|
||||
LocalTrailerIds = new List<Guid>();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -572,7 +575,7 @@ namespace MediaBrowser.Controller.Entities
|
||||
/// </summary>
|
||||
/// <value>The tags.</value>
|
||||
public List<string> Tags { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Override this if you need to combine/collapse person information
|
||||
/// </summary>
|
||||
@@ -612,7 +615,7 @@ namespace MediaBrowser.Controller.Entities
|
||||
/// </summary>
|
||||
/// <value>The revenue.</value>
|
||||
public double? Revenue { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the production locations.
|
||||
/// </summary>
|
||||
@@ -630,7 +633,7 @@ namespace MediaBrowser.Controller.Entities
|
||||
/// </summary>
|
||||
/// <value>The critic rating summary.</value>
|
||||
public string CriticRatingSummary { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the community rating.
|
||||
/// </summary>
|
||||
@@ -672,84 +675,9 @@ namespace MediaBrowser.Controller.Entities
|
||||
/// <value>The critic reviews.</value>
|
||||
public List<ItemReview> CriticReviews { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The _local trailers
|
||||
/// </summary>
|
||||
private List<Trailer> _localTrailers;
|
||||
/// <summary>
|
||||
/// The _local trailers initialized
|
||||
/// </summary>
|
||||
private bool _localTrailersInitialized;
|
||||
/// <summary>
|
||||
/// The _local trailers sync lock
|
||||
/// </summary>
|
||||
private object _localTrailersSyncLock = new object();
|
||||
/// <summary>
|
||||
/// Gets the local trailers.
|
||||
/// </summary>
|
||||
/// <value>The local trailers.</value>
|
||||
[IgnoreDataMember]
|
||||
public List<Trailer> LocalTrailers
|
||||
{
|
||||
get
|
||||
{
|
||||
LazyInitializer.EnsureInitialized(ref _localTrailers, ref _localTrailersInitialized, ref _localTrailersSyncLock, LoadLocalTrailers);
|
||||
return _localTrailers;
|
||||
}
|
||||
private set
|
||||
{
|
||||
_localTrailers = value;
|
||||
|
||||
if (value == null)
|
||||
{
|
||||
_localTrailersInitialized = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private List<Audio.Audio> _themeSongs;
|
||||
private bool _themeSongsInitialized;
|
||||
private object _themeSongsSyncLock = new object();
|
||||
[IgnoreDataMember]
|
||||
public List<Audio.Audio> ThemeSongs
|
||||
{
|
||||
get
|
||||
{
|
||||
LazyInitializer.EnsureInitialized(ref _themeSongs, ref _themeSongsInitialized, ref _themeSongsSyncLock, LoadThemeSongs);
|
||||
return _themeSongs;
|
||||
}
|
||||
private set
|
||||
{
|
||||
_themeSongs = value;
|
||||
|
||||
if (value == null)
|
||||
{
|
||||
_themeSongsInitialized = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private List<Video> _themeVideos;
|
||||
private bool _themeVideosInitialized;
|
||||
private object _themeVideosSyncLock = new object();
|
||||
[IgnoreDataMember]
|
||||
public List<Video> ThemeVideos
|
||||
{
|
||||
get
|
||||
{
|
||||
LazyInitializer.EnsureInitialized(ref _themeVideos, ref _themeVideosInitialized, ref _themeVideosSyncLock, LoadThemeVideos);
|
||||
return _themeVideos;
|
||||
}
|
||||
private set
|
||||
{
|
||||
_themeVideos = value;
|
||||
|
||||
if (value == null)
|
||||
{
|
||||
_themeVideosInitialized = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
public List<Guid> ThemeSongIds { get; set; }
|
||||
public List<Guid> ThemeVideoIds { get; set; }
|
||||
public List<Guid> LocalTrailerIds { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Loads local trailers from the file system
|
||||
@@ -956,36 +884,25 @@ namespace MediaBrowser.Controller.Entities
|
||||
ResolveArgs = null;
|
||||
}
|
||||
|
||||
// Lazy load these again
|
||||
LocalTrailers = null;
|
||||
ThemeSongs = null;
|
||||
ThemeVideos = null;
|
||||
|
||||
// Refresh for the item
|
||||
var itemRefreshTask = ProviderManager.ExecuteMetadataProviders(this, cancellationToken, forceRefresh, allowSlowProviders);
|
||||
|
||||
cancellationToken.ThrowIfCancellationRequested();
|
||||
|
||||
// Refresh metadata for local trailers
|
||||
var trailerTasks = LocalTrailers.Select(i => i.RefreshMetadata(cancellationToken, forceSave, forceRefresh, allowSlowProviders));
|
||||
var themeSongsChanged = await RefreshThemeSongs(cancellationToken, forceSave, forceRefresh, allowSlowProviders).ConfigureAwait(false);
|
||||
|
||||
var themeSongTasks = ThemeSongs.Select(i => i.RefreshMetadata(cancellationToken, forceSave, forceRefresh, allowSlowProviders));
|
||||
var themeVideosChanged = await RefreshThemeVideos(cancellationToken, forceSave, forceRefresh, allowSlowProviders).ConfigureAwait(false);
|
||||
|
||||
var localTrailersChanged = await RefreshLocalTrailers(cancellationToken, forceSave, forceRefresh, allowSlowProviders).ConfigureAwait(false);
|
||||
|
||||
var videoBackdropTasks = ThemeVideos.Select(i => i.RefreshMetadata(cancellationToken, forceSave, forceRefresh, allowSlowProviders));
|
||||
|
||||
cancellationToken.ThrowIfCancellationRequested();
|
||||
|
||||
// Await the trailer tasks
|
||||
await Task.WhenAll(trailerTasks).ConfigureAwait(false);
|
||||
await Task.WhenAll(themeSongTasks).ConfigureAwait(false);
|
||||
await Task.WhenAll(videoBackdropTasks).ConfigureAwait(false);
|
||||
|
||||
cancellationToken.ThrowIfCancellationRequested();
|
||||
|
||||
// Get the result from the item task
|
||||
var changed = await itemRefreshTask.ConfigureAwait(false);
|
||||
|
||||
if (changed || forceSave)
|
||||
if (changed || forceSave || themeSongsChanged || themeVideosChanged || localTrailersChanged)
|
||||
{
|
||||
cancellationToken.ThrowIfCancellationRequested();
|
||||
|
||||
@@ -995,6 +912,57 @@ namespace MediaBrowser.Controller.Entities
|
||||
return changed;
|
||||
}
|
||||
|
||||
private async Task<bool> RefreshLocalTrailers(CancellationToken cancellationToken, bool forceSave = false, bool forceRefresh = false, bool allowSlowProviders = true)
|
||||
{
|
||||
var newItems = LoadLocalTrailers().ToList();
|
||||
var newItemIds = newItems.Select(i => i.Id).ToList();
|
||||
|
||||
var itemsChanged = !LocalTrailerIds.SequenceEqual(newItemIds);
|
||||
|
||||
var tasks = newItems.Select(i => i.RefreshMetadata(cancellationToken, forceSave, forceRefresh, allowSlowProviders));
|
||||
|
||||
var results = await Task.WhenAll(tasks).ConfigureAwait(false);
|
||||
|
||||
LocalTrailerIds = newItemIds;
|
||||
|
||||
return itemsChanged || results.Contains(true);
|
||||
}
|
||||
|
||||
private async Task<bool> RefreshThemeVideos(CancellationToken cancellationToken, bool forceSave = false, bool forceRefresh = false, bool allowSlowProviders = true)
|
||||
{
|
||||
var newThemeVideos = LoadThemeVideos().ToList();
|
||||
var newThemeVideoIds = newThemeVideos.Select(i => i.Id).ToList();
|
||||
|
||||
var themeVideosChanged = !ThemeVideoIds.SequenceEqual(newThemeVideoIds);
|
||||
|
||||
var tasks = newThemeVideos.Select(i => i.RefreshMetadata(cancellationToken, forceSave, forceRefresh, allowSlowProviders));
|
||||
|
||||
var results = await Task.WhenAll(tasks).ConfigureAwait(false);
|
||||
|
||||
ThemeVideoIds = newThemeVideoIds;
|
||||
|
||||
return themeVideosChanged || results.Contains(true);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Refreshes the theme songs.
|
||||
/// </summary>
|
||||
private async Task<bool> RefreshThemeSongs(CancellationToken cancellationToken, bool forceSave = false, bool forceRefresh = false, bool allowSlowProviders = true)
|
||||
{
|
||||
var newThemeSongs = LoadThemeSongs().ToList();
|
||||
var newThemeSongIds = newThemeSongs.Select(i => i.Id).ToList();
|
||||
|
||||
var themeSongsChanged = !ThemeSongIds.SequenceEqual(newThemeSongIds);
|
||||
|
||||
var tasks = newThemeSongs.Select(i => i.RefreshMetadata(cancellationToken, forceSave, forceRefresh, allowSlowProviders));
|
||||
|
||||
var results = await Task.WhenAll(tasks).ConfigureAwait(false);
|
||||
|
||||
ThemeSongIds = newThemeSongIds;
|
||||
|
||||
return themeSongsChanged || results.Contains(true);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Clear out all metadata properties. Extend for sub-classes.
|
||||
/// </summary>
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using MediaBrowser.Controller.IO;
|
||||
using System;
|
||||
using MediaBrowser.Controller.IO;
|
||||
using MediaBrowser.Model.Entities;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
@@ -14,6 +15,13 @@ namespace MediaBrowser.Controller.Entities.Movies
|
||||
/// </summary>
|
||||
public class Movie : Video
|
||||
{
|
||||
public List<Guid> SpecialFeatureIds { get; set; }
|
||||
|
||||
public Movie()
|
||||
{
|
||||
SpecialFeatureIds = new List<Guid>();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Should be overridden to return the proper folder where metadata lives
|
||||
/// </summary>
|
||||
@@ -36,41 +44,6 @@ namespace MediaBrowser.Controller.Entities.Movies
|
||||
return this.GetProviderId(MetadataProviders.Tmdb) ?? this.GetProviderId(MetadataProviders.Imdb) ?? base.GetUserDataKey();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The _special features
|
||||
/// </summary>
|
||||
private List<Video> _specialFeatures;
|
||||
/// <summary>
|
||||
/// The _special features initialized
|
||||
/// </summary>
|
||||
private bool _specialFeaturesInitialized;
|
||||
/// <summary>
|
||||
/// The _special features sync lock
|
||||
/// </summary>
|
||||
private object _specialFeaturesSyncLock = new object();
|
||||
/// <summary>
|
||||
/// Gets the special features.
|
||||
/// </summary>
|
||||
/// <value>The special features.</value>
|
||||
[IgnoreDataMember]
|
||||
public List<Video> SpecialFeatures
|
||||
{
|
||||
get
|
||||
{
|
||||
LazyInitializer.EnsureInitialized(ref _specialFeatures, ref _specialFeaturesInitialized, ref _specialFeaturesSyncLock, () => LoadSpecialFeatures().ToList());
|
||||
return _specialFeatures;
|
||||
}
|
||||
private set
|
||||
{
|
||||
_specialFeatures = value;
|
||||
|
||||
if (value == null)
|
||||
{
|
||||
_specialFeaturesInitialized = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Needed because the resolver stops at the movie folder and we find the video inside.
|
||||
/// </summary>
|
||||
@@ -94,21 +67,30 @@ namespace MediaBrowser.Controller.Entities.Movies
|
||||
/// <returns>Task{System.Boolean}.</returns>
|
||||
public override async Task<bool> RefreshMetadata(CancellationToken cancellationToken, bool forceSave = false, bool forceRefresh = false, bool allowSlowProviders = true, bool resetResolveArgs = true)
|
||||
{
|
||||
// Lazy load these again
|
||||
SpecialFeatures = null;
|
||||
|
||||
// Kick off a task to refresh the main item
|
||||
var result = await base.RefreshMetadata(cancellationToken, forceSave, forceRefresh, allowSlowProviders, resetResolveArgs).ConfigureAwait(false);
|
||||
|
||||
var tasks = SpecialFeatures.Select(item => item.RefreshMetadata(cancellationToken, forceSave, forceRefresh, allowSlowProviders));
|
||||
var specialFeaturesChanged = await RefreshSpecialFeatures(cancellationToken, forceSave, forceRefresh, allowSlowProviders).ConfigureAwait(false);
|
||||
|
||||
await Task.WhenAll(tasks).ConfigureAwait(false);
|
||||
|
||||
cancellationToken.ThrowIfCancellationRequested();
|
||||
|
||||
return result;
|
||||
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();
|
||||
|
||||
var itemsChanged = !SpecialFeatureIds.SequenceEqual(newItemIds);
|
||||
|
||||
var tasks = newItems.Select(i => i.RefreshMetadata(cancellationToken, forceSave, forceRefresh, allowSlowProviders));
|
||||
|
||||
var results = await Task.WhenAll(tasks).ConfigureAwait(false);
|
||||
|
||||
SpecialFeatureIds = newItemIds;
|
||||
|
||||
return itemsChanged || results.Contains(true);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Loads the special features.
|
||||
/// </summary>
|
||||
|
||||
@@ -24,7 +24,7 @@ namespace MediaBrowser.Controller.Persistence
|
||||
/// </summary>
|
||||
/// <param name="id">The id.</param>
|
||||
/// <returns>BaseItem.</returns>
|
||||
BaseItem RetrieveItem(Guid id);
|
||||
BaseItem GetItem(Guid id);
|
||||
|
||||
/// <summary>
|
||||
/// Gets children of a given Folder
|
||||
@@ -33,6 +33,13 @@ namespace MediaBrowser.Controller.Persistence
|
||||
/// <returns>IEnumerable{BaseItem}.</returns>
|
||||
IEnumerable<BaseItem> RetrieveChildren(Folder parent);
|
||||
|
||||
/// <summary>
|
||||
/// Retrieves the items.
|
||||
/// </summary>
|
||||
/// <param name="ids">The ids.</param>
|
||||
/// <returns>IEnumerable{BaseItem}.</returns>
|
||||
IEnumerable<BaseItem> GetItems(IEnumerable<Guid> ids);
|
||||
|
||||
/// <summary>
|
||||
/// Saves children of a given Folder
|
||||
/// </summary>
|
||||
|
||||
@@ -57,15 +57,9 @@ namespace MediaBrowser.Controller.Providers.Music
|
||||
|
||||
if (result != null)
|
||||
{
|
||||
if (!string.IsNullOrEmpty(result.Item1))
|
||||
if (!string.IsNullOrEmpty(result))
|
||||
{
|
||||
return result.Item1;
|
||||
}
|
||||
|
||||
// If there were no artists returned at all, then don't bother with musicbrainz
|
||||
if (!result.Item2)
|
||||
{
|
||||
return null;
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -94,7 +88,7 @@ namespace MediaBrowser.Controller.Providers.Music
|
||||
return artist != null ? artist.GetProviderId(MetadataProviders.Musicbrainz) : null;
|
||||
}
|
||||
|
||||
private async Task<Tuple<string,bool>> FindIdFromLastFm(BaseItem item, CancellationToken cancellationToken)
|
||||
private async Task<string> FindIdFromLastFm(BaseItem item, CancellationToken cancellationToken)
|
||||
{
|
||||
//Execute the Artist search against our name and assume first one is the one we want
|
||||
var url = RootUrl + string.Format("method=artist.search&artist={0}&api_key={1}&format=json", UrlEncode(item.Name), ApiKey);
|
||||
@@ -125,10 +119,10 @@ namespace MediaBrowser.Controller.Providers.Music
|
||||
var artist = searchResult.results.artistmatches.artist.FirstOrDefault(i => i.name != null && string.Compare(i.name, item.Name, CultureInfo.CurrentCulture, CompareOptions.IgnoreNonSpace) == 0) ??
|
||||
searchResult.results.artistmatches.artist.First();
|
||||
|
||||
return new Tuple<string, bool>(artist.mbid, true);
|
||||
return artist.mbid;
|
||||
}
|
||||
|
||||
return new Tuple<string,bool>(null, false);
|
||||
return null;
|
||||
}
|
||||
|
||||
private async Task<string> FindIdFromMusicBrainz(BaseItem item, CancellationToken cancellationToken)
|
||||
|
||||
@@ -146,7 +146,6 @@ namespace MediaBrowser.Controller.Providers.TV
|
||||
string name = episode.Name;
|
||||
string location = episode.Path;
|
||||
|
||||
Logger.Debug("TvDbProvider: Fetching episode data for: " + name);
|
||||
string epNum = TVUtils.EpisodeNumberFromFile(location, episode.Season != null);
|
||||
|
||||
if (epNum == null)
|
||||
|
||||
@@ -130,7 +130,6 @@ namespace MediaBrowser.Controller.Providers.TV
|
||||
{
|
||||
string name = season.Name;
|
||||
|
||||
Logger.Debug("TvDbProvider: Fetching season data: " + name);
|
||||
var seasonNumber = TVUtils.GetSeasonNumberFromPath(season.Path) ?? -1;
|
||||
|
||||
season.IndexNumber = seasonNumber;
|
||||
|
||||
@@ -193,7 +193,6 @@ namespace MediaBrowser.Controller.Providers.TV
|
||||
var success = false;
|
||||
|
||||
var name = series.Name;
|
||||
Logger.Debug("TvDbProvider: Fetching series data: " + name);
|
||||
|
||||
if (!string.IsNullOrEmpty(seriesId))
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user