Resolve name from episode folder
This commit is contained in:
parent
221d9373e8
commit
08ccf2a49c
|
@ -27,6 +27,7 @@ using MediaBrowser.Controller.Drawing;
|
|||
using MediaBrowser.Controller.Dto;
|
||||
using MediaBrowser.Controller.Entities;
|
||||
using MediaBrowser.Controller.Entities.Audio;
|
||||
using MediaBrowser.Controller.Entities.TV;
|
||||
using MediaBrowser.Controller.IO;
|
||||
using MediaBrowser.Controller.Library;
|
||||
using MediaBrowser.Controller.LiveTv;
|
||||
|
@ -48,6 +49,7 @@ using MediaBrowser.Providers.MediaInfo;
|
|||
using Microsoft.Extensions.Caching.Memory;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Episode = MediaBrowser.Controller.Entities.TV.Episode;
|
||||
using EpisodeInfo = Emby.Naming.TV.EpisodeInfo;
|
||||
using Genre = MediaBrowser.Controller.Entities.Genre;
|
||||
using Person = MediaBrowser.Controller.Entities.Person;
|
||||
using VideoResolver = Emby.Naming.Video.VideoResolver;
|
||||
|
@ -2512,7 +2514,7 @@ namespace Emby.Server.Implementations.Library
|
|||
public bool FillMissingEpisodeNumbersFromPath(Episode episode, bool forceRefresh)
|
||||
{
|
||||
var series = episode.Series;
|
||||
bool? isAbsoluteNaming = series == null ? false : string.Equals(series.DisplayOrder, "absolute", StringComparison.OrdinalIgnoreCase);
|
||||
bool? isAbsoluteNaming = series != null && string.Equals(series.DisplayOrder, "absolute", StringComparison.OrdinalIgnoreCase);
|
||||
if (!isAbsoluteNaming.Value)
|
||||
{
|
||||
// In other words, no filter applied
|
||||
|
@ -2524,9 +2526,32 @@ namespace Emby.Server.Implementations.Library
|
|||
var isFolder = episode.VideoType == VideoType.BluRay || episode.VideoType == VideoType.Dvd;
|
||||
|
||||
// TODO nullable - what are we trying to do there with empty episodeInfo?
|
||||
var episodeInfo = episode.IsFileProtocol
|
||||
? resolver.Resolve(episode.Path, isFolder, null, null, isAbsoluteNaming) ?? new Naming.TV.EpisodeInfo(episode.Path)
|
||||
: new Naming.TV.EpisodeInfo(episode.Path);
|
||||
EpisodeInfo episodeInfo = null;
|
||||
if (episode.IsFileProtocol)
|
||||
{
|
||||
episodeInfo = resolver.Resolve(episode.Path, isFolder, null, null, isAbsoluteNaming) ?? new EpisodeInfo(episode.Path);
|
||||
// Resolve from parent folder if it's not the Season folder
|
||||
if (!episodeInfo.EpisodeNumber.HasValue && episode.Parent is not Season)
|
||||
{
|
||||
var episodeInfoFromFolder = resolver.Resolve(Path.GetDirectoryName(episode.Path)!, true, null, null, isAbsoluteNaming);
|
||||
// merge the missing information
|
||||
episodeInfo.SeriesName = episodeInfoFromFolder?.SeriesName;
|
||||
episodeInfo.EpisodeNumber ??= episodeInfoFromFolder?.EpisodeNumber;
|
||||
episodeInfo.EndingEpisodeNumber ??= episodeInfoFromFolder?.EndingEpisodeNumber;
|
||||
episodeInfo.SeasonNumber ??= episodeInfoFromFolder?.SeasonNumber;
|
||||
episodeInfo.Container ??= episodeInfoFromFolder?.Container;
|
||||
episodeInfo.Format3D ??= episodeInfoFromFolder?.Format3D;
|
||||
episodeInfo.Is3D = episodeInfoFromFolder?.Is3D ?? episodeInfo.Is3D;
|
||||
episodeInfo.IsStub = episodeInfoFromFolder?.IsStub ?? episodeInfo.IsStub;
|
||||
episodeInfo.StubType = episodeInfoFromFolder?.StubType;
|
||||
episodeInfo.IsByDate = episodeInfoFromFolder?.IsStub ?? episodeInfo.IsByDate;
|
||||
episodeInfo.Day ??= episodeInfoFromFolder?.Day;
|
||||
episodeInfo.Month ??= episodeInfoFromFolder?.Month;
|
||||
episodeInfo.Year ??= episodeInfoFromFolder?.Year;
|
||||
}
|
||||
}
|
||||
|
||||
episodeInfo ??= new EpisodeInfo(episode.Path);
|
||||
|
||||
try
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue
Block a user