Skip to content

Commit

Permalink
优化发布时间获取 Fix #769
Browse files Browse the repository at this point in the history
  • Loading branch information
nilaoda committed Nov 12, 2023
1 parent 7148a96 commit 9051270
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 4 deletions.
3 changes: 2 additions & 1 deletion BBDown.Core/Fetcher/BangumiInfoFetcher.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ public async Task<VInfo> FetchAsync(string id)
string cover = result.GetProperty("cover").ToString();
string title = result.GetProperty("title").ToString();
string desc = result.GetProperty("evaluate").ToString();
long pubTime = DateTimeOffset.ParseExact(result.GetProperty("publish").GetProperty("pub_time").ToString(), "yyyy-MM-dd HH:mm:ss", null).ToUnixTimeSeconds();
string pubTimeStr = result.GetProperty("publish").GetProperty("pub_time").ToString();
long pubTime = string.IsNullOrEmpty(pubTimeStr) ? 0 : DateTimeOffset.ParseExact(pubTimeStr, "yyyy-MM-dd HH:mm:ss", null).ToUnixTimeSeconds();
var pages = result.GetProperty("episodes").EnumerateArray();
List<Page> pagesInfo = new();
int i = 1;
Expand Down
5 changes: 3 additions & 2 deletions BBDown.Core/Fetcher/IntlBangumiInfoFetcher.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@ public async Task<VInfo> FetchAsync(string id)
}
}

long pubTime = DateTimeOffset.ParseExact(result.GetProperty("publish").GetProperty("pub_time").ToString(), "yyyy-MM-dd HH:mm:ss", null).ToUnixTimeSeconds();
string pubTimeStr = result.GetProperty("publish").GetProperty("pub_time").ToString();
long pubTime = string.IsNullOrEmpty(pubTimeStr) ? 0 : DateTimeOffset.ParseExact(pubTimeStr, "yyyy-MM-dd HH:mm:ss", null).ToUnixTimeSeconds();
var pages = new List<JsonElement>();
if (result.TryGetProperty("episodes", out JsonElement episodes))
{
Expand Down Expand Up @@ -99,7 +100,7 @@ public async Task<VInfo> FetchAsync(string id)
page.GetProperty("id").ToString(),
_title,
0, res,
page.GetProperty("pub_time").GetInt64());
page.TryGetProperty("pub_time", out JsonElement pub_time) ? pub_time.GetInt64() : 0);
if (p.epid == id) index = p.index.ToString();
pagesInfo.Add(p);
}
Expand Down
5 changes: 4 additions & 1 deletion BBDown/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,10 @@ public static (Dictionary<string, byte> encodingPriority, Dictionary<string, int
string title = vInfo.Title;
long pubTime = vInfo.PubTime;
LogColor("视频标题: " + title);
Log("发布时间: " + FormatTimeStamp(pubTime, "yyyy-MM-dd HH:mm:ss zzz"));
if (pubTime != 0)
{
Log("发布时间: " + FormatTimeStamp(pubTime, "yyyy-MM-dd HH:mm:ss zzz"));
}
var mid = vInfo.PagesInfo.FirstOrDefault(p => !string.IsNullOrEmpty(p.ownerMid))?.ownerMid;
if (!string.IsNullOrEmpty(mid))
{
Expand Down

0 comments on commit 9051270

Please sign in to comment.