docs: 为缩略图、最近文件相关新增类型补全中文 XML 文档注释
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
@@ -4,12 +4,22 @@ using System.Text;
|
||||
|
||||
namespace FileShare_Services.Services.FileLibrary
|
||||
{
|
||||
/// <summary>
|
||||
/// 视频缩略图服务实现,使用 ffmpeg 截取视频帧作为缩略图,使用 ffprobe 提取视频时长。
|
||||
/// </summary>
|
||||
public sealed class VideoThumbnailService : IVideoThumbnailService
|
||||
{
|
||||
/// <summary>缩略图文件存储目录的绝对路径。</summary>
|
||||
private readonly string _thumbnailDir;
|
||||
/// <summary>ffmpeg 可执行文件路径。</summary>
|
||||
private readonly string _ffmpegPath;
|
||||
/// <summary>ffprobe 可执行文件路径。</summary>
|
||||
private readonly string _ffprobePath;
|
||||
|
||||
/// <summary>
|
||||
/// 初始化视频缩略图服务,解析并验证配置路径,创建缩略图存储目录。
|
||||
/// </summary>
|
||||
/// <param name="options">缩略图存储配置选项。</param>
|
||||
public VideoThumbnailService(ThumbnailStorageOptions options)
|
||||
{
|
||||
_thumbnailDir = Path.IsPathRooted(options.RootPath)
|
||||
@@ -20,6 +30,7 @@ namespace FileShare_Services.Services.FileLibrary
|
||||
Directory.CreateDirectory(_thumbnailDir);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public Task<GeneratedThumbnail?> GenerateThumbnailAsync(int libraryRootId, string videoPath, CancellationToken ct = default)
|
||||
{
|
||||
var hash = ComputeHash(videoPath);
|
||||
@@ -69,6 +80,7 @@ namespace FileShare_Services.Services.FileLibrary
|
||||
}
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public string GetAbsolutePath(string relativePath)
|
||||
{
|
||||
var root = Path.GetFullPath(_thumbnailDir);
|
||||
@@ -82,6 +94,11 @@ namespace FileShare_Services.Services.FileLibrary
|
||||
return fullPath;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 解析可执行文件路径,支持绝对路径和相对于应用程序基目录的相对路径。
|
||||
/// </summary>
|
||||
/// <param name="executablePath">配置中的原始可执行文件路径。</param>
|
||||
/// <returns>可用的绝对路径。</returns>
|
||||
private static string ResolveExecutablePath(string executablePath)
|
||||
{
|
||||
if (Path.IsPathRooted(executablePath))
|
||||
@@ -95,6 +112,7 @@ namespace FileShare_Services.Services.FileLibrary
|
||||
: executablePath;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public double? GetVideoDuration(string videoPath)
|
||||
{
|
||||
try
|
||||
@@ -130,6 +148,11 @@ namespace FileShare_Services.Services.FileLibrary
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 计算视频文件路径的 MD5 哈希值,用于生成唯一的缩略图文件名。
|
||||
/// </summary>
|
||||
/// <param name="videoPath">视频文件的绝对路径。</param>
|
||||
/// <returns>小写的十六进制 MD5 哈希字符串。</returns>
|
||||
public string ComputeHash(string videoPath) =>
|
||||
Convert.ToHexString(MD5.HashData(Encoding.UTF8.GetBytes(videoPath))).ToLowerInvariant();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user