1、去重

2、分享
3、视频播放
4、批量删除,重新下载
5、自定义标题(仅博主视频)
6、授权页面去掉博主添加,新增关注列表
7、图文视频合成优化
8、其他优化
This commit is contained in:
jianzhichu
2025-11-30 00:42:25 +08:00
parent 63b51d211e
commit e6e9ff3cc3
94 changed files with 8155 additions and 1544 deletions
+127 -35
View File
@@ -15,50 +15,48 @@ namespace dy.net.repository
}
/// <summary>
/// 分页查询收藏视频
///
/// </summary>
/// <param name="pageIndex">页码(从1开始)</param>
/// <param name="pageSize">每页数量</param>
/// <param name="tag">可选标签过滤</param>
/// <param name="author">可选作者过滤</param>
/// <returns>分页结果(视频列表和总数)</returns>
public async Task<(List<DouyinVideo> list, int totalCount)> GetPagedAsync(int pageIndex, int pageSize, string tag = null, string author = null,string viedoType=null, List<string> dates = null)
/// <param name="dto"></param>
/// <returns></returns>
public async Task<(List<DouyinVideo> list, int totalCount)> GetPagedAsync(DouyinVideoPageRequestDto dto)
{
DateTime? start, end;
GetDateBetween(dto.Dates, out start, out end);
DateTime? start = null;
DateTime? end =null;
if(dates!=null && dates.Count==2)
DateTime? start2, end2;
GetDateBetween(dto.Dates2, out start2, out end2);
VideoTypeEnum? enumviedoType = null;
if (!string.IsNullOrEmpty(dto.ViedoType) && dto.ViedoType != "*")
{
start = Convert.ToDateTime(dates[0]);
end = Convert.ToDateTime(dates[1]);
enumviedoType = dto.ViedoType.ToVideoTypeEnum();
}
else if(dates!=null && dates.Count==1)
{
start = Convert.ToDateTime(dates[0]);
}
VideoTypeEnum? enumviedoType = null;
if (!string.IsNullOrEmpty(viedoType)&&viedoType!="*")
{
enumviedoType = viedoType.ToVideoTypeEnum();
}
var where = this.Db.Queryable<DouyinVideo>()
.WhereIF(!string.IsNullOrWhiteSpace(tag), x => x.Tag1 == tag)
.WhereIF(!string.IsNullOrWhiteSpace(author), x => x.Author == author)
//.WhereIF(!string.IsNullOrWhiteSpace(title), x => x.VideoTitle.Contains(title))
.WhereIF(!string.IsNullOrWhiteSpace(dto.Title), x => x.VideoTitle.Contains(dto.Title))
.WhereIF(!string.IsNullOrWhiteSpace(dto.Author), x => x.Author == dto.Author)
.WhereIF(start.HasValue, x => x.SyncTime >= start.Value)
.WhereIF(end.HasValue, x => x.SyncTime <= end.Value)
.WhereIF(start2.HasValue, x => x.CreateTime >= start2.Value)
.WhereIF(end2.HasValue, x => x.CreateTime <= end2.Value)
.WhereIF(enumviedoType.HasValue, x => x.ViedoType == enumviedoType);
var totalCount = await where.CountAsync();
var list = await where.OrderByDescending(x=>x.SyncTime).Skip((pageIndex - 1) * pageSize).Take(pageSize).ToListAsync();
if (list.Any()) {
var users= await this.Db.Queryable<DouyinUserCookie>().ToListAsync();
var list = await where.OrderByDescending(x => x.SyncTime).Skip((dto.PageIndex - 1) * dto.PageSize).Take(dto.PageSize).ToListAsync();
if (list.Any())
{
var users = await this.Db.Queryable<DouyinCookie>().ToListAsync();
foreach (var item in list)
{
var user= users.FirstOrDefault(x=>x.Id== item.CookieId);
if(user!=null)
var user = users.FirstOrDefault(x => x.Id == item.CookieId);
if (user != null)
{
item.DyUser = user.UserName;
}
@@ -67,19 +65,34 @@ namespace dy.net.repository
return (list, totalCount);
}
private static void GetDateBetween(List<string> dates, out DateTime? start, out DateTime? end)
{
start = null;
end = null;
if (dates != null && dates.Count == 2)
{
start = Convert.ToDateTime(dates[0]);
end = Convert.ToDateTime(dates[1]);
}
else if (dates != null && dates.Count == 1)
{
start = Convert.ToDateTime(dates[0]);
}
}
/// <summary>
///
/// 对于重复标题进行处理
/// </summary>
/// <param name="AuthorId"></param>
/// <param name="ViedoNameSimplify"></param>
/// <returns></returns>
public async Task<(string, string)> GetUperLastViedoFileName(string AuthorId,string ViedoNameSimplify)
public async Task<(string, string)> GetUperLastViedoFileName(string AuthorId, string ViedoNameSimplify)
{
var video= await this.Db.Queryable<DouyinVideo>().Where(x => x.AuthorId == AuthorId && x.ViedoType == VideoTypeEnum.UperPost)
.Where(x => x.VideoTitleSimplify == ViedoNameSimplify)
.OrderByDescending(x => x.CreateTime).FirstAsync();
var video = await this.Db.Queryable<DouyinVideo>().Where(x => x.AuthorId == AuthorId && x.ViedoType == VideoTypeEnum.UperPost)
.Where(x => x.VideoTitleSimplify == ViedoNameSimplify)
.OrderByDescending(x => x.CreateTime).FirstAsync();
if (video != null)
{
@@ -107,9 +120,88 @@ namespace dy.net.repository
{
return (ViedoNameSimplify, "");
}
}
/// <summary>
/// 根据视频ID列表获取视频信息
/// </summary>
/// <param name="ids"></param>
/// <returns></returns>
public async Task<List<DouyinVideo>> GetByIds(List<string> ids)
{
// 使用 Queryable 方法构建查询
return await this.Db.Queryable<DouyinVideo>()
.Where(x => ids.Contains(x.Id))
.ToListAsync();
}
/// <summary>
/// 记录要重新下载的视频
/// </summary>
/// <param name="downs"></param>
/// <returns></returns>
public bool InsertReDowns(List<ViedoReDown> downs)
{
if (downs != null)
{
return Db.Insertable(downs).ExecuteCommand() > 0;
}
else
{
return false;
}
}
/// <summary>
/// 更新视频重新下载状态
/// </summary>
/// <param name="videoId">视频ID(对应ViedoReDown.Id</param>
/// <param name="status">状态值(1时会同步更新下载时间)</param>
/// <returns>是否更新成功(影响行数>0</returns>
public async Task<bool> UpdateReDownStatus(string videoId, int status)
{
// 校验必填参数(避免无效数据库操作)
if (string.IsNullOrWhiteSpace(videoId))
{
Serilog.Log.Error("更新重新下载状态失败:videoId为空");
return false;
}
// 构建更新条件(统一Where条件,避免重复代码)
var updateable = Db.Updateable<ViedoReDown>()
.Where(it => it.Id == videoId)
.SetColumns(it => new ViedoReDown
{
Status = status,
UpdateTime = DateTime.Now
});
if (status == 1)
{
updateable = updateable.SetColumns(it => it.DownTime == DateTime.Now);
}
int affectedRows = await updateable.ExecuteCommandAsync();
// 可选:记录更新结果日志
if (affectedRows <= 0)
{
Serilog.Log.Debug("更新重新下载状态无匹配数据:videoId={0}, status={1}", videoId, status);
}
return affectedRows > 0;
}
/// <summary>
///
/// </summary>
/// <returns></returns>
public async Task<List<ViedoReDown>> GetViedoReDowns()
{
return await this.Db.Queryable<ViedoReDown>()
.Where(x => x.Status == 0 || x.Status == 2)
.ToListAsync();
}
}
}