예제 #1
0
        /// <summary>
        /// range 重试,解决range字段找不到,但又必须提供的问题
        /// </summary>
        /// <param name="func"></param>
        /// <param name="paramModel"></param>
        /// <param name="retryNum"></param>
        /// <returns></returns>
        private GatherResult Retry(Func <ParamModel, GatherResult> func, ParamModel paramModel, int retryNum)
        {
            GatherResult result = default(GatherResult);

            try
            {
                result = func(paramModel);
                return(result);
            }
            catch (Exception)
            {
                for (int i = 1; i <= retryNum; i++)
                {
                    try
                    {
                        paramModel.Range = $"{DateTime.Now.Year - i}";
                        result           = func(paramModel);
                        return(result);
                    }
                    catch (Exception)
                    {
                    }
                }
                return(result);
            }
        }
예제 #2
0
        protected override IEnumerable <GatherResult> OnPlatsAndList(HtmlNode htmlNode)
        {
            var oldStat = htmlNode.Attributes["_oldstat"].Value.Split("&");
            var lis     = htmlNode.ChildNodes.First(d => d.HasClass("play_source_list")).Descendants("li");

            return(lis.Select(d =>
            {
                var @params = JsonConvert.DeserializeObject <ReqParamModel>(d.Attributes["data-params"].Value.Replace("&quot;", "\""));
                string sval8 = oldStat.First(s => s.Contains("sval8")).Split("=").Last();
                var paramModel = new ParamModel
                {
                    Id = @params != null ? @params.id : htmlNode.Attributes["data-id"].Value,
                    Plname = @params != null ? @params.plname : this.GetPlname(htmlNode),
                    Plat = @params != null ? @params.plat : sval8.Split("%2526").First(s => s.Contains("plat")).Split("%253D").Last(),
                    Type = "4",
                    Range = this.GetRange(htmlNode),
                    Data_type = @params != null ? @params.data_type.ToString() : sval8.Split("%26").First(s => s.Contains("data%5Ftype")).Split("%3D").Last(),
                    Video_type = @params != null ? @params.video_type.ToString() : sval8.Split("%26").First(s => s.Contains("video%5Ftype")).Split("%3D").Last(),
                    Otype = "json",
                    Uid = oldStat.First(s => s.Contains("guid")).Split("=").Last().Replace("%2D", "-"),
                    Callback = string.Empty,
                    CurrentTime = DateTimeOffset.Now.ToUnixTimeMilliseconds().ToString(),
                };
                return $"https://s.video.qq.com/get_playsource?{paramModel}";
            }).Select(link => GetGatherResult(link, htmlNode)));
        }
예제 #3
0
        public static string GetOnPlatsAndListLink(this ParamModel paramModel, bool flag)
        {
            string link;

            if (flag)
            {
                link = $@"https://s.video.qq.com/get_playsource?id={paramModel.Id}&plname={paramModel.Plname}&range={paramModel.Range}&plat={paramModel.Plat}&type={paramModel.Type}&data_type={paramModel.Data_type}&video_type={paramModel.Video_type}&otype={paramModel.Otype}&uid={paramModel.Uid}&callback={paramModel.Callback}&_t={paramModel.CurrentTime}";
            }
            else
            {
                link = $@"https://s.video.qq.com/get_playsource?id={paramModel.Id}&plname={paramModel.Plname}&range={paramModel.Range}&plat={paramModel.Plat}&type={paramModel.Type}&data_type={paramModel.Data_type}&video_type={paramModel.Video_type}&otype={paramModel.Otype}&uid={paramModel.Uid}&callback={paramModel.Callback}&_t={paramModel.CurrentTime}";
            }
            return(link);
        }
예제 #4
0
        protected override GatherResult OnOnePlatAndList(HtmlNode htmlNode)
        {
            var    oldStat    = htmlNode.Attributes["_oldstat"].Value.Split("&");
            string sval8      = oldStat.First(s => s.Contains("sval8")).Split("=").Last();
            var    paramModel = new ParamModel
            {
                Id          = htmlNode.Attributes["data-id"].Value,
                Plname      = this.GetPlname(htmlNode),
                Plat        = sval8.Split("%2526").First(s => s.Contains("plat")).Split("%253D").Last(),
                Type        = "4",
                Data_type   = sval8.Split("%26").First(s => s.Contains("data%5Ftype")).Split("%3D").Last(),
                Video_type  = sval8.Split("%26").First(s => s.Contains("video%5Ftype")).Split("%3D").Last(),
                Otype       = "json",
                Uid         = oldStat.First(s => s.Contains("guid")).Split("=").Last().Replace("%2D", "-"),
                Callback    = "",
                Range       = this.GetRange(htmlNode),
                CurrentTime = DateTimeOffset.Now.ToUnixTimeMilliseconds().ToString(),
            };
            var result = this.Retry(param => GetGatherResult($"https://s.video.qq.com/get_playsource?{param}", htmlNode), paramModel, 4);

            return(result);
        }
예제 #5
0
        protected override IEnumerable <GatherResult> OnOnePlatAndButtons(HtmlNode htmlNode)
        {
            var    oldStat    = htmlNode.Attributes["_oldstat"].Value.Split("&");
            string sval8      = oldStat.First(s => s.Contains("sval8")).Split("=").Last();
            var    paramModel = new ParamModel
            {
                Id          = htmlNode.Attributes["data-id"].Value,
                Plname      = this.GetPlname(htmlNode),
                Plat        = sval8.Split("%2526").First(s => s.Contains("plat")).Split("%253D").Last(),
                Type        = "5",
                Data_type   = sval8.Split("%26").First(s => s.Contains("data%5Ftype")).Split("%3D").Last(),
                Video_type  = sval8.Split("%26").First(s => s.Contains("video%5Ftype")).Split("%3D").Last(),
                Otype       = "json",
                Uid         = oldStat.First(s => s.Contains("guid")).Split("=").Last().Replace("%2D", "-"),
                Callback    = "",
                Range       = this.GetRange(htmlNode),
                CurrentTime = DateTimeOffset.Now.ToUnixTimeMilliseconds().ToString(),
            };
            var link         = $"https://s.video.qq.com/get_playsource?{paramModel}";
            var gatherResult = GetGatherResult(link, htmlNode);
            var tagA         = htmlNode.ChildNodes.FirstOrDefault(node => node.HasClass("result_btn_line"))?.Descendants("a");

            if (tagA != null && tagA.Count() > 1)
            {
                gatherResult.DramaList = gatherResult.DramaList.Concat(tagA.Skip(1).Select(a => new Drama()
                {
                    Title = a.Descendants("span").First().InnerText,
                    Pic   = gatherResult.DramaList.FirstOrDefault()?.Pic,
                    Link  = a.Attributes["href"].Value
                }).SkipLast(1));
            }
            return(new List <GatherResult>()
            {
                gatherResult
            });
        }
예제 #6
0
        public static string GetOnOnePlatAndButtonsLink(this ParamModel paramModel)
        {
            string link = $@"https://s.video.qq.com/get_playsource?{paramModel}";

            return(link);
        }