优化视频下载逻辑顺序
This commit is contained in:
+14
-25
@@ -429,7 +429,7 @@ namespace dy.net.job
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
//如果存在,但是因为去重规则,选择的最高优先级变更了,需要删除原来的,重新下载。
|
//如果存在,但是因为去重规则,选择的最高优先级变更了,需要删除原来的,重新下载。
|
||||||
if (exitVideo!=null) {
|
if (exitVideo != null) {
|
||||||
await douyinVideoService.DeleteById(exitVideo.Id);
|
await douyinVideoService.DeleteById(exitVideo.Id);
|
||||||
}
|
}
|
||||||
var uper = await douyinFollowService.GetByUperId(item.AuthorUserId.ToString(), cookie.MyUserId);
|
var uper = await douyinFollowService.GetByUperId(item.AuthorUserId.ToString(), cookie.MyUserId);
|
||||||
@@ -444,37 +444,31 @@ namespace dy.net.job
|
|||||||
var video = await ProcessSingleVideo(cookie, item, data, config, followed);
|
var video = await ProcessSingleVideo(cookie, item, data, config, followed);
|
||||||
if (video != null)
|
if (video != null)
|
||||||
videos.Add(video);
|
videos.Add(video);
|
||||||
|
else{
|
||||||
|
|
||||||
|
|
||||||
// 处理图文视频
|
|
||||||
if (config.DownImageVideo || config.DownMp3 || config.DownImage)
|
|
||||||
{
|
|
||||||
//处理多个视频-组合的图文视频--类似动图。
|
//处理多个视频-组合的图文视频--类似动图。
|
||||||
|
|
||||||
if (config.DownDynamicVideo)
|
|
||||||
{
|
|
||||||
List<string> dynamicVideoUrls = new List<string>();
|
List<string> dynamicVideoUrls = new List<string>();
|
||||||
if (item.Images != null&& item.Images.Count > 0)
|
// 当需要下载动态视频时,获取其他URL
|
||||||
|
if (config.DownDynamicVideo && item.Images != null && item.Images.Count > 0)
|
||||||
{
|
{
|
||||||
foreach (var img in item.Images)
|
foreach (var img in item.Images)
|
||||||
{
|
{
|
||||||
if (img.DynamicVideo != null&& img.DynamicVideo.BitRate!=null&& img.DynamicVideo.BitRate.Count>0)
|
if (img.DynamicVideo?.BitRate?.Count > 0)
|
||||||
{
|
{
|
||||||
foreach (var btv in img.DynamicVideo.BitRate)
|
foreach (var btv in img.DynamicVideo.BitRate)
|
||||||
{
|
{
|
||||||
var payAddr = btv.PlayAddr;
|
var targetUrl = btv.PlayAddr?.UrlList?.FirstOrDefault(x => x.StartsWith("https://www.douyin.com/aweme/v1/play"));
|
||||||
if(payAddr != null&& payAddr.UrlList!=null&&payAddr.UrlList.Count>0)
|
if (targetUrl != null)
|
||||||
{
|
dynamicVideoUrls.Add(targetUrl);
|
||||||
dynamicVideoUrls.Add(payAddr.UrlList.FirstOrDefault(x => x.StartsWith("https://www.douyin.com/aweme/v1/play")));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//说明这个是图文视频里面的动态视频拼接的。。。
|
// 处理核心逻辑
|
||||||
if (dynamicVideoUrls.Count > 0)
|
if (config.DownDynamicVideo && dynamicVideoUrls.Count > 0)
|
||||||
{
|
{
|
||||||
|
// 处理动态视频
|
||||||
var dynamicVideo = await ProcessDynamicVideo(dynamicVideoUrls, cookie, item, data, config);
|
var dynamicVideo = await ProcessDynamicVideo(dynamicVideoUrls, cookie, item, data, config);
|
||||||
if (dynamicVideo != null)
|
if (dynamicVideo != null)
|
||||||
{
|
{
|
||||||
@@ -488,19 +482,14 @@ namespace dy.net.job
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
var mergevideo = await ProcessImageSetAndMergeToVideo(cookie, item, data, config, followed);
|
// 统一处理图文视频逻辑
|
||||||
if (mergevideo != null)
|
if (config.DownImageVideo || config.DownMp3 || config.DownImage)
|
||||||
videos.Add(mergevideo);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
{
|
||||||
var mergevideo = await ProcessImageSetAndMergeToVideo(cookie, item, data, config, followed);
|
var mergevideo = await ProcessImageSetAndMergeToVideo(cookie, item, data, config, followed);
|
||||||
if (mergevideo != null)
|
if (mergevideo != null)
|
||||||
videos.Add(mergevideo);
|
videos.Add(mergevideo);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return videos;
|
return videos;
|
||||||
|
|||||||
Reference in New Issue
Block a user