Skip to content

Commit

Permalink
转存词条缩略图到公共图床
Browse files Browse the repository at this point in the history
  • Loading branch information
LittleFish-233 committed May 5, 2023
1 parent c613e19 commit f38d1ce
Showing 1 changed file with 24 additions and 0 deletions.
Expand Up @@ -122,6 +122,30 @@ public async Task TransferMainImagesToPublic(int maxCount)

}

entries = await _entryRepository.GetAll().Where(s => string.IsNullOrWhiteSpace(s.Thumbnail) == false && s.IsHidden == false && string.IsNullOrWhiteSpace(s.Name) == false && s.MainPicture.Contains("?") == false && s.MainPicture.Contains("default") == false)
.OrderBy(s => s.Id)
.Take(maxCount).ToListAsync();

foreach (var item in entries)
{
try
{
var temp = await TransferDepositFile(item.Thumbnail);
if (string.IsNullOrWhiteSpace(temp) == false)
{
item.Thumbnail = temp;
await _entryRepository.UpdateAsync(item);
_logger.LogInformation("转存 词条 - {name}({id}) 缩略图到 tucang.cc 图床,链接替换为:{url}", item.Name, item.Id, item.Thumbnail);
}
}
catch (Exception ex)
{
_logger.LogError(ex, "转存词条 - {Name}({Id}) 缩略图失败", item.Name, item.Id);
}

}


var articles = await _articleRepository.GetAll().Where(s => string.IsNullOrWhiteSpace(s.MainPicture) == false && s.IsHidden == false && string.IsNullOrWhiteSpace(s.Name) == false && s.MainPicture.Contains("?") == false && s.MainPicture.Contains("default") == false)
.OrderBy(s => s.Id)
.Take(maxCount).ToListAsync();
Expand Down

0 comments on commit f38d1ce

Please sign in to comment.