1、完成图片视频
2、优化定时任务,抽出基类服务 3、todo:日志保存时间设置,默认10天 4、todo:同一个视频-只下载一次。就是对于收藏了,又喜欢了,或者又刚好是关注的up主,看哪个定时任务先同步到,后面就不在重复下载了
This commit is contained in:
@@ -53,7 +53,7 @@ namespace dy.net.job
|
||||
return data?.Cursor ?? "0";
|
||||
}
|
||||
|
||||
protected override string CreateSaveFolder(DouyinUserCookie cookie, Aweme item, string tag1, string tag2)
|
||||
protected override string CreateSaveFolder(DouyinUserCookie cookie, Aweme item, string tag1, string tag2, AppConfig config)
|
||||
{
|
||||
var safeTag1 = string.IsNullOrWhiteSpace(tag1) ? "other" : TikTokFileNameHelper.SanitizePath(tag1);
|
||||
var folder = Path.Combine(cookie.SavePath, safeTag1, $"{TikTokFileNameHelper.SanitizePath(item.Desc)}@{item.AwemeId}");
|
||||
@@ -61,8 +61,9 @@ namespace dy.net.job
|
||||
return folder;
|
||||
}
|
||||
|
||||
protected override string GetVideoFileName(DouyinUserCookie cookie, Aweme item, VideoBitRate bitRate)
|
||||
protected override string GetVideoFileName(DouyinUserCookie cookie, Aweme item)
|
||||
{
|
||||
var bitRate=item.Video.BitRate.FirstOrDefault();
|
||||
return $"{item.AwemeId}.{bitRate.Format}";
|
||||
}
|
||||
|
||||
|
||||
@@ -46,7 +46,7 @@ namespace dy.net.job
|
||||
return data?.MaxCursor ?? "0";
|
||||
}
|
||||
|
||||
protected override string CreateSaveFolder(DouyinUserCookie cookie, Aweme item, string tag1, string tag2)
|
||||
protected override string CreateSaveFolder(DouyinUserCookie cookie, Aweme item, string tag1, string tag2, AppConfig config)
|
||||
{
|
||||
var safeTag1 = string.IsNullOrWhiteSpace(tag1) ? "other" : TikTokFileNameHelper.SanitizePath(tag1);
|
||||
var folder = Path.Combine(cookie.FavSavePath, safeTag1, $"{TikTokFileNameHelper.SanitizePath(item.Desc)}@{item.AwemeId}");
|
||||
@@ -54,8 +54,9 @@ namespace dy.net.job
|
||||
return folder;
|
||||
}
|
||||
|
||||
protected override string GetVideoFileName(DouyinUserCookie cookie, Aweme item, VideoBitRate bitRate)
|
||||
protected override string GetVideoFileName(DouyinUserCookie cookie, Aweme item)
|
||||
{
|
||||
var bitRate = item.Video.BitRate.FirstOrDefault();
|
||||
return $"{item.AwemeId}.{bitRate.Format}";
|
||||
}
|
||||
|
||||
|
||||
@@ -51,25 +51,63 @@ namespace dy.net.job
|
||||
return data?.MaxCursor ?? "0";
|
||||
}
|
||||
|
||||
protected override string CreateSaveFolder(DouyinUserCookie cookie, Aweme item, string tag1, string tag2)
|
||||
protected override string CreateSaveFolder(DouyinUserCookie cookie, Aweme item, string tag1, string tag2,AppConfig config)
|
||||
{
|
||||
// UP主视频通常按作者名创建文件夹
|
||||
var authorName = string.IsNullOrWhiteSpace(item.Author?.Nickname) ? "UnknownAuthor" : TikTokFileNameHelper.SanitizePath(item.Author.Nickname);
|
||||
var folder = Path.Combine(cookie.UpSavePath, authorName);
|
||||
if (!Directory.Exists(folder)) Directory.CreateDirectory(folder);
|
||||
return folder;
|
||||
if(config.UperSaveTogether)
|
||||
{
|
||||
return folder;
|
||||
}
|
||||
else
|
||||
{
|
||||
var sampleName = TikTokFileNameHelper.GenerateFileName(item.Desc, item.AwemeId);
|
||||
var (existingName, _) = _douyinVideoService.GetUperLastViedoFileName(item.Author.Uid, sampleName).Result;
|
||||
var fileNameFolder = string.IsNullOrWhiteSpace(existingName) ? sampleName : existingName;
|
||||
return Path.Combine(folder, fileNameFolder);
|
||||
}
|
||||
}
|
||||
|
||||
protected override string GetVideoFileName(DouyinUserCookie cookie, Aweme item, VideoBitRate bitRate)
|
||||
protected override string GetVideoFileName(DouyinUserCookie cookie, Aweme item)
|
||||
{
|
||||
var bitRate = item.Video.BitRate.FirstOrDefault();
|
||||
var config = _commonService.GetConfig();
|
||||
var fileName = string.Empty;
|
||||
if (config?.UperUseViedoTitle ?? false)
|
||||
{
|
||||
var sampleName = TikTokFileNameHelper.GenerateFileName(item.Desc, item.AwemeId);
|
||||
var (existingName, _) = _douyinVideoService.GetUperLastViedoFileName(item.Author.Uid, sampleName).Result;
|
||||
return string.IsNullOrWhiteSpace(existingName) ? $"{sampleName}.{bitRate.Format}" : $"{existingName}.{bitRate.Format}";
|
||||
fileName= string.IsNullOrWhiteSpace(existingName) ? $"{sampleName}.{bitRate.Format}" : $"{existingName}.{bitRate.Format}";
|
||||
}
|
||||
else
|
||||
{
|
||||
fileName = $"{item.AwemeId}.{bitRate.Format}";
|
||||
}
|
||||
return fileName;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="cookie"></param>
|
||||
/// <param name="item"></param>
|
||||
/// <param name="config"></param>
|
||||
/// <param name="imageType"></param>
|
||||
/// <returns></returns>
|
||||
protected override string GetNfoFileName(DouyinUserCookie cookie, Aweme item, AppConfig config, string imageType)
|
||||
{
|
||||
if (config.UperSaveTogether)
|
||||
{
|
||||
var videoFileName = GetVideoFileName(cookie, item);
|
||||
return $"{Path.GetFileNameWithoutExtension(videoFileName)}{imageType}";
|
||||
}
|
||||
else
|
||||
{
|
||||
return base.GetNfoFileName(cookie,item,config,imageType);
|
||||
}
|
||||
return $"{item.AwemeId}.{bitRate.Format}";
|
||||
}
|
||||
|
||||
protected override string GetAuthorAvatarBasePath(DouyinUserCookie cookie)
|
||||
|
||||
+705
-420
File diff suppressed because it is too large
Load Diff
+5
-2
@@ -22,10 +22,13 @@ namespace dy.net.model
|
||||
public int BatchCount { get; set; } = 10;
|
||||
|
||||
/// <summary>
|
||||
/// 博主视频是否 直接用标题做文件名,不另外加一层文件夹
|
||||
/// 博主视频是否 直接用标题做文件名
|
||||
/// </summary>
|
||||
public bool UperUseViedoTitle { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 是否博主视频直接放一个根目录,不另外按名字建文件夹
|
||||
/// </summary>
|
||||
public bool UperSaveTogether { get; set; }
|
||||
/// <summary>
|
||||
/// 是否下载图片视频
|
||||
/// </summary>
|
||||
|
||||
@@ -29,7 +29,7 @@ namespace dy.net.service
|
||||
cron++;
|
||||
expression = cron.ToString();
|
||||
}
|
||||
//await StartFavoriteJob(expression);
|
||||
await StartFavoriteJob(expression);
|
||||
|
||||
await Task.Delay(delay);
|
||||
if (int.TryParse(expression, out int cron2))
|
||||
@@ -37,7 +37,7 @@ namespace dy.net.service
|
||||
cron2++;
|
||||
expression = cron2.ToString();
|
||||
}
|
||||
await StartUperPostJob(expression);
|
||||
//await StartUperPostJob(expression);
|
||||
}
|
||||
|
||||
private async Task<bool> StartCollectJob(string expression)
|
||||
|
||||
@@ -71,8 +71,8 @@ namespace dy.net.utils
|
||||
//title = Regex.Replace(title, @"#\S+", "", RegexOptions.Compiled);
|
||||
|
||||
// 步骤2:移除表情符号(匹配常见表情Unicode区块)
|
||||
string emojiPattern = @"[\u1F600-\u1F64F\u1F300-\u1F5FF\u1F680-\u1F6FF\u1E000-\u1EFFF\u2600-\u2B55\u200D]";
|
||||
title = Regex.Replace(title, emojiPattern, "", RegexOptions.Compiled);
|
||||
//string emojiPattern = @"[\u1F600-\u1F64F\u1F300-\u1F5FF\u1F680-\u1F6FF\u1E000-\u1EFFF\u2600-\u2B55\u200D]";
|
||||
//title = Regex.Replace(title, emojiPattern, "", RegexOptions.Compiled);
|
||||
|
||||
// 步骤3:过滤系统非法字符(Windows/macOS/Linux通用禁止)
|
||||
char[] illegalChars = new[] { '/', '\\', ':', '*', '?', '"', '<', '>', '|', '\0', '\t', '\n', '\r' };
|
||||
|
||||
Reference in New Issue
Block a user