短剧、合集

This commit is contained in:
jianzhichu
2026-01-20 00:20:37 +08:00
parent 7c6ee0a8a6
commit 7175b3858a
25 changed files with 779 additions and 745 deletions
-69
View File
@@ -108,75 +108,6 @@ namespace dy.net.service
}
/// <summary>
/// 初始化一些数据,兼容旧版数据结构。
/// </summary>
public void UpdateCollectViedoType()
{
//更新视频类型字段-兼容老版本
string sql = @"UPDATE dy_collect_video
SET ViedoType = CASE
WHEN ViedoType = '0' THEN 0
WHEN ViedoType = '1' THEN 1
WHEN ViedoType = '2' THEN 2
WHEN ViedoType = '3' THEN 3
WHEN ViedoType = '4' THEN 4
ELSE NULL
END;";
sqlSugarClient.Ado.ExecuteCommand(sql);
//更新关注表的IsNoFollowed字段为空的数据为0--兼容老版本-新加的字段
string followUpdateSql = @"Update dy_follow SET IsNoFollowed=0 WHERE IsNoFollowed is NULL";
sqlSugarClient.Ado.ExecuteCommand(followUpdateSql);
//更新图片视频的合并状态
string updateIsMergeVideoSql = @"UPDATE dy_collect_video SET IsMergeVideo = 1 WHERE IsMergeVideo IS NULL and ViedoType='4';";
sqlSugarClient.Ado.ExecuteCommand(updateIsMergeVideoSql);
//更新非图片视频的合并状态
string updateNoIsMergeVideoSql = @"UPDATE dy_collect_video SET IsMergeVideo = 0 WHERE IsMergeVideo IS NULL and ViedoType<>'4';";
sqlSugarClient.Ado.ExecuteCommand(updateNoIsMergeVideoSql);
//强制开启去重
sqlSugarClient.Updateable<AppConfig>().SetColumns(x => new AppConfig { AutoDistinct = true }).Where(x => !string.IsNullOrWhiteSpace(x.Id)).ExecuteCommand();
//重新根据保存路径更新图片视频的类型为喜欢,收藏或关注
var collectViedos = sqlSugarClient.Queryable<DouyinVideo>().Where(x => x.ViedoType == VideoTypeEnum.ImageVideo).ToList();
if (collectViedos != null && collectViedos.Any())
{
var cookies = sqlSugarClient.Queryable<DouyinCookie>().ToList();
collectViedos.ForEach(x =>
{
var ck = cookies.FirstOrDefault(c => c.Id == x.CookieId);
if (ck != null)
{
var savePath = x.VideoSavePath;
if (savePath != null)
{
if (savePath.StartsWith(ck.SavePath))
{
x.ViedoType = VideoTypeEnum.dy_collects;
}
else if (savePath.StartsWith(ck.UpSavePath))
{
x.ViedoType = VideoTypeEnum.dy_follows;
}
else if (savePath.StartsWith(ck.FavSavePath))
{
x.ViedoType = VideoTypeEnum.dy_favorite;
}
else
{
x.ViedoType = VideoTypeEnum.dy_collects;
}
}
}
});
//只更新图片视频的类型
sqlSugarClient.Updateable(collectViedos).UpdateColumns(x => new DouyinVideo { ViedoType = x.ViedoType }).IgnoreColumns(true).ExecuteCommand();
}
}
/// <summary>
/// 重置所有Cookie的同步状态为0
/// </summary>