Merge pull request #2421 from viaregio/master

#2407: Prefer episode and season numbers from the embedded MP4-metadata
This commit is contained in:
Vasily 2020-02-20 13:17:07 +03:00 committed by GitHub
commit c73370ad92
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 55 additions and 13 deletions

View File

@ -755,7 +755,18 @@ namespace Emby.Server.Implementations
serviceCollection.AddSingleton(UserManager);
LibraryManager = new LibraryManager(this, LoggerFactory, TaskManager, UserManager, ServerConfigurationManager, UserDataManager, () => LibraryMonitor, FileSystemManager, () => ProviderManager, () => UserViewManager);
MediaEncoder = new MediaBrowser.MediaEncoding.Encoder.MediaEncoder(
LoggerFactory.CreateLogger<MediaBrowser.MediaEncoding.Encoder.MediaEncoder>(),
ServerConfigurationManager,
FileSystemManager,
ProcessFactory,
LocalizationManager,
() => SubtitleEncoder,
_configuration,
StartupOptions.FFmpegPath);
serviceCollection.AddSingleton(MediaEncoder);
LibraryManager = new LibraryManager(this, LoggerFactory, TaskManager, UserManager, ServerConfigurationManager, UserDataManager, () => LibraryMonitor, FileSystemManager, () => ProviderManager, () => UserViewManager, MediaEncoder);
serviceCollection.AddSingleton(LibraryManager);
var musicManager = new MusicManager(LibraryManager);
@ -833,17 +844,6 @@ namespace Emby.Server.Implementations
ChapterManager = new ChapterManager(LibraryManager, LoggerFactory, ServerConfigurationManager, ItemRepository);
serviceCollection.AddSingleton(ChapterManager);
MediaEncoder = new MediaBrowser.MediaEncoding.Encoder.MediaEncoder(
LoggerFactory.CreateLogger<MediaBrowser.MediaEncoding.Encoder.MediaEncoder>(),
ServerConfigurationManager,
FileSystemManager,
ProcessFactory,
LocalizationManager,
() => SubtitleEncoder,
_configuration,
StartupOptions.FFmpegPath);
serviceCollection.AddSingleton(MediaEncoder);
EncodingManager = new MediaEncoder.EncodingManager(FileSystemManager, LoggerFactory, MediaEncoder, ChapterManager, LibraryManager);
serviceCollection.AddSingleton(EncodingManager);

View File

@ -29,11 +29,13 @@ using MediaBrowser.Controller.Entities.TV;
using MediaBrowser.Controller.IO;
using MediaBrowser.Controller.Library;
using MediaBrowser.Controller.LiveTv;
using MediaBrowser.Controller.MediaEncoding;
using MediaBrowser.Controller.Persistence;
using MediaBrowser.Controller.Providers;
using MediaBrowser.Controller.Resolvers;
using MediaBrowser.Controller.Sorting;
using MediaBrowser.Model.Configuration;
using MediaBrowser.Model.Dlna;
using MediaBrowser.Model.Dto;
using MediaBrowser.Model.Entities;
using MediaBrowser.Model.IO;
@ -141,6 +143,7 @@ namespace Emby.Server.Implementations.Library
public bool IsScanRunning { get; private set; }
private IServerApplicationHost _appHost;
private readonly IMediaEncoder _mediaEncoder;
/// <summary>
/// The _library items cache
@ -174,7 +177,8 @@ namespace Emby.Server.Implementations.Library
Func<ILibraryMonitor> libraryMonitorFactory,
IFileSystem fileSystem,
Func<IProviderManager> providerManagerFactory,
Func<IUserViewManager> userviewManager)
Func<IUserViewManager> userviewManager,
IMediaEncoder mediaEncoder)
{
_appHost = appHost;
_logger = loggerFactory.CreateLogger(nameof(LibraryManager));
@ -186,6 +190,7 @@ namespace Emby.Server.Implementations.Library
_fileSystem = fileSystem;
_providerManagerFactory = providerManagerFactory;
_userviewManager = userviewManager;
_mediaEncoder = mediaEncoder;
_libraryItemsCache = new ConcurrentDictionary<Guid, BaseItem>();
@ -2408,6 +2413,38 @@ namespace Emby.Server.Implementations.Library
episodeInfo = new Naming.TV.EpisodeInfo();
}
try
{
var libraryOptions = GetLibraryOptions(episode);
if (libraryOptions.EnableEmbeddedEpisodeInfos && string.Equals(episodeInfo.Container, "mp4", StringComparison.OrdinalIgnoreCase))
{
// Read from metadata
var mediaInfo = _mediaEncoder.GetMediaInfo(new MediaInfoRequest
{
MediaSource = episode.GetMediaSources(false)[0],
MediaType = DlnaProfileType.Video
}, CancellationToken.None).GetAwaiter().GetResult();
if (mediaInfo.ParentIndexNumber > 0)
{
episodeInfo.SeasonNumber = mediaInfo.ParentIndexNumber;
}
if (mediaInfo.IndexNumber > 0)
{
episodeInfo.EpisodeNumber = mediaInfo.IndexNumber;
}
if (!string.IsNullOrEmpty(mediaInfo.ShowName))
{
episodeInfo.SeriesName = mediaInfo.ShowName;
}
}
}
catch (Exception ex)
{
_logger.LogError(ex, "Error reading the episode informations with ffprobe. Episode: {EpisodeInfo}", episodeInfo.Path);
}
var changed = false;
if (episodeInfo.IsByDate)

View File

@ -112,6 +112,9 @@ namespace MediaBrowser.MediaEncoding.Probing
info.Name = title;
}
info.IndexNumber = FFProbeHelpers.GetDictionaryNumericValue(tags, "episode_sort");
info.ParentIndexNumber = FFProbeHelpers.GetDictionaryNumericValue(tags, "season_number");
info.ShowName = FFProbeHelpers.GetDictionaryValue(tags, "show_name");
info.ProductionYear = FFProbeHelpers.GetDictionaryNumericValue(tags, "date");
// Several different forms of retaildate

View File

@ -21,6 +21,7 @@ namespace MediaBrowser.Model.Configuration
public bool ImportMissingEpisodes { get; set; }
public bool EnableAutomaticSeriesGrouping { get; set; }
public bool EnableEmbeddedTitles { get; set; }
public bool EnableEmbeddedEpisodeInfos { get; set; }
public int AutomaticRefreshIntervalDays { get; set; }

View File

@ -36,6 +36,7 @@ namespace MediaBrowser.Model.MediaInfo
/// <value>The studios.</value>
public string[] Studios { get; set; }
public string[] Genres { get; set; }
public string ShowName { get; set; }
public int? IndexNumber { get; set; }
public int? ParentIndexNumber { get; set; }
public int? ProductionYear { get; set; }