aboutsummaryrefslogtreecommitdiff
path: root/Emby.Server.Implementations/Library/Resolvers/VideoExtraResolver.cs
diff options
context:
space:
mode:
authorJoe Rogers <1337joe@gmail.com>2021-12-22 22:37:49 +0100
committerCody Robibero (Rebase PR Action) <cody@robibe.ro>2021-12-24 21:21:19 +0000
commitc0ab54f0bdd51518ac803095ecf0a8d74945be30 (patch)
treedcdbd1868852fbc28a48575b393717ebaceeecf5 /Emby.Server.Implementations/Library/Resolvers/VideoExtraResolver.cs
parent60e75f7b700bb8ddc52d937892e2fcdaa57b9d6a (diff)
Fix resolved type for Trailers
Diffstat (limited to 'Emby.Server.Implementations/Library/Resolvers/VideoExtraResolver.cs')
-rw-r--r--Emby.Server.Implementations/Library/Resolvers/VideoExtraResolver.cs55
1 files changed, 55 insertions, 0 deletions
diff --git a/Emby.Server.Implementations/Library/Resolvers/VideoExtraResolver.cs b/Emby.Server.Implementations/Library/Resolvers/VideoExtraResolver.cs
new file mode 100644
index 000000000..9aadce88c
--- /dev/null
+++ b/Emby.Server.Implementations/Library/Resolvers/VideoExtraResolver.cs
@@ -0,0 +1,55 @@
+#nullable disable
+
+using Emby.Naming.Common;
+using MediaBrowser.Controller.Entities;
+using MediaBrowser.Controller.Library;
+using MediaBrowser.Controller.Resolvers;
+using MediaBrowser.Model.Entities;
+
+namespace Emby.Server.Implementations.Library.Resolvers
+{
+ /// <summary>
+ /// Resolves a Path into a Video or Video subclass.
+ /// </summary>
+ public class VideoExtraResolver : BaseVideoResolver<Video>
+ {
+ /// <summary>
+ /// Initializes a new instance of the <see cref="VideoExtraResolver"/> class.
+ /// </summary>
+ /// <param name="namingOptions">The naming options.</param>
+ public VideoExtraResolver(NamingOptions namingOptions)
+ : base(namingOptions)
+ {
+ }
+
+ /// <summary>
+ /// Gets the priority.
+ /// </summary>
+ /// <value>The priority.</value>
+ public override ResolverPriority Priority => ResolverPriority.Last;
+
+ /// <summary>
+ /// Resolves the specified args.
+ /// </summary>
+ /// <param name="args">The args.</param>
+ /// <returns>The video extra or null if not handled by this resolver.</returns>
+ public override Video Resolve(ItemResolveArgs args)
+ {
+ // Only handle owned items
+ if (args.Parent != null)
+ {
+ return null;
+ }
+
+ var ownedItem = base.Resolve(args);
+
+ // Re-resolve items that have their own type
+ if (ownedItem.ExtraType == ExtraType.Trailer)
+ {
+ ownedItem = ResolveVideo<Trailer>(args, false);
+ }
+
+ return ownedItem;
+ }
+ }
+}