Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extras: Clean filename and process NFOs #9403

Merged
merged 5 commits into from
Mar 20, 2023
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion Emby.Naming/Common/NamingOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,8 @@ public NamingOptions()
@"^(?<cleaned>.+?)(\[.*\])",
@"^\s*(?<cleaned>.+?)\WE[0-9]+(-|~)E?[0-9]+(\W|$)",
@"^\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[]
Expand Down
3 changes: 1 addition & 2 deletions Emby.Naming/Video/VideoResolver.cs
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,7 @@ public static class VideoResolver
name = cleanDateTimeResult.Name;
year = cleanDateTimeResult.Year;

if (extraResult.ExtraType is null
&& TryCleanString(name, namingOptions, out var newName))
if (TryCleanString(name, namingOptions, out var newName))
{
name = newName;
}
Expand Down
11 changes: 9 additions & 2 deletions Emby.Server.Implementations/Library/Resolvers/ExtraResolver.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using Emby.Naming.Common;
using Emby.Naming.Video;
using MediaBrowser.Controller.Entities;
using MediaBrowser.Controller.Library;
using MediaBrowser.Controller.Providers;
using MediaBrowser.Controller.Resolvers;
using MediaBrowser.Model.Entities;
Expand All @@ -15,7 +16,7 @@ namespace Emby.Server.Implementations.Library.Resolvers
/// <summary>
/// Resolves a Path into a Video or Video subclass.
/// </summary>
internal class ExtraResolver
internal class ExtraResolver : BaseVideoResolver<Video>
{
private readonly NamingOptions _namingOptions;
private readonly IItemResolver[] _trailerResolvers;
Expand All @@ -28,10 +29,16 @@ internal class ExtraResolver
/// <param name="namingOptions">An instance of <see cref="NamingOptions"/>.</param>
/// <param name="directoryService">The directory service.</param>
public ExtraResolver(ILogger<ExtraResolver> logger, NamingOptions namingOptions, IDirectoryService directoryService)
: base(logger, namingOptions, directoryService)
{
_namingOptions = namingOptions;
_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>
Expand Down
6 changes: 0 additions & 6 deletions MediaBrowser.Providers/Manager/ProviderManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -404,12 +404,6 @@ private bool CanRefreshMetadata(
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)
{
return true;
Expand Down
3 changes: 2 additions & 1 deletion MediaBrowser.XbmcMetadata/Savers/MovieNfoSaver.cs
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,8 @@ internal static IEnumerable<string> GetMovieSavePaths(ItemInfo item)
{
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");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -368,8 +368,8 @@ public void GetMetadataProviders_CanRefreshMetadataSupportsLocal_WhenSupportsOrN
[Theory]
[InlineData(nameof(ICustomMetadataProvider), true)]
[InlineData(nameof(IRemoteMetadataProvider), true)]
[InlineData(nameof(ILocalMetadataProvider), false)]
public void GetMetadataProviders_CanRefreshMetadataOwned_WhenNotLocal(string providerType, bool expected)
[InlineData(nameof(ILocalMetadataProvider), true)]
public void GetMetadataProviders_CanRefreshMetadataOwned(string providerType, bool expected)
{
GetMetadataProviders_CanRefreshMetadata_Tester(providerType, expected, ownedItem: true);
}
Expand Down