mirror of
https://github.com/jellyfin/jellyfin.git
synced 2026-04-28 21:06:32 +01:00
Added a VirtualFolder entity, a resolver, and a CollectionType property.
This commit is contained in:
parent
a201eb060b
commit
a508a997d9
41
MediaBrowser.Controller/Resolvers/VirtualFolderResolver.cs
Normal file
41
MediaBrowser.Controller/Resolvers/VirtualFolderResolver.cs
Normal file
@@ -0,0 +1,41 @@
|
||||
using System.ComponentModel.Composition;
|
||||
using System.IO;
|
||||
using MediaBrowser.Controller.Events;
|
||||
using MediaBrowser.Model.Entities;
|
||||
|
||||
namespace MediaBrowser.Controller.Resolvers
|
||||
{
|
||||
[Export(typeof(IBaseItemResolver))]
|
||||
public class VirtualFolderResolver : BaseFolderResolver<VirtualFolder>
|
||||
{
|
||||
protected override VirtualFolder Resolve(ItemResolveEventArgs args)
|
||||
{
|
||||
if (args.IsFolder && args.Parent != null && args.Parent.IsRoot)
|
||||
{
|
||||
return new VirtualFolder();
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
protected override void SetItemValues(VirtualFolder item, ItemResolveEventArgs args)
|
||||
{
|
||||
// Set the name initially by stripping off the [CollectionType=...]
|
||||
// The name can always be overridden later by folder.xml
|
||||
string pathName = Path.GetFileNameWithoutExtension(args.Path);
|
||||
|
||||
string srch = "[collectiontype=";
|
||||
int index = pathName.IndexOf(srch, System.StringComparison.OrdinalIgnoreCase);
|
||||
|
||||
if (index != -1)
|
||||
{
|
||||
item.Name = pathName.Substring(0, index).Trim();
|
||||
|
||||
item.CollectionType = pathName.Substring(index + srch.Length).TrimEnd(']');
|
||||
}
|
||||
|
||||
base.SetItemValues(item, args);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user