1、去重
2、分享 3、视频播放 4、批量删除,重新下载 5、自定义标题(仅博主视频) 6、授权页面去掉博主添加,新增关注列表 7、图文视频合成优化 8、其他优化
This commit is contained in:
+26
-31
@@ -8,35 +8,34 @@ using System.Threading.Tasks;
|
||||
|
||||
namespace dy.net.job
|
||||
{
|
||||
public class DouyinFavoritSyncJob : DouyinBaseSyncJob
|
||||
public class DouyinFavoritSyncJob : DouyinBasicSyncJob
|
||||
{
|
||||
public DouyinFavoritSyncJob(
|
||||
DouyinCookieService dyCookieService,
|
||||
DouyinHttpClientService dyHttpClientService,
|
||||
DouyinVideoService dyCollectVideoService,
|
||||
DouyinCommonService commonService, IServiceProvider serviceProvider, IWebHostEnvironment webHostEnvironment)
|
||||
: base(dyCookieService, dyHttpClientService, dyCollectVideoService, commonService, serviceProvider, webHostEnvironment) { }
|
||||
DouyinCookieService douyinCookieService,
|
||||
DouyinHttpClientService douyinHttpClientService,
|
||||
DouyinVideoService douyinVideoService,
|
||||
DouyinCommonService douyinCommonService,DouyinFollowService douyinFollowService,DouyinMergeVideoService douyinMergeVideoService)
|
||||
: base(douyinCookieService, douyinHttpClientService, douyinVideoService, douyinCommonService, douyinFollowService, douyinMergeVideoService) { }
|
||||
|
||||
protected override string JobType => "favorite";
|
||||
protected override async Task<List<DouyinUserCookie>> GetValidCookies()
|
||||
protected override string JobType => SystemStaticUtil.DY_FAVORITES;
|
||||
protected override async Task<List<DouyinCookie>> GetValidCookies()
|
||||
{
|
||||
var cookies = await _dyCookieService.GetAllCookies();
|
||||
return cookies.Where(c => !string.IsNullOrWhiteSpace(c.FavSavePath)).ToList();
|
||||
return await douyinCookieService.GetAllOpendAsync(x=> !string.IsNullOrWhiteSpace(x.FavSavePath));
|
||||
}
|
||||
|
||||
protected override bool IsCookieValid(DouyinUserCookie cookie)
|
||||
protected override bool IsCookieValid(DouyinCookie cookie)
|
||||
{
|
||||
return !string.IsNullOrWhiteSpace(cookie.Cookies) && cookie.Cookies.Length >= 1000 &&
|
||||
!string.IsNullOrWhiteSpace(cookie.FavSavePath) &&
|
||||
!string.IsNullOrWhiteSpace(cookie.SecUserId) && cookie.SecUserId.Length >= 10;
|
||||
}
|
||||
|
||||
protected override async Task<DouyinVideoInfo> FetchVideoData(DouyinUserCookie cookie, string cursor)
|
||||
protected override async Task<DouyinVideoInfo> FetchVideoData(DouyinCookie cookie, string cursor,string uperUid)
|
||||
{
|
||||
return await _douyinService.SyncFavoriteVideos(count, cursor, cookie.SecUserId, cookie.Cookies);
|
||||
return await douyinHttpClientService.SyncFavoriteVideos(count, cursor, cookie.SecUserId, cookie.Cookies);
|
||||
}
|
||||
|
||||
protected override bool ShouldContinueSync(DouyinUserCookie cookie, DouyinVideoInfo data)
|
||||
protected override bool ShouldContinueSync(DouyinCookie cookie, DouyinVideoInfo data, DouyinFollowed followed=null)
|
||||
{
|
||||
return data != null && data.HasMore == 1 && cookie.FavHasSyncd == 0;
|
||||
}
|
||||
@@ -46,32 +45,19 @@ namespace dy.net.job
|
||||
return data?.MaxCursor ?? "0";
|
||||
}
|
||||
|
||||
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}");
|
||||
if (!Directory.Exists(folder)) Directory.CreateDirectory(folder);
|
||||
return folder;
|
||||
}
|
||||
|
||||
protected override string GetVideoFileName(DouyinUserCookie cookie, Aweme item)
|
||||
{
|
||||
var bitRate = item.Video.BitRate.FirstOrDefault();
|
||||
return $"{item.AwemeId}.{bitRate.Format}";
|
||||
}
|
||||
|
||||
protected override string GetAuthorAvatarBasePath(DouyinUserCookie cookie)
|
||||
protected override string GetAuthorAvatarBasePath(DouyinCookie cookie)
|
||||
{
|
||||
return Path.Combine(cookie.FavSavePath, "author");
|
||||
}
|
||||
|
||||
protected override async Task HandleSyncCompletion(DouyinUserCookie cookie, int syncCount)
|
||||
protected override async Task HandleSyncCompletion(DouyinCookie cookie, int syncCount)
|
||||
{
|
||||
if (syncCount > 0)
|
||||
{
|
||||
Serilog.Log.Debug($"{JobType}-Cookie-[{cookie.UserName}],本次同步成功{syncCount}条视频");
|
||||
cookie.FavHasSyncd = 1;
|
||||
await _dyCookieService.UpdateAsync(cookie);
|
||||
await douyinCookieService.UpdateAsync(cookie);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -79,12 +65,21 @@ namespace dy.net.job
|
||||
}
|
||||
}
|
||||
|
||||
protected override VideoEntityDifferences GetVideoEntityDifferences(DouyinUserCookie cookie, Aweme item)
|
||||
protected override VideoEntityDifferences GetVideoEntityDifferences(DouyinCookie cookie, Aweme item)
|
||||
{
|
||||
return new VideoEntityDifferences
|
||||
{
|
||||
VideoType = VideoTypeEnum.Favorite
|
||||
};
|
||||
}
|
||||
|
||||
protected override string CreateSaveFolder(DouyinCookie cookie, Aweme item, AppConfig config, DouyinFollowed followed)
|
||||
{
|
||||
var (tag1, _, _) = GetVideoTags(item);
|
||||
var safeTag1 = string.IsNullOrWhiteSpace(tag1) ? "other" : DouyinFileNameHelper.SanitizePath(tag1);
|
||||
var folder = Path.Combine(cookie.FavSavePath, safeTag1, $"{DouyinFileNameHelper.SanitizePath(item.Desc)}@{item.AwemeId}");
|
||||
if (!Directory.Exists(folder)) Directory.CreateDirectory(folder);
|
||||
return folder;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user