jellyfin/MediaBrowser.Providers/TV/SeriesMetadataService.cs

79 lines
3.2 KiB
C#
Raw Normal View History

2014-02-03 20:51:28 +00:00
using MediaBrowser.Common.IO;
using MediaBrowser.Controller.Configuration;
using MediaBrowser.Controller.Entities.TV;
using MediaBrowser.Controller.Library;
2015-01-17 18:15:09 +00:00
using MediaBrowser.Controller.Localization;
2014-02-03 20:51:28 +00:00
using MediaBrowser.Controller.Providers;
using MediaBrowser.Model.Entities;
using MediaBrowser.Model.Logging;
using MediaBrowser.Providers.Manager;
using System.Collections.Generic;
2015-01-28 21:29:02 +00:00
using System.Threading;
using System.Threading.Tasks;
2014-02-03 20:51:28 +00:00
namespace MediaBrowser.Providers.TV
{
2014-02-09 07:27:44 +00:00
public class SeriesMetadataService : MetadataService<Series, SeriesInfo>
2014-02-03 20:51:28 +00:00
{
2015-01-17 18:15:09 +00:00
private readonly ILocalizationManager _localization;
private readonly ILibraryManager _libraryManager;
2015-01-28 21:29:02 +00:00
public SeriesMetadataService(IServerConfigurationManager serverConfigurationManager, ILogger logger, IProviderManager providerManager, IProviderRepository providerRepo, IFileSystem fileSystem, IUserDataManager userDataManager, ILocalizationManager localization, ILibraryManager libraryManager)
: base(serverConfigurationManager, logger, providerManager, providerRepo, fileSystem, userDataManager)
2014-02-03 20:51:28 +00:00
{
2015-01-17 18:15:09 +00:00
_localization = localization;
_libraryManager = libraryManager;
2014-02-03 20:51:28 +00:00
}
/// <summary>
/// Merges the specified source.
/// </summary>
/// <param name="source">The source.</param>
/// <param name="target">The target.</param>
/// <param name="lockedFields">The locked fields.</param>
/// <param name="replaceData">if set to <c>true</c> [replace data].</param>
/// <param name="mergeMetadataSettings">if set to <c>true</c> [merge metadata settings].</param>
protected override void MergeData(Series source, Series target, List<MetadataFields> lockedFields, bool replaceData, bool mergeMetadataSettings)
{
ProviderUtils.MergeBaseItemData(source, target, lockedFields, replaceData, mergeMetadataSettings);
if (replaceData || target.SeasonCount == 0)
{
target.SeasonCount = source.SeasonCount;
}
if (replaceData || string.IsNullOrEmpty(target.AirTime))
{
target.AirTime = source.AirTime;
}
if (replaceData || !target.Status.HasValue)
{
target.Status = source.Status;
}
if (replaceData || target.AirDays.Count == 0)
{
target.AirDays = source.AirDays;
2015-01-28 21:29:02 +00:00
}
if (mergeMetadataSettings)
{
target.DisplaySpecialsWithSeasons = source.DisplaySpecialsWithSeasons;
}
2014-02-03 20:51:28 +00:00
}
2015-01-28 21:29:02 +00:00
protected override async Task AfterMetadataRefresh(Series item, MetadataRefreshOptions refreshOptions, CancellationToken cancellationToken)
{
await base.AfterMetadataRefresh(item, refreshOptions, cancellationToken).ConfigureAwait(false);
if (refreshOptions.IsPostRecursiveRefresh)
{
var provider = new DummySeasonProvider(ServerConfigurationManager, Logger, _localization, _libraryManager);
await provider.Run(item, CancellationToken.None).ConfigureAwait(false);
}
}
2014-02-03 20:51:28 +00:00
}
}