Beispiel #1
0
        private void ReadNutDb()
        {
            using (var http = new GZipWebClient {
                Encoding = Encoding.UTF8
            })
            {
                http.Headers.Add("Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8");
                http.Headers.Add("User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.110 Safari/537.36");
                http.Headers.Add("Accept-Encoding: gzip, deflate, br");
                http.Headers.Add("Upgrade-Insecure-Requests: 1");

                var html = http.DownloadString(_config.NutdbUrl);
                var keys = new List <string>(html.Split(new[] { "\n" }, StringSplitOptions.RemoveEmptyEntries));
                if (keys.Count == 0)
                {
                    throw new Exception("没有得到数据");
                }


                //前3行 不要
                keys.RemoveAt(0);
                keys.RemoveAt(0);
                keys.RemoveAt(0);
                Invoke(new Action(() => { toolStripProgressBar_download.Maximum = keys.Count; }));
                var count = 0;
                foreach (var key in keys)
                {
                    var kan = key.Split('|');
                    //0                 |1                                  |2                                  |3          |4      |5      |6              |7              |8      |9
                    //id                |rightsId                           |key                                |isUpdate   |isDLC  |isDemo |baseName       |name           |version|region
                    //01000320000CC000  |01000320000CC0000000000000000000   |F64FBE562E753B662F7CC8D6C8B4EE79   |0          |0      |0      |1-2-Switch™    |1-2-Switch™    |0      |US

                    var tid    = kan[0];
                    var name   = kan[7];
                    var ver    = kan[8];
                    var region = kan[9] == "US" ? "AU" : kan[9]; //美区用不了.换掉

                    if (_titlekeys.ContainsKey(tid))             //只会得到本体
                    {
                        _titlekeys[tid]["ver"]    = ver;
                        _titlekeys[tid]["region"] = region;
                        _titlekeys[tid]["ename"]  = name;
                    }

                    Invoke(new Action(() => { toolStripProgressBar_download.Value = ++count; }));
                }
            }
        }
Beispiel #2
0
        private void DownloadExcel()
        {
            try
            {
                using (var http = new GZipWebClient())
                {
                    http.Headers.Add("Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8");
                    http.Headers.Add("User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.110 Safari/537.36");
                    http.Headers.Add("Accept-Encoding: gzip, deflate, br");
                    http.Headers.Add("Upgrade-Insecure-Requests: 1");

                    http.DownloadFile("https://raw.githubusercontent.com/ningxiaoxiao/NSGameDownloader/master/NSGameDownloader/db.xlsx", ExcelPath);
                }
            }
            catch (Exception e)
            {
                MessageBox.Show("无法访问github,无法更新最新网盘地址.请检查网络", "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }