mirror of
https://github.com/jellyfin/jellyfin.git
synced 2026-06-17 13:10:28 +01:00
Switched all i/o to win32 methods and added protobuf serialization for ffprobe caching
This commit is contained in:
parent
882e364326
commit
c80c8c1cfd
@@ -1,4 +1,5 @@
|
||||
using System.ComponentModel.Composition;
|
||||
using System.IO;
|
||||
using System.Threading.Tasks;
|
||||
using MediaBrowser.Controller.Events;
|
||||
using MediaBrowser.Controller.Xml;
|
||||
@@ -21,11 +22,9 @@ namespace MediaBrowser.Controller.Providers
|
||||
|
||||
public override Task FetchAsync(BaseEntity item, ItemResolveEventArgs args)
|
||||
{
|
||||
var metadataFile = args.GetFileSystemEntryByName("folder.xml");
|
||||
|
||||
if (metadataFile.HasValue)
|
||||
if (args.ContainsFile("folder.xml"))
|
||||
{
|
||||
return Task.Run(() => { new FolderXmlParser().Fetch(item as Folder, metadataFile.Value.Path); });
|
||||
return Task.Run(() => { new FolderXmlParser().Fetch(item as Folder, Path.Combine(args.Path, "folder.xml")); });
|
||||
}
|
||||
|
||||
return Task.FromResult<object>(null);
|
||||
|
||||
@@ -3,6 +3,7 @@ using System.ComponentModel.Composition;
|
||||
using System.IO;
|
||||
using System.Threading.Tasks;
|
||||
using MediaBrowser.Controller.Events;
|
||||
using MediaBrowser.Controller.IO;
|
||||
using MediaBrowser.Model.Entities;
|
||||
|
||||
namespace MediaBrowser.Controller.Providers
|
||||
@@ -22,27 +23,21 @@ namespace MediaBrowser.Controller.Providers
|
||||
|
||||
public async override Task FetchAsync(BaseEntity item, ItemResolveEventArgs args)
|
||||
{
|
||||
var trailerPath = args.GetFileSystemEntryByName("trailers", true);
|
||||
|
||||
if (trailerPath.HasValue)
|
||||
if (args.ContainsFolder("trailers"))
|
||||
{
|
||||
string[] allFiles = Directory.GetFileSystemEntries(trailerPath.Value.Path, "*", SearchOption.TopDirectoryOnly);
|
||||
List<Video> items = new List<Video>();
|
||||
|
||||
List<Video> localTrailers = new List<Video>();
|
||||
|
||||
for (int i = 0; i < allFiles.Length; i++)
|
||||
foreach (WIN32_FIND_DATA file in FileData.GetFileSystemEntries(Path.Combine(args.Path, "trailers"), "*"))
|
||||
{
|
||||
string file = allFiles[i];
|
||||
|
||||
Video video = await Kernel.Instance.ItemController.GetItem(file).ConfigureAwait(false) as Video;
|
||||
Video video = await Kernel.Instance.ItemController.GetItem(file.Path, fileInfo: file).ConfigureAwait(false) as Video;
|
||||
|
||||
if (video != null)
|
||||
{
|
||||
localTrailers.Add(video);
|
||||
items.Add(video);
|
||||
}
|
||||
}
|
||||
|
||||
(item as BaseItem).LocalTrailers = localTrailers;
|
||||
(item as BaseItem).LocalTrailers = items;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -183,6 +183,10 @@ namespace MediaBrowser.Controller.Providers
|
||||
base.Init();
|
||||
|
||||
AudioInfoProvider.EnsureCacheSubFolders(Kernel.Instance.ApplicationPaths.FFProbeVideoCacheDirectory);
|
||||
|
||||
ProtoBuf.Meta.RuntimeTypeModel.Default.Add(typeof(FFProbeResult), true);
|
||||
ProtoBuf.Meta.RuntimeTypeModel.Default.Add(typeof(MediaStream), true);
|
||||
ProtoBuf.Meta.RuntimeTypeModel.Default.Add(typeof(MediaFormat), true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user