Merge pull request #9403 from SenorSmartyPants/ExtraCleanAndNFO

Co-authored-by: Cody Robibero <cody@robibe.ro>
pull/9522/head
Cody Robibero 1 year ago committed by GitHub
commit dd491ce8ff
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -156,7 +156,8 @@ namespace Emby.Naming.Common
@"^(?<cleaned>.+?)(\[.*\])", @"^(?<cleaned>.+?)(\[.*\])",
@"^\s*(?<cleaned>.+?)\WE[0-9]+(-|~)E?[0-9]+(\W|$)", @"^\s*(?<cleaned>.+?)\WE[0-9]+(-|~)E?[0-9]+(\W|$)",
@"^\s*\[[^\]]+\](?!\.\w+$)\s*(?<cleaned>.+)", @"^\s*\[[^\]]+\](?!\.\w+$)\s*(?<cleaned>.+)",
@"^\s*(?<cleaned>.+?)\s+-\s+[0-9]+\s*$" @"^\s*(?<cleaned>.+?)\s+-\s+[0-9]+\s*$",
@"^\s*(?<cleaned>.+?)(([-._ ](trailer|sample))|-(scene|clip|behindthescenes|deleted|deletedscene|featurette|short|interview|other|extra))$"
}; };
SubtitleFileExtensions = new[] SubtitleFileExtensions = new[]

@ -87,8 +87,7 @@ namespace Emby.Naming.Video
name = cleanDateTimeResult.Name; name = cleanDateTimeResult.Name;
year = cleanDateTimeResult.Year; year = cleanDateTimeResult.Year;
if (extraResult.ExtraType is null if (TryCleanString(name, namingOptions, out var newName))
&& TryCleanString(name, namingOptions, out var newName))
{ {
name = newName; name = newName;
} }

@ -4,6 +4,7 @@ using System.IO;
using Emby.Naming.Common; using Emby.Naming.Common;
using Emby.Naming.Video; using Emby.Naming.Video;
using MediaBrowser.Controller.Entities; using MediaBrowser.Controller.Entities;
using MediaBrowser.Controller.Library;
using MediaBrowser.Controller.Providers; using MediaBrowser.Controller.Providers;
using MediaBrowser.Controller.Resolvers; using MediaBrowser.Controller.Resolvers;
using MediaBrowser.Model.Entities; using MediaBrowser.Model.Entities;
@ -15,7 +16,7 @@ namespace Emby.Server.Implementations.Library.Resolvers
/// <summary> /// <summary>
/// Resolves a Path into a Video or Video subclass. /// Resolves a Path into a Video or Video subclass.
/// </summary> /// </summary>
internal class ExtraResolver internal class ExtraResolver : BaseVideoResolver<Video>
{ {
private readonly NamingOptions _namingOptions; private readonly NamingOptions _namingOptions;
private readonly IItemResolver[] _trailerResolvers; private readonly IItemResolver[] _trailerResolvers;
@ -28,10 +29,16 @@ namespace Emby.Server.Implementations.Library.Resolvers
/// <param name="namingOptions">An instance of <see cref="NamingOptions"/>.</param> /// <param name="namingOptions">An instance of <see cref="NamingOptions"/>.</param>
/// <param name="directoryService">The directory service.</param> /// <param name="directoryService">The directory service.</param>
public ExtraResolver(ILogger<ExtraResolver> logger, NamingOptions namingOptions, IDirectoryService directoryService) public ExtraResolver(ILogger<ExtraResolver> logger, NamingOptions namingOptions, IDirectoryService directoryService)
: base(logger, namingOptions, directoryService)
{ {
_namingOptions = namingOptions; _namingOptions = namingOptions;
_trailerResolvers = new IItemResolver[] { new GenericVideoResolver<Trailer>(logger, namingOptions, directoryService) }; _trailerResolvers = new IItemResolver[] { new GenericVideoResolver<Trailer>(logger, namingOptions, directoryService) };
_videoResolvers = new IItemResolver[] { new GenericVideoResolver<Video>(logger, namingOptions, directoryService) }; _videoResolvers = new IItemResolver[] { this };
}
protected override Video Resolve(ItemResolveArgs args)
{
return ResolveVideo<Video>(args, true);
} }
/// <summary> /// <summary>

@ -404,12 +404,6 @@ namespace MediaBrowser.Providers.Manager
return false; return false;
} }
// Prevent owned items from reading the same local metadata file as their owner
if (!item.OwnerId.Equals(default) && provider is ILocalMetadataProvider)
{
return false;
}
if (includeDisabled) if (includeDisabled)
{ {
return true; return true;

@ -62,7 +62,8 @@ namespace MediaBrowser.XbmcMetadata.Savers
{ {
yield return Path.ChangeExtension(item.Path, ".nfo"); yield return Path.ChangeExtension(item.Path, ".nfo");
if (!item.IsInMixedFolder) // only allow movie object to read movie.nfo, not owned videos (which will be itemtype video, not movie)
if (!item.IsInMixedFolder && item.ItemType == typeof(Movie))
{ {
yield return Path.Combine(item.ContainingFolderPath, "movie.nfo"); yield return Path.Combine(item.ContainingFolderPath, "movie.nfo");
} }

@ -368,8 +368,8 @@ namespace Jellyfin.Providers.Tests.Manager
[Theory] [Theory]
[InlineData(nameof(ICustomMetadataProvider), true)] [InlineData(nameof(ICustomMetadataProvider), true)]
[InlineData(nameof(IRemoteMetadataProvider), true)] [InlineData(nameof(IRemoteMetadataProvider), true)]
[InlineData(nameof(ILocalMetadataProvider), false)] [InlineData(nameof(ILocalMetadataProvider), true)]
public void GetMetadataProviders_CanRefreshMetadataOwned_WhenNotLocal(string providerType, bool expected) public void GetMetadataProviders_CanRefreshMetadataOwned(string providerType, bool expected)
{ {
GetMetadataProviders_CanRefreshMetadata_Tester(providerType, expected, ownedItem: true); GetMetadataProviders_CanRefreshMetadata_Tester(providerType, expected, ownedItem: true);
} }

@ -79,6 +79,35 @@ public class FindExtrasTests
Assert.Equal(ExtraType.Sample, extras[2].ExtraType); Assert.Equal(ExtraType.Sample, extras[2].ExtraType);
} }
[Fact]
public void FindExtras_SeparateMovieFolder_CleanExtraNames()
{
var owner = new Movie { Name = "Up", Path = "/movies/Up/Up.mkv" };
var paths = new List<string>
{
"/movies/Up/Up.mkv",
"/movies/Up/Recording the audio[Bluray]-behindthescenes.mkv",
"/movies/Up/Interview with the dog-interview.mkv",
"/movies/Up/shorts/Balloons[1080p].mkv"
};
var files = paths.Select(p => new FileSystemMetadata
{
FullName = p,
IsDirectory = false
}).ToList();
var extras = _libraryManager.FindExtras(owner, files, new DirectoryService(_fileSystemMock.Object)).OrderBy(e => e.ExtraType).ToList();
Assert.Equal(3, extras.Count);
Assert.Equal(ExtraType.BehindTheScenes, extras[0].ExtraType);
Assert.Equal("Recording the audio", extras[0].Name);
Assert.Equal(ExtraType.Interview, extras[1].ExtraType);
Assert.Equal("Interview with the dog", extras[1].Name);
Assert.Equal(ExtraType.Short, extras[2].ExtraType);
Assert.Equal("Balloons", extras[2].Name);
}
[Fact] [Fact]
public void FindExtras_SeparateMovieFolderWithMixedExtras_FindsCorrectExtras() public void FindExtras_SeparateMovieFolderWithMixedExtras_FindsCorrectExtras()
{ {

Loading…
Cancel
Save