完成合集、短剧

This commit is contained in:
jianzhichu
2026-01-22 08:33:59 +08:00
parent 7175b3858a
commit e270397334
51 changed files with 3502 additions and 1411 deletions
+56 -33
View File
@@ -1,4 +1,5 @@
using System.Collections.Generic;
using dy.net.model.dto;
using System.Collections.Generic;
namespace dy.net.utils
{
@@ -8,6 +9,46 @@ namespace dy.net.utils
/// </summary>
public static class DouyinRequestParamManager
{
#region
/// <summary>
/// 私有静态只读基础参数模板(仅创建1次)
/// </summary>
private static readonly Dictionary<string, string> _baseParamTemplate = new Dictionary<string, string>
{
{"device_platform", "webapp"},
{"aid", "6383"},
{"channel", "channel_pc_web"},
{"pc_client_type", "1"},
{"pc_libra_divert", "Windows"},
{"cookie_enabled", "true"},
{"browser_language", "zh-CN"},
{"browser_platform", "Win32"},
{"browser_name", "Chrome"},
{"browser_online", "true"},
{"engine_name", "Blink"},
{"os_name", "Windows"},
{"os_version", "10"},
{"device_memory", "8"},
{"platform", "PC"},
{"downlink", "10"},
{"effective_type", "4g"},
{"round_trip_time", "0"},
{"update_version_code", "170400"},
{"whale_cut_token", ""}
};
/// <summary>
///
/// </summary>
/// <returns></returns>
private static Dictionary<string, string> InitBaseParams()
{
return new Dictionary<string, string>(_baseParamTemplate);
}
#endregion
#region
/// <summary>
/// 抖音全局域名
@@ -399,42 +440,24 @@ namespace dy.net.utils
}
#endregion
#region
/// <summary>
/// 私有静态只读基础参数模板(仅创建1次)
/// </summary>
private static readonly Dictionary<string, string> _baseParamTemplate = new Dictionary<string, string>
{
{"device_platform", "webapp"},
{"aid", "6383"},
{"channel", "channel_pc_web"},
{"pc_client_type", "1"},
{"pc_libra_divert", "Windows"},
{"cookie_enabled", "true"},
{"browser_language", "zh-CN"},
{"browser_platform", "Win32"},
{"browser_name", "Chrome"},
{"browser_online", "true"},
{"engine_name", "Blink"},
{"os_name", "Windows"},
{"os_version", "10"},
{"device_memory", "8"},
{"platform", "PC"},
{"downlink", "10"},
{"effective_type", "4g"},
{"round_trip_time", "0"},
{"update_version_code", "170400"},
{"whale_cut_token", ""}
};
/// <summary>
///
/// 获取视频类型名称
/// </summary>
/// <param name="videoType"></param>
/// <returns></returns>
private static Dictionary<string, string> InitBaseParams()
public static string GetDesc(this VideoTypeEnum videoType)
{
return new Dictionary<string, string>(_baseParamTemplate);
return videoType switch
{
VideoTypeEnum.dy_favorite => "喜欢",
VideoTypeEnum.dy_collects => "默认收藏夹",
VideoTypeEnum.dy_follows => "关注",
VideoTypeEnum.ImageVideo => "图文视频",
VideoTypeEnum.dy_custom_collect => "自定义收藏夹",
VideoTypeEnum.dy_mix => "合集",
VideoTypeEnum.dy_series => "短剧",
_ => string.Empty // 匹配所有未定义的枚举值,返回空字符串(替代原 default)
};
}
#endregion
}
}
+20 -8
View File
@@ -45,17 +45,17 @@ namespace dy.net.utils
}
var nfoActorFullPath = Path.Combine(actorsDir, $"{video.Author}{fileExt}");
if (File.Exists(nfoActorFullPath))
if (!File.Exists(nfoActorFullPath))
{
File.Delete(nfoActorFullPath);
File.Copy(video.AuthorAvatar, nfoActorFullPath, overwrite: true);
//File.Delete(video.AuthorAvatar);
}
// 执行复制(CopyTo支持覆盖,但先删除更可控)
File.Copy(video.AuthorAvatar, nfoActorFullPath, overwrite: true);
}
}
}
GenerateNfoFile(new DouyinVideoNfo
var nfoInfo= new DouyinVideoNfo
{
Actors = new List<Actor>
{
@@ -70,7 +70,19 @@ namespace dy.net.utils
Thumbnail = "poster.jpg",// 使用poster作为缩略图
ReleaseDate = video.CreateTime,
Genres = new List<string> { video.Tag1, video.Tag2, video.Tag3 }.Where(t => !string.IsNullOrWhiteSpace(t)).ToList()
}, nfoFullPath);
};
if (video.ViedoType == VideoTypeEnum.dy_mix || video.ViedoType == VideoTypeEnum.dy_series)
{
string directory = Path.GetDirectoryName(nfoFullPath);
nfoFullPath = Path.Combine(directory, "tvshow.nfo");
if (!File.Exists(nfoFullPath))
GenerateNfoFile(nfoInfo, nfoFullPath, "tvshow");
}
else
{
GenerateNfoFile(nfoInfo, nfoFullPath);
}
}
catch (Exception ex)
{
@@ -78,7 +90,7 @@ namespace dy.net.utils
}
}
private static void GenerateNfoFile(DouyinVideoNfo videoInfo, string filePath)
private static void GenerateNfoFile(DouyinVideoNfo videoInfo, string filePath,string xmlRoot= "movie")
{
try
{
@@ -89,7 +101,7 @@ namespace dy.net.utils
throw new ArgumentException("文件路径不能为空", nameof(filePath));
// 创建根元素
XElement root = new XElement("movie");
XElement root = new XElement(xmlRoot);
//root.Add(new XElement("outline"));
root.Add(new XElement("lockdata", true));
//root.Add(new XElement("director", videoInfo.Author));