예제 #1
0
        public static void RefreshColorSceme()
        {
            MaterialSkinManager materialSkinManager = MaterialSkinManager.Instance;

            if (Other.IsDarkMode())
            {//Dark Mode
                materialSkinManager.ColorScheme = new ColorScheme(Primary.Grey900, Primary.Grey700, Primary.Grey700, Accent.Pink100, TextShade.WHITE);
                materialSkinManager.Theme       = MaterialSkinManager.Themes.DARK;
            }
            else
            {
                materialSkinManager.ColorScheme = new ColorScheme(Primary.Indigo500, Primary.Indigo700, Primary.Indigo100, Accent.Pink100, TextShade.WHITE);
                materialSkinManager.Theme       = MaterialSkinManager.Themes.LIGHT;
            }
            if (env.mainForm == null || env.mainForm.materialLabel2 == null)
            {
                return;
            }

            env.mainForm.materialLabel2.BackColor = GetBackGroundColor();
        }
예제 #2
0
        private void Initialize()
        {
            Directory.CreateDirectory(Environment.CurrentDirectory + "/config");
            Directory.CreateDirectory(Environment.CurrentDirectory + "/temp");
            RefreshUserData();
            Settings.ReadSettings();
            materialSingleLineTextField2.Text = Settings.maxMission.ToString();
            LowCache.Checked         = Settings.lowcache;
            materialLabel2.BackColor = Other.GetBackGroundColor();
            Tabs.Size = new Size(Tabs.Width, Tabs.Height + 30);
            materialCheckBox1.Checked   = Settings.usearia2c;
            materialCheckBox2.Checked   = Settings.downloaddanmaku;
            materialCheckBox4.Checked   = Settings.downloadcc;
            aria2cargu.Visible          = materialCheckBox1.Checked;
            aria2cargu.Text             = Settings.aria2cargument;
            materialFlatButton7.Visible = materialCheckBox1.Checked;
            APILink.Text = Settings.apilink;
            AreaSelector.SelectedIndex = Settings.area switch
            {
                "cn" => 0,
                "hk" => 1,
                "tw" => 2,
                "th" => 3,
                _ => 0
            };
            if (Environment.OSVersion.Platform == PlatformID.Unix)
            {
                Tabs.Region             = new Region(new RectangleF(Tabs.Left, Tabs.Top, Tabs.Width, Tabs.Height));
                TabSelector.Location    = new System.Drawing.Point(0, 64);
                materialLabel2.Location = new Point(411, 80);
                materialLabel2.Size     = new Size(691, 25);
                videoList1.Size         = new Size(1200, 650);
                videoList1.Location     = new Point(-5, 70);
                panel3.Location         = new Point(0, 5);
            }

            checkUpdate();
        }
예제 #3
0
        public MainForm()
        {
            InitializeComponent();
            var materialSkinManager = MaterialSkinManager.Instance;

            materialSkinManager.AddFormToManage(this);


            if (Other.IsDarkMode())
            {//Dark Mode
                materialSkinManager.ColorScheme = new ColorScheme(Primary.BlueGrey500, Primary.BlueGrey900, Primary.BlueGrey500, Accent.LightBlue200, TextShade.WHITE);
                materialSkinManager.Theme       = MaterialSkinManager.Themes.DARK;
            }
            else
            {
                materialSkinManager.ColorScheme = new ColorScheme(Primary.Indigo500, Primary.Indigo500, Primary.Indigo500, Accent.LightBlue200, TextShade.WHITE);
                materialSkinManager.Theme       = MaterialSkinManager.Themes.LIGHT;
            }
            RefreshUserData();
            Settings.ReadSettings();
            materialSingleLineTextField2.Text = Settings.maxMission.ToString();
            materialLabel2.BackColor          = Other.GetBackGroundColor();
        }
예제 #4
0
 private bool GetDownloadUrls()
 {
     if (quality < VideoQuality.Q4K)
     {
         //下载链接api为 https://api.bilibili.com/x/player/playurl?avid=44743619&cid=78328965&qn=32 cid为上面获取到的 avid为输入的av号 qn为视频质量
         //https://www.biliplus.com/BPplayurl.php?otype=json&cid=29892777&module=bangumi&qn=16
         WebClient MyWebClient = new WebClient();
         MyWebClient.Credentials = CredentialCache.DefaultCredentials;//获取或设置用于向Internet资源的请求进行身份验证的网络凭据
         string callback = "";
         try
         {
             if (!Settings.outland)
             {
                 MyWebClient.Headers.Add("Cookie", User.cookie);
                 callback = Encoding.UTF8.GetString(MyWebClient.DownloadData(string.Format("https://api.bilibili.com/x/player/playurl?avid={0}&cid={1}&qn={2}", aid, cid, quality.ToString()))); //如果获取网站页面采用的是UTF-8,则使用这句
             }
             else
             {
                 System.Net.ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;                                                                                                                          //加上这一句
                 callback = Encoding.UTF8.GetString(MyWebClient.DownloadData(string.Format("https://www.biliplus.com/BPplayurl.php?otype=json&module=bangumi&avid={0}&cid={1}&qn={2}", aid, cid, quality.ToString()))); //如果获取网站页面采用的是UTF-8,则使用这句
             }
         }
         catch (WebException e)
         {
             Dialog.Show("无法下载," + e.Message);
             return(false);
         }
         MyWebClient.Dispose();
         if (!Settings.outland)
         {
             JSONCallback.Player.Player player = JsonConvert.DeserializeObject <JSONCallback.Player.Player>(callback);
             if (player.code == -404)
             {
                 Dialog.Show(string.Format("无法下载 {0}({1}), 该视频需要大会员登录下载,请先登录", player.code, player.message), "获取错误");
                 return(false);
             }
             else if (player.code != 0)
             {
                 Dialog.Show(string.Format("无法下载 {0}({1})", player.code, player.message), "获取错误");
                 return(false);
             }
             if (!player.data.accept_quality.Contains(quality))
             {
                 Console.WriteLine(string.Format("没有指定的画质 {0} ,最高画质为 {1}, 自动下载最高画质{1}", VideoQuality.Name(quality), VideoQuality.Name(player.data.accept_quality[0])));
                 quality = player.data.accept_quality[0];
                 return(GetDownloadUrls());//我太懒了,直接递归吧
             }
             foreach (JSONCallback.Player.DurlItem Item in player.data.durl)
             {
                 DownloadUrl du = new DownloadUrl();
                 du.url  = Item.url;
                 du.size = Item.size;
                 urls.Add(du);
             }
             return(true);
         }
         else
         {
             if (callback == "")
             {
                 Dialog.Show(string.Format("使用BiliPlus API出错!"), "获取错误");
                 return(false);
             }
             JSONCallback.BiliPlus.Player player = JsonConvert.DeserializeObject <JSONCallback.BiliPlus.Player>(callback);
             if (!player.accept_quality.Contains(quality))
             {
                 Console.WriteLine(string.Format("没有指定的画质 {0} ,最高画质为 {1}, 自动下载最高画质{1}", VideoQuality.Name(quality), VideoQuality.Name(player.accept_quality[0])));
                 quality = player.accept_quality[0];
                 return(GetDownloadUrls());//我太懒了,直接递归吧
             }
             foreach (JSONCallback.BiliPlus.DurlItem Item in player.durl)
             {
                 DownloadUrl du = new DownloadUrl();
                 du.url  = Item.url;
                 du.size = Item.size;
                 urls.Add(du);
             }
             return(true);
         }
     }
     else
     {
         string callback = Other.GetHtml("https://www.bilibili.com/video/av" + aid, true);
         string json     = Other.TextGetCenter("window.__playinfo__=", "</script>", callback);
         Console.WriteLine(json);
         try
         {
             JSONCallback.FourKPlayer.FourKPlayer player = JsonConvert.DeserializeObject <JSONCallback.FourKPlayer.FourKPlayer>(json);
             if (player.code == -404)
             {
                 Dialog.Show(string.Format("无法下载 {0}({1}), 该视频需要大会员登录下载,请先登录", player.code, player.message), "获取错误");
                 return(false);
             }
             else if (player.code != 0)
             {
                 Dialog.Show(string.Format("无法下载 {0}({1})", player.code, player.message), "获取错误");
                 return(false);
             }
             if (!player.data.accept_quality.Contains(quality))
             {
                 Console.WriteLine(string.Format("没有指定的画质 {0} ,最高画质为 {1}, 自动下载最高画质{1}", VideoQuality.Name(quality), VideoQuality.Name(player.data.accept_quality[0])));
                 quality = player.data.accept_quality[0];
                 return(GetDownloadUrls());//我太懒了,直接递归吧
             }
             foreach (JSONCallback.FourKPlayer.VideoItem Item in player.data.dash.video)
             {
                 if (Item.id != quality)
                 {
                     continue;
                 }
                 DownloadUrl du = new DownloadUrl();
                 du.type = Item.mimeType.Replace("video/", "");
                 du.url  = Item.baseUrl;
                 du.size = -1;//暂不支持检测大小
                 urls.Add(du);
                 du      = new DownloadUrl();
                 du.type = "mp3";
                 du.url  = player.data.dash.audio[1].baseUrl;
                 du.size = -1;//暂不支持检测大小
                 urls.Add(du);
                 return(true);
             }
             return(false);
         }
         catch (Exception e)
         {
             Console.WriteLine("4K获取出错,正在尝试降级后重试.");
             quality = VideoQuality.Q1080P60;
             return(GetDownloadUrls());
         }
     }
 }
예제 #5
0
        public Video(string vlink)
        {
            //第一步,bilibili网址转换
            //注意垃圾spm!
            //例如 https://www.bilibili.com/bangumi/play/ss28615/?spm=3.0212
            if (vlink.IndexOf("?") != -1)
            {//去除后置参数
                vlink = vlink.Substring(0, vlink.IndexOf("?"));
            }

            if (vlink.Contains("space.bilibili.com"))
            {
                //https://space.bilibili.com/341151171

                string uid = vlink.Substring(vlink.LastIndexOf("/") + 1, vlink.Length - 1 - vlink.LastIndexOf("/"));
                ProcessUid(uid);
                return;
            }

            vlink = Other.TextGetCenter("/", "/?", vlink);
            if (vlink.EndsWith("/"))
            {
                vlink = vlink.Substring(0, vlink.Length - 1);
            }
            vlink = Other.TextGetCenter("/", "?", vlink);


            //第二步判断格式
            if (vlink.Contains("BV"))
            {
                Type  = VideoType.AV;
                vlink = "av" + Video.ProcessBV(vlink);
            }
            vlink = vlink.ToLower();
            if (vlink.Contains("av"))
            {
                Type = VideoType.AV;
                ProcessAV(vlink.Replace("av", ""));
            }
            else if (vlink.Contains("ep"))
            {
                Type = VideoType.SS;
                ProcessEP(vlink.Replace("ep", ""));
            }
            else if (vlink.Contains("ss"))
            {
                Type = VideoType.SS;
                ProcessSS(vlink.Replace("ss", ""));
            }
            else if (vlink.Contains("md"))
            {
                ProcessMD(vlink.Replace("md", ""));
            }
            else if (vlink.Contains("ml"))
            {
                ProcessML(vlink.Replace("ml", ""));
            }
            else if (vlink.Contains("uid"))
            {
                ProcessUid(vlink.Replace("uid", ""));
            }
            else
            {
                Dialog.Show("不是可以获取的格式,请检查格式是否正确");
            }
        }