예제 #1
0
        public void Gen2(List <BiliInterfaceInfo> infos)
        {
            Log.Info("【副榜】开始生成" + infos.Count + "个视频的图片(每3个一张图)");
            foreach (BiliInterfaceInfo info in infos)
            {
                BiliInterface.GetPic(info);
            }
            for (int i = 0; i < infos.Count; i += 3)
            {
                image               = Properties.Resources.fubang2;
                g                   = Graphics.FromImage(image);
                g.SmoothingMode     = SmoothingMode.HighQuality;
                g.TextRenderingHint = System.Drawing.Text.TextRenderingHint.AntiAlias;
                g.PixelOffsetMode   = PixelOffsetMode.HighQuality;
                g.InterpolationMode = InterpolationMode.HighQualityBilinear;

                AddPic2(infos[i], 1);
                if (i + 1 < infos.Count)
                {
                    AddPic2(infos[i + 1], 2);
                }
                if (i + 2 < infos.Count)
                {
                    AddPic2(infos[i + 2], 3);
                }

                string url = Environment.CurrentDirectory + @"\pic\Rank" + infos[i].Fpaiming + "-" + (infos[i].Fpaiming + 2) + ".png";
                Log.Info("保存图片 " + url);
                image.Save(url);
            }

            Log.Info("副榜图片批量生成完成");
        }
예제 #2
0
        public void Gen(List <BiliInterfaceInfo> infos)
        {
            //Gen2(infos);
            //return;

            Log.Info("【副榜】开始生成" + infos.Count + "个视频的图片(每3个一张图)");
            foreach (BiliInterfaceInfo info in infos)
            {
                BiliInterface.GetPic(info);
            }
            for (int i = 0; i < infos.Count; i += 3)
            {
                image = Properties.Resources.fubang;//Image.FromFile("fubang.png");
                g     = Graphics.FromImage(image);

                AddPic(infos[i], 1);
                if (i + 1 < infos.Count)
                {
                    AddPic(infos[i + 1], 2);
                }
                if (i + 2 < infos.Count)
                {
                    AddPic(infos[i + 2], 3);
                }

                string url = Environment.CurrentDirectory + @"\pic\Rank" + infos[i].Fpaiming + "-" + (infos[i].Fpaiming + 2) + ".jpg";
                Log.Info("保存图片 " + url);
                image.Save(url);
            }

            Log.Info("副榜图片批量生成完成");
        }
예제 #3
0
        public static List <string> GetList(int cate_id, DateTime from, DateTime to)
        {
            Log.Info($"正在获取排行 - 分区{cate_id} / 时间{from.ToString("yyyyMMdd")}~{to.ToString("yyyyMMdd")}");
            string url  = "http://" + $"s.search.bilibili.com/cate/search?main_ver=v3&search_type=video&view_type=hot_rank&pic_size=160x100&order=click&copy_right=-1&cate_id={cate_id}&page=1&pagesize=150&time_from={from.ToString("yyyyMMdd")}&time_to={to.ToString("yyyyMMdd")}";
            string html = BiliInterface.GetHtml(url);

            if (html == null)
            {
                return(null);
            }
            JObject obj = JObject.Parse(html);
            IEnumerable <string> avs = from n in obj["result"]
                                       select "av" + Regex.Match((string)n["arcurl"], @"\d+").Value;

            return(avs.ToList());
        }
예제 #4
0
        public static List <string> GetSearch(string keyword, int tids_1, int tids_2, string order, DateTime needFrom, int need = 0)
        {
            int           page = 1;
            List <string> re   = new List <string>();
            //highlight=1会导致title被加入高亮样式html,改成0还是有,无解
            string url  = "http://" + $"api.bilibili.com/x/web-interface/search/type?jsonp=jsonp&highlight=0&search_type=video&keyword={keyword}&order={order}&duration=0&page={page}&tids={tids_2}";
            string html = BiliInterface.GetHtml(url);

            if (html == null)
            {
                return(null);
            }
            JObject obj        = JObject.Parse(html);
            int     numResults = (int)obj["data"]["numResults"];
            int     numPages   = (int)obj["data"]["numPages"];

            Log.Info($"找到{numResults}个,{numPages}页");
            for (int i = 2; i <= numPages + 1; i++)
            {
                IList <JToken> results = obj["data"]["result"].Children().ToList();
                foreach (var result in results)
                {
                    DateTime uploadtime = UnixTimeStampToDateTime(result["pubdate"].ToObject <double>());
                    if (uploadtime >= needFrom.Date)
                    {
                        string avnum = "av" + result["aid"];
                        re.Add(avnum);
                    }
                    else
                    {
                        i = 99999;
                        break;
                    }
                }
                if (i == 99999)
                {
                    break;
                }
                url  = "http://" + $"api.bilibili.com/x/web-interface/search/type?jsonp=jsonp&search_type=video&keyword={keyword}&order={order}&duration=0&page={i}&tids={tids_2}";
                html = BiliInterface.GetHtml(url);
                obj  = JObject.Parse(html);
            }
            return(re);
        }
예제 #5
0
        public static string DoReplace(string before, BiliInterfaceInfo info)
        {
            string after = before;

            after = after.Replace("<", "{");
            after = after.Replace(">", "}");

            after = after.Replace("{}", "\r\n");

            after = after.Replace("{huanhang}", "\r\n");
            after = after.Replace("{title}", info.title);
            after = after.Replace("{time}", info.created_at.Replace(" ", " ")); //半角换成全角
            after = after.Replace("{created_at}", info.created_at);
            after = after.Replace("{AVNUM}", info.AVNUM);
            after = after.Replace("{avnum}", info.avnum);
            after = after.Replace("{author}", info.author);
            after = after.Replace("{zongfen}", info.Fdefen.ToString());
            after = after.Replace("{paiming}", info.Fpaiming.HasValue ? info.Fpaiming.Value.ToString("00") : "--");
            after = after.Replace("{bofang}", info.play.ToString());
            after = after.Replace("{yingbi}", info.coins.ToString());
            after = after.Replace("{shoucang}", info.favorites.ToString());
            after = after.Replace("{danmu}", info.video_review.ToString());
            after = after.Replace("{pinglun}", info.review.ToString());
            after = after.Replace("{tag}", info.tag);
            after = after.Replace("{share}", info.share.ToString());
            after = after.Replace("{pic}", "{pic}" + info.AVNUM);
            after = after.Replace("{face}", "{face}" + BiliInterface.GetFaceFilename(info));

            Type bitype = typeof(BiliInterfaceInfo);

            foreach (PropertyInfo pi in bitype.GetProperties(BindingFlags.Public | BindingFlags.Instance))
            {
                if (pi.CanRead && pi.Name != "pic" && pi.Name != "face")
                {
                    after = after.Replace($"{{{pi.Name}}}", pi.GetValue(info)?.ToString() ?? "");
                }
            }

            return(after);
        }
예제 #6
0
        public static void GenWithTemplate(IEnumerable <BiliInterfaceInfo> binfos, Image bg, string template, int repeat, float offset, string ext = "jpg")
        {
            Zhubang zb = new Zhubang();

            foreach (BiliInterfaceInfo info in binfos)
            {
                BiliInterface.GetPic(info);
            }

            List <Zhubang.TemplateInfo> tinfos = new List <Zhubang.TemplateInfo>();

            for (int j = 0; j < binfos.Count(); j += repeat)
            {
                Image image = (Image)bg.Clone();
                for (int i = 0; i < repeat; i++)
                {
                    if (j + i >= binfos.Count())
                    {
                        break;
                    }
                    tinfos = ParseTemplate(binfos.ElementAt(j + i), template);
                    foreach (var tinfo in tinfos)
                    {
                        if (tinfo.point != null)
                        {
                            tinfo.point.Y += offset * i;
                        }
                        if (tinfo.rectangle != null)
                        {
                            tinfo.rectangle.Y += offset * i;
                        }
                    }
                    image = zb.GenWithTemplate(image, tinfos);
                }
                string url = FileManager.currentPath + @"\pic\Rank" + binfos.ElementAt(j).Fpaiming + "-" + (binfos.ElementAt(j).Fpaiming + repeat - 1) + "." + ext;
                image.Save(url);
                image.Dispose();
            }
        }
예제 #7
0
        public static List <string> GetListOld(SortType type, int zone, int page, DateTime from, DateTime to)
        {
            Log.Info("正在获取排行(旧版) - 依据" + type.ToString().ToLower() + "/分区" + zone + "/分页" + page + "/时间" + from.ToString("yyyy-MM-dd") + "~" + to.ToString("yyyy-MM-dd"));
            string url  = "http://www.bilibili.com/list/" + type.ToString() + "-" + zone + "-" + page + "-" + from.ToString("yyyy-MM-dd") + "~" + to.ToString("yyyy-MM-dd") + ".html";
            string html = BiliInterface.GetHtml(url);

            if (html == null)
            {
                return(null);
            }
            int           p = html.IndexOf("href=\"/video/av");
            List <string> r = new List <string>();

            while (p > 0)
            {
                string s = html.Substring(p + 13, html.IndexOf("/", p + 13) - p - 13);
                if (!r.Contains(s))
                {
                    r.Add(s);
                }
                p = html.IndexOf("href=\"/video/av", p + 3);
            }
            return(r);
        }
예제 #8
0
        public async Task <UserInfoModel> GetMyUserInfo()
        {
            if (IsLogin())
            {
                try
                {
                    string url = string.Format("http://account.bilibili.com/api/myinfo?access_key={0}&appkey={1}&platform=wp&type=json", BiliApiHelper.access_key, BiliApiHelper._appKey_IOS);
                    url += "&sign=" + BiliApiHelper.GetSign(url);
                    string results = await BiliInterface.GetHtmlAsync(url);

                    UserInfoModel model = JsonConvert.DeserializeObject <UserInfoModel>(results);
                    //AttentionList = model.attentions;
                    return(model);
                }
                catch (Exception)
                {
                    return(null);
                }
            }
            else
            {
                return(null);
            }
        }
예제 #9
0
        private void Http_DownloadStringCompleted(object sender, DownloadStringCompletedEventArgs e)
        {
            try
            {
                string response = e.Result;

                JArray       result  = JArray.Parse(response);
                List <Asset> asserts = new List <Asset>();

                bool hasBeta   = false;
                bool hasStable = false;

                if (result != null)
                {
                    foreach (JObject release in result)
                    {
                        if ((bool)release["prerelease"])
                        {
                            if (!hasBeta)
                            {
                                Asset ass = new Asset();
                                ass.Parase(release);
                                if (ass.IsNewVersion(Version))
                                {
                                    asserts.Add(ass);
                                    hasBeta = true;
                                }
                            }
                        }
                        else
                        {
                            Asset ass = new Asset();
                            ass.Parase(release);
                            if (ass.IsNewVersion(Version))
                            {
                                asserts.Add(ass);
                                hasStable = true;
                            }
                            break;
                        }
                    }
                }

                if (asserts.Count != 0)
                {
                    foreach (Asset ass in asserts)
                    {
                        Log.Info($"发现新版本{ass.name}" + (ass.prerelease ? "beta" : ""));
                    }
                    int    stable    = asserts.Count - 1;
                    string changelog = "更新日志获取失败惹 T T";
                    try
                    {
                        changelog = BiliInterface.GetHtml("https://raw.githubusercontent.com/SkiTiSu/BiliRanking/master/BiliRanking/changelog.txt");
                        changelog = changelog.Substring(0, changelog.IndexOf("\n\n"));
                    }
                    catch
                    {
                        Log.Warn("更新日志获取失败");
                    }
                    if (!checkBeta && hasStable)
                    {
                        DialogResult res = MessageBox.Show($"发现新版本{asserts[stable].name}啦\r\n最近{changelog}\r\n\r\n马上更新嘛?", @"\(^o^)/更新啦", MessageBoxButtons.YesNo);
                        if (res == DialogResult.Yes)
                        {
                            StartDownload(asserts[stable]);
                        }
                        else
                        {
                            Log.Info("更新被取消");
                        }
                    }
                    else if (checkBeta && (hasBeta || hasStable))
                    {
                        DialogResult res = MessageBox.Show($"发现新版本{asserts[0].name}beta啦\r\n最近{changelog}\r\n\r\n马上更新嘛?", @"\(^o^)/更新啦", MessageBoxButtons.YesNo);
                        if (res == DialogResult.Yes)
                        {
                            StartDownload(asserts[0]);
                        }
                        else
                        {
                            Log.Info("更新被取消");
                        }
                    }
                    else
                    {
                        Log.Info("没有符合要求的更新");
                    }
                }
                else
                {
                    Log.Info("没有发现新版本");
                }
            }
            catch (Exception ex)
            {
                Log.Error("检查更新失败 - 解析json失败");
                Log.Debug(ex.Message);
            }
        }