mirror of
https://github.com/jellyfin/jellyfin.git
synced 2025-07-09 03:04:24 -04:00
update people saving
This commit is contained in:
parent
8afd04ae37
commit
b3dd4beb8a
@ -8,6 +8,7 @@ using MediaBrowser.Model.Dlna;
|
|||||||
using MediaBrowser.Model.Entities;
|
using MediaBrowser.Model.Entities;
|
||||||
using MediaBrowser.Model.MediaInfo;
|
using MediaBrowser.Model.MediaInfo;
|
||||||
using MediaBrowser.Model.Serialization;
|
using MediaBrowser.Model.Serialization;
|
||||||
|
using System.Collections.Generic;
|
||||||
using System.Globalization;
|
using System.Globalization;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
@ -22,15 +23,17 @@ namespace MediaBrowser.Providers.MediaInfo
|
|||||||
private readonly IItemRepository _itemRepo;
|
private readonly IItemRepository _itemRepo;
|
||||||
private readonly IApplicationPaths _appPaths;
|
private readonly IApplicationPaths _appPaths;
|
||||||
private readonly IJsonSerializer _json;
|
private readonly IJsonSerializer _json;
|
||||||
|
private readonly ILibraryManager _libraryManager;
|
||||||
|
|
||||||
private readonly CultureInfo _usCulture = new CultureInfo("en-US");
|
private readonly CultureInfo _usCulture = new CultureInfo("en-US");
|
||||||
|
|
||||||
public FFProbeAudioInfo(IMediaEncoder mediaEncoder, IItemRepository itemRepo, IApplicationPaths appPaths, IJsonSerializer json)
|
public FFProbeAudioInfo(IMediaEncoder mediaEncoder, IItemRepository itemRepo, IApplicationPaths appPaths, IJsonSerializer json, ILibraryManager libraryManager)
|
||||||
{
|
{
|
||||||
_mediaEncoder = mediaEncoder;
|
_mediaEncoder = mediaEncoder;
|
||||||
_itemRepo = itemRepo;
|
_itemRepo = itemRepo;
|
||||||
_appPaths = appPaths;
|
_appPaths = appPaths;
|
||||||
_json = json;
|
_json = json;
|
||||||
|
_libraryManager = libraryManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<ItemUpdateType> Probe<T>(T item, CancellationToken cancellationToken)
|
public async Task<ItemUpdateType> Probe<T>(T item, CancellationToken cancellationToken)
|
||||||
@ -96,7 +99,7 @@ namespace MediaBrowser.Providers.MediaInfo
|
|||||||
/// <param name="cancellationToken">The cancellation token.</param>
|
/// <param name="cancellationToken">The cancellation token.</param>
|
||||||
/// <param name="mediaInfo">The media information.</param>
|
/// <param name="mediaInfo">The media information.</param>
|
||||||
/// <returns>Task.</returns>
|
/// <returns>Task.</returns>
|
||||||
protected Task Fetch(Audio audio, CancellationToken cancellationToken, Model.MediaInfo.MediaInfo mediaInfo)
|
protected async Task Fetch(Audio audio, CancellationToken cancellationToken, Model.MediaInfo.MediaInfo mediaInfo)
|
||||||
{
|
{
|
||||||
var mediaStreams = mediaInfo.MediaStreams;
|
var mediaStreams = mediaInfo.MediaStreams;
|
||||||
|
|
||||||
@ -110,9 +113,9 @@ namespace MediaBrowser.Providers.MediaInfo
|
|||||||
var extension = (Path.GetExtension(audio.Path) ?? string.Empty).TrimStart('.');
|
var extension = (Path.GetExtension(audio.Path) ?? string.Empty).TrimStart('.');
|
||||||
audio.Container = extension;
|
audio.Container = extension;
|
||||||
|
|
||||||
FetchDataFromTags(audio, mediaInfo);
|
await FetchDataFromTags(audio, mediaInfo).ConfigureAwait(false);
|
||||||
|
|
||||||
return _itemRepo.SaveMediaStreams(audio.Id, mediaStreams, cancellationToken);
|
await _itemRepo.SaveMediaStreams(audio.Id, mediaStreams, cancellationToken).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -120,7 +123,7 @@ namespace MediaBrowser.Providers.MediaInfo
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="audio">The audio.</param>
|
/// <param name="audio">The audio.</param>
|
||||||
/// <param name="data">The data.</param>
|
/// <param name="data">The data.</param>
|
||||||
private void FetchDataFromTags(Audio audio, Model.MediaInfo.MediaInfo data)
|
private async Task FetchDataFromTags(Audio audio, Model.MediaInfo.MediaInfo data)
|
||||||
{
|
{
|
||||||
// Only set Name if title was found in the dictionary
|
// Only set Name if title was found in the dictionary
|
||||||
if (!string.IsNullOrEmpty(data.Title))
|
if (!string.IsNullOrEmpty(data.Title))
|
||||||
@ -130,17 +133,19 @@ namespace MediaBrowser.Providers.MediaInfo
|
|||||||
|
|
||||||
if (!audio.LockedFields.Contains(MetadataFields.Cast))
|
if (!audio.LockedFields.Contains(MetadataFields.Cast))
|
||||||
{
|
{
|
||||||
audio.People.Clear();
|
var people = new List<PersonInfo>();
|
||||||
|
|
||||||
foreach (var person in data.People)
|
foreach (var person in data.People)
|
||||||
{
|
{
|
||||||
PeopleHelper.AddPerson(audio.People, new PersonInfo
|
PeopleHelper.AddPerson(people, new PersonInfo
|
||||||
{
|
{
|
||||||
Name = person.Name,
|
Name = person.Name,
|
||||||
Type = person.Type,
|
Type = person.Type,
|
||||||
Role = person.Role
|
Role = person.Role
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
await _libraryManager.UpdatePeople(audio, people).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
audio.Album = data.Album;
|
audio.Album = data.Album;
|
||||||
|
@ -46,10 +46,11 @@ namespace MediaBrowser.Providers.MediaInfo
|
|||||||
private readonly IServerConfigurationManager _config;
|
private readonly IServerConfigurationManager _config;
|
||||||
private readonly ISubtitleManager _subtitleManager;
|
private readonly ISubtitleManager _subtitleManager;
|
||||||
private readonly IChapterManager _chapterManager;
|
private readonly IChapterManager _chapterManager;
|
||||||
|
private readonly ILibraryManager _libraryManager;
|
||||||
|
|
||||||
private readonly CultureInfo _usCulture = new CultureInfo("en-US");
|
private readonly CultureInfo _usCulture = new CultureInfo("en-US");
|
||||||
|
|
||||||
public FFProbeVideoInfo(ILogger logger, IIsoManager isoManager, IMediaEncoder mediaEncoder, IItemRepository itemRepo, IBlurayExaminer blurayExaminer, ILocalizationManager localization, IApplicationPaths appPaths, IJsonSerializer json, IEncodingManager encodingManager, IFileSystem fileSystem, IServerConfigurationManager config, ISubtitleManager subtitleManager, IChapterManager chapterManager)
|
public FFProbeVideoInfo(ILogger logger, IIsoManager isoManager, IMediaEncoder mediaEncoder, IItemRepository itemRepo, IBlurayExaminer blurayExaminer, ILocalizationManager localization, IApplicationPaths appPaths, IJsonSerializer json, IEncodingManager encodingManager, IFileSystem fileSystem, IServerConfigurationManager config, ISubtitleManager subtitleManager, IChapterManager chapterManager, ILibraryManager libraryManager)
|
||||||
{
|
{
|
||||||
_logger = logger;
|
_logger = logger;
|
||||||
_isoManager = isoManager;
|
_isoManager = isoManager;
|
||||||
@ -64,6 +65,7 @@ namespace MediaBrowser.Providers.MediaInfo
|
|||||||
_config = config;
|
_config = config;
|
||||||
_subtitleManager = subtitleManager;
|
_subtitleManager = subtitleManager;
|
||||||
_chapterManager = chapterManager;
|
_chapterManager = chapterManager;
|
||||||
|
_libraryManager = libraryManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<ItemUpdateType> ProbeVideo<T>(T item,
|
public async Task<ItemUpdateType> ProbeVideo<T>(T item,
|
||||||
@ -219,6 +221,7 @@ namespace MediaBrowser.Providers.MediaInfo
|
|||||||
await AddExternalSubtitles(video, mediaStreams, options, cancellationToken).ConfigureAwait(false);
|
await AddExternalSubtitles(video, mediaStreams, options, cancellationToken).ConfigureAwait(false);
|
||||||
|
|
||||||
FetchEmbeddedInfo(video, mediaInfo, options);
|
FetchEmbeddedInfo(video, mediaInfo, options);
|
||||||
|
await FetchPeople(video, mediaInfo, options).ConfigureAwait(false);
|
||||||
|
|
||||||
video.IsHD = mediaStreams.Any(i => i.Type == MediaStreamType.Video && i.Width.HasValue && i.Width.Value >= 1270);
|
video.IsHD = mediaStreams.Any(i => i.Type == MediaStreamType.Video && i.Width.HasValue && i.Width.Value >= 1270);
|
||||||
|
|
||||||
@ -370,24 +373,6 @@ namespace MediaBrowser.Providers.MediaInfo
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!video.LockedFields.Contains(MetadataFields.Cast))
|
|
||||||
{
|
|
||||||
if (video.People.Count == 0 || isFullRefresh)
|
|
||||||
{
|
|
||||||
video.People.Clear();
|
|
||||||
|
|
||||||
foreach (var person in data.People)
|
|
||||||
{
|
|
||||||
PeopleHelper.AddPerson(video.People, new PersonInfo
|
|
||||||
{
|
|
||||||
Name = person.Name,
|
|
||||||
Type = person.Type,
|
|
||||||
Role = person.Role
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!video.LockedFields.Contains(MetadataFields.Genres))
|
if (!video.LockedFields.Contains(MetadataFields.Genres))
|
||||||
{
|
{
|
||||||
if (video.Genres.Count == 0 || isFullRefresh)
|
if (video.Genres.Count == 0 || isFullRefresh)
|
||||||
@ -458,6 +443,31 @@ namespace MediaBrowser.Providers.MediaInfo
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private async Task FetchPeople(Video video, Model.MediaInfo.MediaInfo data, MetadataRefreshOptions options)
|
||||||
|
{
|
||||||
|
var isFullRefresh = options.MetadataRefreshMode == MetadataRefreshMode.FullRefresh;
|
||||||
|
|
||||||
|
if (!video.LockedFields.Contains(MetadataFields.Cast))
|
||||||
|
{
|
||||||
|
if (isFullRefresh || _libraryManager.GetPeople(video).Count == 0)
|
||||||
|
{
|
||||||
|
var people = new List<PersonInfo>();
|
||||||
|
|
||||||
|
foreach (var person in data.People)
|
||||||
|
{
|
||||||
|
PeopleHelper.AddPerson(people, new PersonInfo
|
||||||
|
{
|
||||||
|
Name = person.Name,
|
||||||
|
Type = person.Type,
|
||||||
|
Role = person.Role
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
await _libraryManager.UpdatePeople(video, people);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private SubtitleOptions GetOptions()
|
private SubtitleOptions GetOptions()
|
||||||
{
|
{
|
||||||
return _config.GetConfiguration<SubtitleOptions>("subtitles");
|
return _config.GetConfiguration<SubtitleOptions>("subtitles");
|
||||||
|
@ -314,11 +314,6 @@ namespace MediaBrowser.Providers.TV
|
|||||||
{
|
{
|
||||||
using (var streamReader = new StreamReader(xmlFile, Encoding.UTF8))
|
using (var streamReader = new StreamReader(xmlFile, Encoding.UTF8))
|
||||||
{
|
{
|
||||||
if (!item.LockedFields.Contains(MetadataFields.Cast))
|
|
||||||
{
|
|
||||||
item.People.Clear();
|
|
||||||
}
|
|
||||||
|
|
||||||
// Use XmlReader for best performance
|
// Use XmlReader for best performance
|
||||||
using (var reader = XmlReader.Create(streamReader, new XmlReaderSettings
|
using (var reader = XmlReader.Create(streamReader, new XmlReaderSettings
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user