public async Task <string?> GetLrcAsync(string id) { return(await _caching.GetAsync($"{nameof(GetLrcAsync)}.{id}", async() => { return await Task.Run(() => { var lrc = _meting.LyricObj(id); return lrc.lyric; }); }, TimeSpan.FromMinutes(_config.Cache.Lrc))); }
/// <summary> /// 获取B站历史弹幕 /// </summary> /// <param name="cid">视频的cid</param> /// <param name="date">历史日期</param> /// <returns></returns> public async Task <BaseDanmuData[]> GetDanmuAsync(int cid, string[] date) { if (!_canGetHistory) { return(await GetDanmuAsync(new BiliBiliQuery { Cid = cid })); } var a = Task.Run(() => date.Select(async s => { return(await _caching.GetAsync( $"{nameof(GetDanmuAsync)}{cid}{s}", async() => new BiliBiliDanmuData(await GetDanmuRawAsync( $"/x/v2/dm/history?type=1&oid={cid}&date={s}", true)), TimeSpan.FromHours(_setting.DanmuCacheTime))); }).SelectMany(s => s.Result.D)); return(new BiliBiliDanmuData { D = (await a).ToArray() }.ToBaseDanmuDatas().ToArray()); }