mirror of
https://github.com/jellyfin/jellyfin.git
synced 2026-06-08 00:39:25 +01:00
added item type to refresh info
This commit is contained in:
62
MediaBrowser.Controller/Providers/DirectoryService.cs
Normal file
62
MediaBrowser.Controller/Providers/DirectoryService.cs
Normal file
@@ -0,0 +1,62 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using MediaBrowser.Model.Logging;
|
||||
|
||||
namespace MediaBrowser.Controller.Providers
|
||||
{
|
||||
public class DirectoryService
|
||||
{
|
||||
private readonly ILogger _logger;
|
||||
|
||||
private readonly Dictionary<string, List<FileSystemInfo>> _cache = new Dictionary<string, List<FileSystemInfo>>(StringComparer.OrdinalIgnoreCase);
|
||||
|
||||
public DirectoryService(ILogger logger)
|
||||
{
|
||||
_logger = logger;
|
||||
}
|
||||
|
||||
public List<FileSystemInfo> GetFileSystemEntries(string path)
|
||||
{
|
||||
List<FileSystemInfo> entries;
|
||||
|
||||
if (!_cache.TryGetValue(path, out entries))
|
||||
{
|
||||
//_logger.Debug("Getting files for " + path);
|
||||
|
||||
entries = new DirectoryInfo(path).EnumerateFileSystemInfos("*", SearchOption.TopDirectoryOnly).ToList();
|
||||
_cache.Add(path, entries);
|
||||
}
|
||||
|
||||
return entries;
|
||||
}
|
||||
|
||||
public IEnumerable<FileInfo> GetFiles(string path)
|
||||
{
|
||||
return GetFileSystemEntries(path).OfType<FileInfo>();
|
||||
}
|
||||
|
||||
public IEnumerable<DirectoryInfo> GetDirectories(string path)
|
||||
{
|
||||
return GetFileSystemEntries(path).OfType<DirectoryInfo>();
|
||||
}
|
||||
|
||||
public FileInfo GetFile(string path)
|
||||
{
|
||||
var directory = Path.GetDirectoryName(path);
|
||||
var filename = Path.GetFileName(path);
|
||||
|
||||
return GetFiles(directory).FirstOrDefault(i => string.Equals(i.Name, filename, StringComparison.OrdinalIgnoreCase));
|
||||
}
|
||||
|
||||
|
||||
public DirectoryInfo GetDirectory(string path)
|
||||
{
|
||||
var directory = Path.GetDirectoryName(path);
|
||||
var name = Path.GetFileName(path);
|
||||
|
||||
return GetDirectories(directory).FirstOrDefault(i => string.Equals(i.Name, name, StringComparison.OrdinalIgnoreCase));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
using System;
|
||||
using MediaBrowser.Controller.Entities;
|
||||
using MediaBrowser.Controller.Entities;
|
||||
using System;
|
||||
|
||||
namespace MediaBrowser.Controller.Providers
|
||||
{
|
||||
|
||||
@@ -17,7 +17,7 @@ namespace MediaBrowser.Controller.Providers
|
||||
|
||||
public interface ILocalImageFileProvider : ILocalImageProvider
|
||||
{
|
||||
List<LocalImageInfo> GetImages(IHasImages item);
|
||||
List<LocalImageInfo> GetImages(IHasImages item, DirectoryService directoryService);
|
||||
}
|
||||
|
||||
public class LocalImageInfo
|
||||
|
||||
@@ -149,4 +149,9 @@ namespace MediaBrowser.Controller.Providers
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public class SeasonInfo : ItemLookupInfo
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using MediaBrowser.Model.Logging;
|
||||
using System;
|
||||
|
||||
namespace MediaBrowser.Controller.Providers
|
||||
{
|
||||
@@ -16,6 +17,8 @@ namespace MediaBrowser.Controller.Providers
|
||||
/// </summary>
|
||||
[Obsolete]
|
||||
public bool ForceSave { get; set; }
|
||||
|
||||
public DirectoryService DirectoryService { get; set; }
|
||||
}
|
||||
|
||||
public class ImageRefreshOptions
|
||||
|
||||
@@ -18,6 +18,12 @@ namespace MediaBrowser.Controller.Providers
|
||||
/// <value>The name of the item.</value>
|
||||
public string ItemName { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the type of the item.
|
||||
/// </summary>
|
||||
/// <value>The type of the item.</value>
|
||||
public string ItemType { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the name of the series.
|
||||
/// </summary>
|
||||
|
||||
Reference in New Issue
Block a user