This commit is contained in:
jianzhichu
2026-01-24 15:51:45 +08:00
parent 3f6b1874eb
commit e92e290a4e
10 changed files with 60 additions and 31 deletions
+1 -1
View File
@@ -196,7 +196,7 @@ namespace dy.net.Controllers
return saved ? ApiResult.Success() : ApiResult.Fail("添加失败");
}
private (bool Success, string Message) ValidatePaths(DouyinCookie cookie)
private static (bool Success, string Message) ValidatePaths(DouyinCookie cookie)
{
var pathsToCheck = new Dictionary<string, string>
{
+15 -7
View File
@@ -217,20 +217,28 @@ namespace dy.net
//commonService.UpdateCollectViedoType();
// 重置博主作品同步状态为未同步
//commonService.UpdateAllCookieSyncedToZero();
// 初始化Cookie
var cookieService = services.GetRequiredService<DouyinCookieService>();
var deploy = Appsettings.Get("deploy");
if (deploy != null && deploy == "docker")//docker环境直接初始化一个默认的配置
{
cookieService.InitCookie();
}
// 初始化配置
var config = commonService.InitConfig();
if (!isDevelopment)
//Serilog.Log.Debug("isRestart1=" + config.IsFirstRunning);
//if (!isDevelopment)
{
var cookie = cookieService.GetOpendCookies();
if (cookie != null && cookie.Any())
{
// 启动定时任务
var quartzJobService = services.GetRequiredService<DouyinQuartzJobService>();
quartzJobService.InitOrReStartAllJobs(config?.Cron <= 0 ? "30" : config.Cron.ToString());
}
// 初始化Cookie
var deploy = Appsettings.Get("deploy");
if (deploy != null && deploy == "docker")//docker环境直接初始化一个默认的配置
{
var cookieService = services.GetRequiredService<DouyinCookieService>();
cookieService.InitCookie();
}
}
catch (Exception ex)
@@ -3,7 +3,7 @@
<Project>
<PropertyGroup>
<_PublishTargetUrl>E:\code\dysync\bin\Release\net6.0\publish\</_PublishTargetUrl>
<History>True|2026-01-23T14:14:26.8066324Z||;True|2026-01-23T13:36:48.4086406+08:00||;True|2026-01-23T13:30:27.2924204+08:00||;True|2026-01-23T13:02:53.3219368+08:00||;True|2026-01-23T13:01:54.3466638+08:00||;True|2026-01-23T13:01:28.8560809+08:00||;True|2026-01-22T23:18:32.0400436+08:00||;True|2026-01-22T22:29:29.5746209+08:00||;True|2026-01-22T21:32:21.7284081+08:00||;True|2026-01-22T21:20:26.5985955+08:00||;False|2026-01-22T21:20:21.1372539+08:00||;True|2026-01-22T21:11:18.3771739+08:00||;True|2026-01-22T20:58:55.9862778+08:00||;True|2026-01-22T20:51:48.6699461+08:00||;False|2026-01-22T20:51:42.2079210+08:00||;True|2026-01-22T20:50:34.7280114+08:00||;True|2026-01-22T20:50:11.1588492+08:00||;True|2026-01-22T16:11:14.0626037+08:00||;True|2026-01-22T15:53:16.6377347+08:00||;True|2026-01-22T15:45:34.0935091+08:00||;True|2026-01-22T12:44:28.1577014+08:00||;True|2026-01-22T12:40:45.7449335+08:00||;True|2026-01-22T12:39:07.0683214+08:00||;True|2026-01-22T09:55:49.7086190+08:00||;True|2026-01-22T01:37:53.6972395+08:00||;True|2026-01-22T01:34:14.2142463+08:00||;True|2026-01-22T01:32:50.9228911+08:00||;True|2026-01-22T01:29:43.8871986+08:00||;True|2026-01-22T01:29:40.7838709+08:00||;True|2026-01-22T01:27:34.4763970+08:00||;True|2026-01-22T01:26:55.0117367+08:00||;True|2026-01-22T01:23:19.4789587+08:00||;True|2026-01-19T10:19:44.8997385+08:00||;True|2026-01-19T10:11:10.2305307+08:00||;True|2026-01-17T00:52:08.8180346+08:00||;False|2026-01-17T00:52:03.1829000+08:00||;True|2026-01-17T00:45:04.0498090+08:00||;True|2026-01-16T21:00:57.7239379+08:00||;True|2026-01-16T21:00:03.3912989+08:00||;True|2026-01-16T20:56:08.5505592+08:00||;True|2026-01-16T20:46:32.3067302+08:00||;True|2026-01-15T22:18:57.9835738+08:00||;True|2026-01-15T22:07:25.4753938+08:00||;True|2026-01-15T22:07:14.8243754+08:00||;True|2026-01-15T21:40:13.2613927+08:00||;True|2026-01-15T20:57:56.6291682+08:00||;True|2026-01-15T20:57:47.1363536+08:00||;True|2026-01-15T20:08:44.4710883+08:00||;True|2026-01-15T20:04:51.8284314+08:00||;False|2026-01-15T20:04:45.3258155+08:00||;True|2026-01-15T19:59:11.7907672+08:00||;True|2026-01-15T01:10:48.9066941+08:00||;True|2026-01-15T01:03:23.6216975+08:00||;True|2026-01-15T01:03:16.3364591+08:00||;False|2026-01-15T01:03:10.5654436+08:00||;True|2026-01-15T00:49:21.6559622+08:00||;True|2026-01-15T00:10:42.7288439+08:00||;True|2026-01-15T00:06:28.4241682+08:00||;True|2026-01-13T22:34:15.2372411+08:00||;True|2026-01-13T22:26:46.4522947+08:00||;True|2026-01-13T22:15:56.9735179+08:00||;True|2026-01-13T22:15:51.8250677+08:00||;False|2026-01-13T22:15:46.6608690+08:00||;True|2026-01-13T22:03:06.4683237+08:00||;False|2026-01-13T22:03:01.2036027+08:00||;True|2026-01-13T21:36:05.8776209+08:00||;True|2026-01-13T21:33:02.0766289+08:00||;False|2026-01-13T21:32:57.1976141+08:00||;True|2026-01-13T19:14:35.2519439+08:00||;True|2026-01-13T15:07:50.0836745+08:00||;False|2026-01-13T15:06:35.5929685+08:00||;True|2026-01-13T10:21:41.6012776+08:00||;True|2026-01-13T09:57:25.4788847+08:00||;True|2026-01-13T09:53:14.4900360+08:00||;True|2026-01-13T09:23:53.6465295+08:00||;True|2026-01-12T22:04:14.5886955+08:00||;False|2026-01-12T22:04:08.2008101+08:00||;True|2026-01-12T21:53:46.9947176+08:00||;True|2026-01-12T21:11:15.8358024+08:00||;True|2026-01-12T21:09:51.8663228+08:00||;True|2026-01-11T21:25:07.5052845+08:00||;False|2026-01-11T21:24:27.5744557+08:00||;True|2026-01-11T19:59:15.4734611+08:00||;False|2026-01-11T19:59:04.9543339+08:00||;True|2026-01-11T18:51:30.6649269+08:00||;True|2026-01-08T21:07:57.5094466+08:00||;True|2026-01-08T14:51:18.2266231+08:00||;True|2026-01-08T14:31:55.1137120+08:00||;True|2026-01-08T00:16:24.4451490+08:00||;True|2026-01-08T00:14:20.7430793+08:00||;True|2026-01-08T00:07:46.7228194+08:00||;True|2026-01-07T23:52:13.3290082+08:00||;True|2026-01-07T23:49:28.4838650+08:00||;True|2026-01-07T23:47:45.1936189+08:00||;True|2026-01-07T23:35:09.7818611+08:00||;True|2026-01-07T23:20:43.7462863+08:00||;True|2026-01-07T23:04:39.5140429+08:00||;False|2026-01-07T23:04:36.5367611+08:00||;True|2026-01-07T22:53:14.6013449+08:00||;True|2026-01-07T22:49:59.9549006+08:00||;</History>
<History>True|2026-01-24T07:47:01.6934638Z||;True|2026-01-24T15:32:35.6316009+08:00||;True|2026-01-24T15:16:28.7216639+08:00||;True|2026-01-23T22:14:26.8066324+08:00||;True|2026-01-23T13:36:48.4086406+08:00||;True|2026-01-23T13:30:27.2924204+08:00||;True|2026-01-23T13:02:53.3219368+08:00||;True|2026-01-23T13:01:54.3466638+08:00||;True|2026-01-23T13:01:28.8560809+08:00||;True|2026-01-22T23:18:32.0400436+08:00||;True|2026-01-22T22:29:29.5746209+08:00||;True|2026-01-22T21:32:21.7284081+08:00||;True|2026-01-22T21:20:26.5985955+08:00||;False|2026-01-22T21:20:21.1372539+08:00||;True|2026-01-22T21:11:18.3771739+08:00||;True|2026-01-22T20:58:55.9862778+08:00||;True|2026-01-22T20:51:48.6699461+08:00||;False|2026-01-22T20:51:42.2079210+08:00||;True|2026-01-22T20:50:34.7280114+08:00||;True|2026-01-22T20:50:11.1588492+08:00||;True|2026-01-22T16:11:14.0626037+08:00||;True|2026-01-22T15:53:16.6377347+08:00||;True|2026-01-22T15:45:34.0935091+08:00||;True|2026-01-22T12:44:28.1577014+08:00||;True|2026-01-22T12:40:45.7449335+08:00||;True|2026-01-22T12:39:07.0683214+08:00||;True|2026-01-22T09:55:49.7086190+08:00||;True|2026-01-22T01:37:53.6972395+08:00||;True|2026-01-22T01:34:14.2142463+08:00||;True|2026-01-22T01:32:50.9228911+08:00||;True|2026-01-22T01:29:43.8871986+08:00||;True|2026-01-22T01:29:40.7838709+08:00||;True|2026-01-22T01:27:34.4763970+08:00||;True|2026-01-22T01:26:55.0117367+08:00||;True|2026-01-22T01:23:19.4789587+08:00||;True|2026-01-19T10:19:44.8997385+08:00||;True|2026-01-19T10:11:10.2305307+08:00||;True|2026-01-17T00:52:08.8180346+08:00||;False|2026-01-17T00:52:03.1829000+08:00||;True|2026-01-17T00:45:04.0498090+08:00||;True|2026-01-16T21:00:57.7239379+08:00||;True|2026-01-16T21:00:03.3912989+08:00||;True|2026-01-16T20:56:08.5505592+08:00||;True|2026-01-16T20:46:32.3067302+08:00||;True|2026-01-15T22:18:57.9835738+08:00||;True|2026-01-15T22:07:25.4753938+08:00||;True|2026-01-15T22:07:14.8243754+08:00||;True|2026-01-15T21:40:13.2613927+08:00||;True|2026-01-15T20:57:56.6291682+08:00||;True|2026-01-15T20:57:47.1363536+08:00||;True|2026-01-15T20:08:44.4710883+08:00||;True|2026-01-15T20:04:51.8284314+08:00||;False|2026-01-15T20:04:45.3258155+08:00||;True|2026-01-15T19:59:11.7907672+08:00||;True|2026-01-15T01:10:48.9066941+08:00||;True|2026-01-15T01:03:23.6216975+08:00||;True|2026-01-15T01:03:16.3364591+08:00||;False|2026-01-15T01:03:10.5654436+08:00||;True|2026-01-15T00:49:21.6559622+08:00||;True|2026-01-15T00:10:42.7288439+08:00||;True|2026-01-15T00:06:28.4241682+08:00||;True|2026-01-13T22:34:15.2372411+08:00||;True|2026-01-13T22:26:46.4522947+08:00||;True|2026-01-13T22:15:56.9735179+08:00||;True|2026-01-13T22:15:51.8250677+08:00||;False|2026-01-13T22:15:46.6608690+08:00||;True|2026-01-13T22:03:06.4683237+08:00||;False|2026-01-13T22:03:01.2036027+08:00||;True|2026-01-13T21:36:05.8776209+08:00||;True|2026-01-13T21:33:02.0766289+08:00||;False|2026-01-13T21:32:57.1976141+08:00||;True|2026-01-13T19:14:35.2519439+08:00||;True|2026-01-13T15:07:50.0836745+08:00||;False|2026-01-13T15:06:35.5929685+08:00||;True|2026-01-13T10:21:41.6012776+08:00||;True|2026-01-13T09:57:25.4788847+08:00||;True|2026-01-13T09:53:14.4900360+08:00||;True|2026-01-13T09:23:53.6465295+08:00||;True|2026-01-12T22:04:14.5886955+08:00||;False|2026-01-12T22:04:08.2008101+08:00||;True|2026-01-12T21:53:46.9947176+08:00||;True|2026-01-12T21:11:15.8358024+08:00||;True|2026-01-12T21:09:51.8663228+08:00||;True|2026-01-11T21:25:07.5052845+08:00||;False|2026-01-11T21:24:27.5744557+08:00||;True|2026-01-11T19:59:15.4734611+08:00||;False|2026-01-11T19:59:04.9543339+08:00||;True|2026-01-11T18:51:30.6649269+08:00||;True|2026-01-08T21:07:57.5094466+08:00||;True|2026-01-08T14:51:18.2266231+08:00||;True|2026-01-08T14:31:55.1137120+08:00||;True|2026-01-08T00:16:24.4451490+08:00||;True|2026-01-08T00:14:20.7430793+08:00||;True|2026-01-08T00:07:46.7228194+08:00||;True|2026-01-07T23:52:13.3290082+08:00||;True|2026-01-07T23:49:28.4838650+08:00||;True|2026-01-07T23:47:45.1936189+08:00||;True|2026-01-07T23:35:09.7818611+08:00||;True|2026-01-07T23:20:43.7462863+08:00||;True|2026-01-07T23:04:39.5140429+08:00||;</History>
<LastFailureDetails />
</PropertyGroup>
</Project>
+1 -1
View File
@@ -478,7 +478,7 @@ const initFullChart = async () => {
try {
// 初始化全屏图表
fullChartInstance = echarts.init(fullChartRef.value);
const option = getChartOption(syncData.value);
const option = getChartOption(syncFullData.value);
// 调整全屏图表的网格和字号,优化显示效果
option.grid = {
left: '4%',
+2 -2
View File
@@ -264,7 +264,7 @@ namespace dy.net.job
{
var tag = cate?.Name ?? followed?.UperName ?? string.Empty;
tag = !string.IsNullOrWhiteSpace(tag) ? $"-[{tag}]" : tag;
Log.Debug($"[{VideoType.GetDesc()}][{cookie.UserName}]{tag},本次成功同步{syncCount}条视频");
Log.Debug($"[{cookie.UserName}][{VideoType.GetDesc()}]{tag},本次成功同步{syncCount}条视频");
if (cate != null)
{
@@ -487,7 +487,7 @@ namespace dy.net.job
var videos = new List<DouyinVideo>();
foreach (var item in data.AwemeList)
{
//if (item.AwemeId != "7440444948844956985")
//if (item.AwemeId != "7586278721292733722")
//{
// continue;
//}
+9 -11
View File
@@ -53,9 +53,7 @@ namespace dy.net.job
foreach (var ck in cookies)
{
Log.Information($"开始处理Cookie用户:[{ck.UserName}]ID{ck.Id}");
// 调用通用方法,传入差异化参数(无委托,参数直观)
if (ck.UseCollectFolder)
{
await SyncCollectGenericAsync(ck, VideoTypeEnum.dy_custom_collect,
@@ -116,7 +114,7 @@ namespace dy.net.job
}
await SyncFollowListAsync(ck, conf);
Log.Debug($"完成[{ck.UserName}] [列表]同步, 包括 [自定义收藏夹、关注、合集、短剧] ");
Log.Debug($"[{ck.UserName}]所有[基础数据(list)]同步完成,包括 [收藏列表、关注列表、合集列表、短剧列表] ");
}
}
@@ -163,7 +161,7 @@ namespace dy.net.job
if (currentItems?.Any() == true)
{
collectDataList.AddRange(currentItems.Select(entityConvertFunc));
Log.Debug($"[{cookie.UserName}] - {logTag}:获取{currentItems.Count}条,累计{collectDataList.Count}条");
Log.Debug($"[{cookie.UserName}][{logTag}]:获取{currentItems.Count}条,累计{collectDataList.Count}条");
}
}
@@ -171,16 +169,16 @@ namespace dy.net.job
if (collectDataList.Any())
{
var (add, update, delete, succ) = await _douyinCollectCateService.Sync(collectDataList, cookie.Id, cateType);
Log.Debug($"[{cookie.UserName}] - {logTag}:同步完成 新增:{add} 更新:{update} 删除:{delete} 成功:{succ}");
Log.Debug($"[{cookie.UserName}][{logTag}]:同步完成 新增:{add} 更新:{update} 删除:{delete} 成功:{succ}");
}
else
{
Log.Debug($"[{cookie.UserName}] - {logTag}:无有效数据");
Log.Debug($"[{cookie.UserName}][{logTag}]:无有效数据");
}
}
catch (Exception ex)
{
Log.Error(ex, $"[{cookie.UserName}] - {logTag}:同步失败");
Log.Error(ex, $"[{cookie.UserName}][{logTag}]:同步失败");
}
}
#endregion
@@ -190,7 +188,7 @@ namespace dy.net.job
{
if (string.IsNullOrWhiteSpace(cookie.SecUserId))
{
Log.Debug($"[{cookie.UserName}] - {LOG_TAG_FOLLOW}:未设置SecUserId,跳过");
Log.Debug($"[{cookie.UserName}][{LOG_TAG_FOLLOW}]:未设置SecUserId,跳过");
return;
}
@@ -237,20 +235,20 @@ namespace dy.net.job
followList.AddRange(data.Followings);
//Log.Debug($"[{cookie.UserName}] - {LOG_TAG_FOLLOW}:获取{data.Followings.Count}条,累计{followList.Count}条");
}
//Serilog.Log.Debug("isRestart2=" + config.IsFirstRunning);
if (!config.IsFirstRunning) hasMore = false;
}
if (followList.Any())
{
var (add, update, succ) = await _followService.Sync(followList, cookie);
Log.Information($"[{cookie.UserName}] - {LOG_TAG_FOLLOW}:同步完成 新增:{add} 更新:{update} 成功:{succ} 总关注数:{total}");
Log.Debug($"[{cookie.UserName}][{LOG_TAG_FOLLOW}]:同步完成 新增:{add} 更新:{update} 成功:{succ} 总关注数:{total}");
}
await _douyinCommonService.SetConfigNotFirstRunning();
}
catch (Exception ex)
{
Log.Error(ex, $"[{cookie.UserName}] - {LOG_TAG_FOLLOW}:同步失败");
Log.Error(ex, $"[{cookie.UserName}][{LOG_TAG_FOLLOW}]:同步失败");
}
}
#endregion
+19 -1
View File
@@ -12,7 +12,7 @@ namespace dy.net.repository
{
}
public async Task<List<DouyinCookie>> GetAllCookies(Expression<Func<DouyinCookie, bool>> whereExpression = null)
public async Task<List<DouyinCookie>> GetAllCookiesAsync(Expression<Func<DouyinCookie, bool>> whereExpression = null)
{
// 1. 初始化查询:先加固定条件 Status == 1
var query = Db.Queryable<DouyinCookie>()
@@ -29,6 +29,24 @@ namespace dy.net.repository
return await query.ToListAsync();
}
public List<DouyinCookie> GetAllCookies(Expression<Func<DouyinCookie, bool>> whereExpression = null)
{
// 1. 初始化查询:先加固定条件 Status == 1
var query = Db.Queryable<DouyinCookie>()
.Where(x => x.Status == 1)
.Where(x => !string.IsNullOrWhiteSpace(x.Cookies)); // 固定条件(必选)
// 2. 若传入自定义条件,叠加 Where(自动 AND 组合)
if (whereExpression != null)
{
query = query.Where(whereExpression); // 自定义条件(可选)
}
// 3. 执行查询(SqlSugar 自动合并所有 Where 条件)
return query.ToList();
}
public async Task<(List<DouyinCookie> list, int totalCount)> GetPagedAsync(int pageIndex, int pageSize)
{
var where = this.Db.Queryable<DouyinCookie>();
+1 -1
View File
@@ -97,7 +97,7 @@ namespace dy.net.service
else
{
int update = await sqlSugarClient.Updateable(config).ExecuteCommandAsync();
int update = await sqlSugarClient.Updateable(config).IgnoreColumns(x => new { x.IsFirstRunning }).ExecuteCommandAsync();
return update > 0;
}
+6 -1
View File
@@ -18,9 +18,14 @@ namespace dy.net.service
public Task<List<DouyinCookie>> GetOpendCookiesAsync(Expression<Func<DouyinCookie, bool>> whereExpression = null)
{
return _cookieRepository.GetAllCookies(whereExpression);
return _cookieRepository.GetAllCookiesAsync(whereExpression);
}
public List<DouyinCookie> GetOpendCookies()
{
return _cookieRepository.GetAllCookies();
}
public Task<List<DouyinCookie>> GetAllAsync()
{
return _cookieRepository.GetAllAsync();
+3 -3
View File
@@ -42,7 +42,7 @@ namespace dy.net.utils
{
Directory.CreateDirectory(actorsDir);
}
var nfoActorFullPath = Path.Combine(actorsDir, $"{video.Author}{fileExt}");
var nfoActorFullPath = Path.Combine(actorsDir, $"{DouyinFileNameHelper.SanitizeLinuxFileName(video.Author,"",true)}{fileExt}");
if (!File.Exists(nfoActorFullPath))
{
@@ -59,11 +59,11 @@ namespace dy.net.utils
Actors = new List<Actor>
{
new() {
Name = video.Author,
Name = DouyinFileNameHelper.SanitizeLinuxFileName(video.Author,"",true),
Role = "主演",
}
},
Author = video.Author,
Author = DouyinFileNameHelper.SanitizeLinuxFileName(video.Author, "", true),
Poster = "poster.jpg",
Title = video.VideoTitle,
Thumbnail = "poster.jpg",// 使用poster作为缩略图