Warn() публичный статический Метод

public static Warn ( string s ) : void
s string
Результат void
Пример #1
0
        public static IEnumerable <string> GetAVFlvUrl(string AVnum, out IEnumerable <string> renames, List <BiliInterfaceInfo> binfos = null) //TODO: 试试元组
        {
            string[] avnp  = Regex.Split(AVnum, "_|-|#");
            string   avnum = GetAVdenum(avnp[0]);

            int page = 1;

            if (avnp.Length > 1)
            {
                try
                {
                    page = int.Parse(avnp[1]);
                }
                catch
                {
                    Log.Warn(AVnum + " - 无法识别分P编号,将下载P1");
                }
            }

            BiliInterfaceInfo    info    = null;
            IEnumerable <string> flvs    = null;
            List <string>        rrnames = new List <string>();

            try
            {
                info = GetInfo(avnum);
                if (page > 1)
                {
                    if (info.pagesn.Count >= page)
                    {
                        flvs = GetFlvUrls(uint.Parse(info.pagesn[page - 1].cid));
                    }
                    else
                    {
                        Log.Warn(AVnum + $" - 目标视频仅有{info.pagesn.Count}P,将下载P1");
                        flvs = GetFlvUrls(info.cid);
                    }
                }
                else
                {
                    flvs = GetFlvUrls(info.cid);
                }
                string topstring = "";
                try
                {
                    if (binfos != null)
                    {
                        int paiming = (from b in binfos where b.avnum == info.avnum select b.Fpaiming.Value).First();
                        if (paiming != 0 && paiming <= 20)
                        {
                            topstring = "TOP_" + paiming + "-";
                        }
                    }
                } catch { }
                info.title = $"{info.title}_{info.avnum}_P{page}_{info.pagesn[page - 1].part}";
                info.title = TSDownload.removeInvChrInPath(info.title);
                for (int i = 0; i < flvs.Count(); i++)
                {
                    string filename = Path.GetFileName(new Uri(flvs.ElementAt(i)).AbsolutePath);
                    rrnames.Add($"{filename}$///${topstring}{info.title}_{i + 1}.flv");
                }
            }
            catch (Exception e)
            {
                Log.Error("AV" + avnum + "的数据发生错误,请稍后重试!" + e.Message);
            }
            renames = rrnames;
            return(flvs);
        }
Пример #2
0
        public static BiliInterfaceInfo GetInfoOld(string AVnum)
        {
            string avnum = AVnum.ToUpper();

            if (avnum.Contains("AV"))
            {
                avnum = avnum.Substring(2, avnum.Length - 2);
            }

            Log.Info("正在通过API获取数据 - AV" + avnum);

            SortedDictionary <string, string> parampairs = new SortedDictionary <string, string>();

            parampairs.Add("id", avnum);
            string param = GetSign(parampairs);

            string html = GetHtml("http://api.bilibili.com/view?" + param);

            JavaScriptSerializer j    = new JavaScriptSerializer();
            BiliInterfaceInfo    info = new BiliInterfaceInfo();

            try
            {
                info = j.Deserialize <BiliInterfaceInfo>(html);

                if (info.code == -403)
                {
                    if (info.error == "no perm error")
                    {
                        Log.Error("没有数据!(正在补档或被删除?)");
                    }
                    else
                    {
                        Log.Error("本视频为会员独享,需要Cookie!");
                    }
                }
                else if (info.code == -503)
                {
                    Log.Warn("到达连续获取上限,延时两秒");
                    System.Threading.Thread.Sleep(2000);
                    return(GetInfo(AVnum));
                }
                else if (info.code == -404)
                {
                    Log.Error("视频不存在!");
                }
                else if (info.code != 0)
                {
                    Log.Error("返回未知错误:" + info.code);
                }
                else
                {
                    info.AVNUM = "AV" + avnum;
                    info.title = info.title.Replace("&amp;", "&");
                    info.title = info.title.Replace("&lt;", "<");
                    info.title = info.title.Replace("&gt;", ">");
                    info.title = info.title.Replace("&quot;", "\"");

                    //算分
                    double xiuzheng = 0;

                    //收藏
                    xiuzheng = ((double)info.favorites / (double)info.play) * 1500;
                    if (xiuzheng > 55)
                    {
                        xiuzheng = 55;
                    }
                    info.Ffavorites = Convert.ToInt32(info.favorites * xiuzheng);

                    //硬币
                    xiuzheng = ((double)info.coins / (double)info.play) * 5000;
                    if (xiuzheng > 25)
                    {
                        xiuzheng = 25;
                    }
                    info.Fcoins = Convert.ToInt32(info.coins * xiuzheng);

                    //评论
                    xiuzheng = ((double)(info.review + info.favorites + info.coins) / (double)(info.play + info.review + info.video_review * 5)) * 800;
                    if (xiuzheng > 30)
                    {
                        xiuzheng = 30;
                    }
                    info.Freview = Convert.ToInt32(info.review * xiuzheng);

                    //播放
                    info.Fplay = info.Ffavorites + info.Fcoins;
                    if (info.play <= info.Fplay)
                    {
                        info.Fplay = info.play;
                    }
                    else
                    {
                        info.Fplay = info.Fplay + (info.play - info.Fplay) / 2;
                    }

                    //得分
                    info.Fdefen = info.Ffavorites + info.Fcoins + info.Freview + info.Fplay;
                }
            }
            catch (Exception e)
            {
                Log.Error("AV" + avnum + "的数据发生错误,请稍后重试!" + e.Message);
            }

            return(info);
        }