/// <summary> /// 查询用户投稿视频明细 /// </summary> /// <param name="mid">用户id</param> /// <param name="pn">页码</param> /// <param name="ps">每页的视频数</param> /// <param name="order">排序</param> /// <param name="tid">视频分区</param> /// <param name="keyword">搜索关键词</param> /// <returns></returns> public SpacePublicationList GetPublication(long mid, int pn, int ps, int tid = 0, PublicationOrder order = PublicationOrder.PUBDATE, string keyword = "") { string url = $"https://api.bilibili.com/x/space/arc/search?mid={mid}&pn={pn}&ps={ps}&order={order.ToString("G").ToLower()}&tid={tid}&keyword={keyword}"; string referer = "https://www.bilibili.com"; string response = Utils.RequestWeb(url, referer); try { // 忽略play的值为“--”时的类型错误 var settings = new JsonSerializerSettings { Error = (sender, args) => { if (Equals(args.ErrorContext.Member, "play") && args.ErrorContext.OriginalObject.GetType() == typeof(SpacePublicationListVideo)) { args.ErrorContext.Handled = true; } } }; var spacePublication = JsonConvert.DeserializeObject <SpacePublicationOrigin>(response, settings); if (spacePublication == null || spacePublication.Data == null) { return(null); } return(spacePublication.Data.List); } catch (Exception e) { Console.WriteLine("GetPublication()发生异常: {0}", e); return(null); } }
/// <summary> /// 查询用户投稿视频明细 /// </summary> /// <param name="mid">用户id</param> /// <param name="pn">页码</param> /// <param name="ps">每页的视频数</param> /// <param name="order">排序</param> /// <param name="tid">视频分区</param> /// <param name="keyword">搜索关键词</param> /// <returns></returns> public SpacePublicationList GetPublication(long mid, int pn, int ps, int tid = 0, PublicationOrder order = PublicationOrder.PUBDATE, string keyword = "") { string url = $"https://api.bilibili.com/x/space/arc/search?mid={mid}&pn={pn}&ps={ps}&order={order.ToString("G").ToLower()}&tid={tid}&keyword={keyword}"; string referer = "https://www.bilibili.com"; string response = Utils.RequestWeb(url, referer); try { var spacePublication = JsonConvert.DeserializeObject <SpacePublicationOrigin>(response); if (spacePublication == null || spacePublication.Data == null) { return(null); } return(spacePublication.Data.List); } catch (Exception e) { Console.WriteLine("GetPublication()发生异常: {0}", e); return(null); } }