Exemple #1
0
        string getTorrentFromAcgRip(string keywordURL, bool longepisode, JsonClass jc) /* 获取种子 */
        {
            bool bb = jc.longepisode == "1" ? true : false;
            List<string> filterEpisode = new List<string>();
            if (!bb)
            {
                /*
                 * if (jc.episode.Equals(comboBox2.SelectedItem.ToString()))
                 * {
                 */

                int countttttt = 0;
                try
                {
                    countttttt = Int32.Parse(jc.episode);
                }
                catch (Exception e)
                {
                    countttttt = 0;
                }
                int episode_before = countttttt - 1;

                for (int q = episode_before; q > -1; --q)
                {
                    filterEpisode.Add((q < 10 ? "0" + q : q + ""));
                }
                /* } */
            }
            string str_url = "nothing";
            keywordURL = keywordURL.Replace("\"", "");

            if ((from a in kwList
                 where a == keywordURL
                 select a).ToList().Count == 0)
            {
                /* kwList.Add(keywordURL); */
            }
            else
            {
                kwList.Add(keywordURL);
                return ("fail");
            }
            try
            {
                IFormatProvider culture = new CultureInfo("en-US", true);
                /*下载网页源代码 */
                MyWebClient webClient = new MyWebClient();
                string acg_rip = "https://acg.rip/";

                string url = "https://acg.rip/?term=" + keywordURL;

                string htmlString = Encoding.GetEncoding("utf-8").GetString(webClient.DownloadData(url));

                Document doc = NSoup.NSoupClient.Parse(htmlString);

                int countmax = 0;
                NSoup.Select.Elements tables = doc.Select("table[class=table table-hover table-condensed post-index]");

                if (tables.Count == 0)
                {
                    return ("nothing");
                }
                Element table = tables.First();
                int trCount = table.Select("tr").Count - 1;       /* 找不到结果也会是1 */
                Element tr = null;
                for (var i = 0; i < trCount; ++i)                     /* 第一行是标题 */
                {
                    try
                    {
                        if (i == 0)
                        {
                            NSoup.Select.Elements trs = doc.Select("table[class=table table-hover table-condensed post-index]").First().Select("tr:eq(" + i + ")");
                            tr = doc.Select("table[class=table table-hover table-condensed post-index]").First().Select("tr:eq(" + i + ")").Eq(1).First();
                        }
                        else
                        {
                            tr = doc.Select("table[class=table table-hover table-condensed post-index]").First().Select("tr:eq(" + i + ")").First();
                        }

                        bool filterflag = false;
                        Element td = tr.Select("td:eq(1)").First();
                        filterflag = filter(jc, td);
                        if (filterflag)
                        {
                            continue;
                        }

                        if (!longepisode)                                                                                             /* 如果是长期连载的 无视开播时间 */
                        {
                            string time_string = tr.Select("td:eq(0)").First().Select("div").Eq(1).First().Text();
                            if (time_string.IndexOf("分钟") > -1)
                            {

                            }
                            else if (time_string.IndexOf("小时") > -1)
                            {

                            }
                            else if (time_string.IndexOf("一天") > -1)
                            {

                            }
                            else if (time_string.IndexOf("年") > -1)
                            {
                                continue;
                            }
                            else if (time_string.IndexOf("月") > -1)
                            {
                                time_string = time_string.Replace("个月", "").Trim();
                                int months = Int16.Parse(time_string);
                                months *= -1;
                                DateTime dateVal = DateTime.Now.AddMonths(months);//DateTime.ParseExact(time_doc.Text(), "yyyy/MM/dd HH:mm", culture);  /* 片时间 */
                                string monthtmp = comboBox2.Items[comboBox2.SelectedIndex].ToString().Length < 2 ? "0" + comboBox2.Items[comboBox2.SelectedIndex].ToString() : comboBox2.Items[comboBox2.SelectedIndex].ToString();
                                string asdasdsad = comboBox3.Items[comboBox3.SelectedIndex].ToString() + "/"
                                                  + monthtmp + "/01 00:00";
                                DateTime currentSeason = DateTime.ParseExact(asdasdsad, "yyyy/MM/dd HH:mm", culture);                 /* 本季时间 */
                                if (DateTime.Compare(dateVal, currentSeason) < 0)                                                   /* 片要比本季时间大 */
                                    continue;
                            }
                            else if (time_string.IndexOf("天") > -1)
                            {
                                time_string = time_string.Replace("天", "").Trim();
                                int days = Int16.Parse(time_string);
                                days *= -1;
                                DateTime dateVal = DateTime.Now.AddDays(days); //DateTime.ParseExact(time_doc.Text(), "yyyy/MM/dd HH:mm", culture);  /* 片时间 */

                                string monthtmp = comboBox2.Items[comboBox2.SelectedIndex].ToString().Length < 2 ? "0" + comboBox2.Items[comboBox2.SelectedIndex].ToString() : comboBox2.Items[comboBox2.SelectedIndex].ToString();
                                string asdasdsad = comboBox3.Items[comboBox3.SelectedIndex].ToString() + "/"
                                                  + monthtmp + "/01 00:00";
                                DateTime currentSeason = DateTime.ParseExact(asdasdsad, "yyyy/MM/dd HH:mm", culture);                 /* 本季时间 */
                                if (DateTime.Compare(dateVal, currentSeason) < 0)                                                   /* 片要比本季时间大 */
                                    continue;
                            }  
                        }

                        Element countt = tr.Select("td:eq(4)").First().Select("span").Eq(2).First();


                        int count = 0;
                        try
                        {
                            count = Int32.Parse(countt.Text());
                        }
                        catch (Exception e)
                        {
                            count = 0;
                        }


                        if (count >= countmax)
                        {
                            Element torrent = tr.Select("td:eq(2)").First().Select("a").First();     /* 磁链地址 */
                            str_url = acg_rip + torrent.Attr("href");
                            countmax = count;
                        }
                    }
                    catch (Exception eeeee)
                    {
                        MessageBox.Show(jc.searchKeyword + " " + jc.episode + " tmd出错了,请联系tmd kenqq");
                        MessageBox.Show(eeeee.ToString());
                        /* str_url = "asd"; */
                    }
                }
            }
            catch (System.Net.WebException e)
            {
                kwList.Add(keywordURL);
                return ("fail");
            }
            catch (Exception e)
            {
                MessageBox.Show(e.ToString());
                kwList.Add(keywordURL);
                return ("fail");
            }
            return (str_url);
        }
Exemple #2
0
 string getTorrentFromNyaa(string keywordURL, bool longepisode) /* 获取种子 */
 {
     string str_url = null;
     keywordURL = keywordURL.Replace("\"", "");
     if ((from a in kwList
          where a == keywordURL
          select a).ToList().Count == 0)
     {
         /* kwList.Add(keywordURL); */
     }
     else
     {
         kwList.Add(keywordURL);
         return ("fail");
     }
     try
     {
         IFormatProvider culture = new CultureInfo("en-US", true);
         /*下载网页源代码 */
         MyWebClient webClient = new MyWebClient();
         string url = "http://www.nyaa.se/?page=search&term=" + keywordURL
                           + "&cats=1_0&minage=0&maxage=14";
         string htmlString = Encoding.GetEncoding("utf-8").GetString(webClient.DownloadData(url));
         Document doc = NSoup.NSoupClient.Parse(htmlString);
         if (htmlString.IndexOf("tlist") > -1)
         {
             /* --------------------- */
             int countmax = 0;
             int trCount = doc.Select("table.tlist").First().Select("tr").Count; /* 找不到结果会是2 */
             for (var i = 1; i < trCount; ++i)
             {
                 if (trCount == 2)
                 {
                     Element isnulldoc = doc.Select("table.tlist").First().Select("tr:eq(" + i + ")").First().Select("td").First().Select("b").First();
                     if (isnulldoc.Text() == "No torrents found.")
                         return ("nothing");
                 }
                 if (!longepisode) /* 如果是长期连载的 无视开播时间 */
                 {
                 }
                 Element countt = doc.Select("table.tlist").First().Select("tr:eq(" + i + ")").First().Select("td:eq(6)").First();
                 int count = 0;
                 try
                 {
                     count = Int32.Parse(countt.Text());
                 }
                 catch (Exception e)
                 {
                     count = 0;
                 }
                 if (count >= countmax)
                 {
                     Element torrent = doc.Select("table.tlist").First().Select("tr:eq(" + i + ")").First()
                               .Select("td[class=tlistdownload]").First().Select("a").First(); /* 种子地址 */
                     countmax = count;
                     str_url = torrent.Attr("href");
                 }
             }
             /* /---------- */
         }
         else
         {
             Element asd = doc.Select("div[class=viewdownloadbutton]").First();
             str_url = doc.Select("div[class=viewdownloadbutton] a[rel=nofollow]").First().Attr("href"); /* 找不到结果会是2 */
         }
     }
     catch (System.Net.WebException e)
     {
         kwList.Add(keywordURL);
         return ("fail");
     }
     catch (Exception e)
     {
         MessageBox.Show(e.ToString());
         kwList.Add(keywordURL);
         return ("fail");
     }
     return (str_url);
 }
Exemple #3
0
        string getTorrentFromDmhy(string keywordURL, bool longepisode, JsonClass jc) /* 获取种子 */
        {
            bool bb = jc.longepisode == "1" ? true : false;
            List<string> filterEpisode = new List<string>();
            if (!bb)
            {
                /*
                 * if (jc.episode.Equals(comboBox2.SelectedItem.ToString()))
                 * {
                 */

                int countttttt = 0;
                try
                {
                    countttttt = Int32.Parse(jc.episode);
                }
                catch (Exception e)
                {
                    countttttt = 0;
                }
                int episode_before = countttttt - 1;

                for (int q = episode_before; q > -1; --q)
                {
                    filterEpisode.Add((q < 10 ? "0" + q : q + ""));
                }
                /* } */
            }
            string str_url = "nothing";
            keywordURL = keywordURL.Replace("\"", "");

            if ((from a in kwList
                 where a == keywordURL
                 select a).ToList().Count == 0)
            {
                /* kwList.Add(keywordURL); */
            }
            else
            {
                kwList.Add(keywordURL);
                return ("fail");
            }
            try
            {
                IFormatProvider culture = new CultureInfo("en-US", true);
                /*下载网页源代码 */
                MyWebClient webClient = new MyWebClient();
                string dmhy = "http://share.dmhy.org";

                string url = "http://share.dmhy.org/topics/list?keyword=" + keywordURL + "&team_id=0&order=date-desc";

                /* string url = "http://share.dmhy.org/"; */

                string htmlString = Encoding.GetEncoding("utf-8").GetString(webClient.DownloadData(url));

                Document doc = NSoup.NSoupClient.Parse(htmlString);

                int countmax = 0;
                NSoup.Select.Elements tables = doc.Select("table#topic_list");
                if (tables.Count == 0)
                {
                    return ("nothing");
                }
                Element table = tables.First();
                int trCount = table.Select("tr").Count - 1;       /* 找不到结果也会是1 */
                Element tr = null;
                for (var i = 0; i < trCount; ++i)                     /* 第一行是标题 */
                {
                    try
                    {
                        if (i == 0)
                        {
                            NSoup.Select.Elements trs = doc.Select("table#topic_list").First().Select("tr:eq(" + i + ")");
                            tr = doc.Select("table#topic_list").First().Select("tr:eq(" + i + ")").Eq(1).First();
                        }
                        else
                        {
                            tr = doc.Select("table#topic_list").First().Select("tr:eq(" + i + ")").First();
                        }
                        string type = tr.Select("td:eq(1)").First().Text();
                        if (!(type == "特攝" || type == "動畫"))
                        {
                            continue;
                        }
                        bool filterflag = false;
                        Element td = doc.Select("tbody").First().Select("tr:eq(" + i + ")").First().Select("td:eq(2)").First();
                        filterflag = filter(jc, td);
                        if (filterflag)
                        {
                            continue;
                        }
                        if (!longepisode)                                                                                             /* 如果是长期连载的 无视开播时间 */
                        {
                            Element time_doc = tr.Select("td:eq(0)").First().Select("span").First();
                            DateTime dateVal = DateTime.ParseExact(time_doc.Text(), "yyyy/MM/dd HH:mm", culture);  /* 片时间 */
                            string monthtmp = comboBox2.Items[comboBox2.SelectedIndex].ToString().Length < 2 ? "0" + comboBox2.Items[comboBox2.SelectedIndex].ToString() : comboBox2.Items[comboBox2.SelectedIndex].ToString();
                            string asdasdsad = comboBox3.Items[comboBox3.SelectedIndex].ToString() + "/"
                                              + monthtmp + "/01 00:00";
                            DateTime currentSeason = DateTime.ParseExact(asdasdsad, "yyyy/MM/dd HH:mm", culture);                 /* 本季时间 */
                            if (DateTime.Compare(dateVal, currentSeason) < 0)                                                   /* 片要比本季时间大 */
                                continue;
                            /* return ("time"); */
                        }
                        Element countt = tr.Select("td:eq(7)").First();


                        int count = 0;
                        try
                        {
                            count = Int32.Parse(countt.Text());
                        }
                        catch (Exception e)
                        {
                            count = 0;
                        }


                        if (count >= countmax)
                        {
                            /* Element torrent = tr.Select("td:eq(3)").First().Select("a[class=download-arrow arrow-torrent]").First(); / * 种子地址 * / */
                            Element magnet = tr.Select("td:eq(3)").First().Select("a[class=download-arrow arrow-magnet]").First();     /* 磁链地址 */
                            Element innerlink = tr.Select("td:eq(2)").First().Select("a").Last();                                         /* 内部链接地址 用于获取地址 */

                            countmax = count;
                            if (checkBox4.CheckState == CheckState.Checked)
                            {
                                /* str_url = dmhy + torrent.Attr("href"); */
                                string inner_url = dmhy + innerlink.Attr("href");
                                string innerhtmlString = Encoding.GetEncoding("utf-8").GetString(webClient.DownloadData(inner_url));
                                Document innerdoc = NSoup.NSoupClient.Parse(innerhtmlString);
                                Element torrent = innerdoc.GetElementById("tabs-1").Select("a").First();
                                str_url = "http:" + torrent.Attr("href");
                                /* str_url = magnet.Attr("href"); */
                            }
                            else
                            {
                                str_url = magnet.Attr("href");
                            }
                        }
                    }
                    catch (Exception eeeee)
                    {
                        MessageBox.Show(jc.searchKeyword + " " + jc.episode + " tmd出错了,请联系tmd kenqq");
                        MessageBox.Show(eeeee.ToString());
                        /* str_url = "asd"; */
                    }
                }
            }
            catch (System.Net.WebException e)
            {
                kwList.Add(keywordURL);
                return ("fail");
            }
            catch (Exception e)
            {
                MessageBox.Show(e.ToString());
                kwList.Add(keywordURL);
                return ("fail");
            }
            return (str_url);
        }
Exemple #4
0
        private static ArrayList DmhyFiveDoces()
        {
            try
            {
                if (lad == null)
                {
                    lad = new ArrayList();
                    IFormatProvider culture = new CultureInfo("en-US", true);
                    /*下载网页源代码 */
                    MyWebClient webClient = new MyWebClient();
                    string url;

                    for (int i = 1; i < 4 + 1; ++i)
                    {
                        url = "http://share.dmhy.org/topics/list/sort_id/2/page/" + i;
                        lad.Add(NSoup.NSoupClient.Parse(Encoding.GetEncoding("utf-8").GetString(webClient.DownloadData(url))));
                    }
                }
            }
            catch (Exception e)
            {
                MessageBox.Show(e.ToString());
            }


            return (lad);
        }
Exemple #5
0
        string getTorrentFromKtxp(string keywordURL, bool longepisode, JsonClass jc) /* 获取种子 */
        {
            string str_url = "nothing";
            keywordURL = keywordURL.Replace("\"", "");
            if ((from a in kwList
                 where a == keywordURL
                 select a).ToList().Count == 0)
            {
                /* kwList.Add(keywordURL); */
            }
            else
            {
                kwList.Add(keywordURL);
                return ("fail");
            }
            try
            {
                IFormatProvider culture = new CultureInfo("en-US", true);
                /*下载网页源代码 */
                MyWebClient webClient = new MyWebClient();
                string ktxp = "http://bt.ktxp.com";
                string sort_addate = "&order=addate";
                string sort_seeders = "&order=seeders";
                string url = "http://bt.ktxp.com/search.php?keyword=" + keywordURL
                                  + "&sort_id=12";
                int param = 0;
                if (param == 0)
                {
                    url += sort_addate;
                }
                else if (param == 1)
                {
                    url += sort_addate;
                }
                string htmlString = Encoding.GetEncoding("utf-8").GetString(webClient.DownloadData(url));
                Document doc = NSoup.NSoupClient.Parse(htmlString);
                int countmax = 0;
                int trCount = doc.Select("tbody").First().Select("tr").Count; /* 找不到结果也会是1 */
                for (var i = 0; i < trCount; ++i)
                {
                    if (trCount == 1)
                    {
                        Element isnulldoc = doc.Select("tbody").First().Select("tr:eq(" + i + ")").First().Select("td").First();
                        if (isnulldoc.Text() == "没有可显示资源")
                            return ("nothing");
                    }

                    if (!longepisode)                                                                                                     /* 如果是长期连载的 无视开播时间 */
                    {
                        Element time_doc = doc.Select("tbody").First().Select("tr:eq(" + i + ")").First().Select("td:eq(0)").First();
                        DateTime dateVal = DateTime.ParseExact(time_doc.Attr("title"), "yyyy/MM/dd HH:mm", culture); /* 片时间 */
                        string monthtmp = comboBox2.Items[comboBox2.SelectedIndex].ToString().Length < 2 ? "0" + comboBox2.Items[comboBox2.SelectedIndex].ToString() : comboBox2.Items[comboBox2.SelectedIndex].ToString();
                        string asdasdsad = comboBox3.Items[comboBox3.SelectedIndex].ToString() + "/"
                                          + monthtmp + "/01 00:00";
                        DateTime currentSeason = DateTime.ParseExact(asdasdsad, "yyyy/MM/dd HH:mm", culture);                         /* 本季时间 */
                        if (DateTime.Compare(dateVal, currentSeason) < 0)                                                           /* 片要比本季时间大 */
                            return ("time");
                    }
                    bool filterflag = false;
                    Element td = doc.Select("tbody").First().Select("tr:eq(" + i + ")").First().Select("td:eq(2)").First();
                    filterflag = filter(jc, td);
                    if (filterflag)
                    {
                        continue;
                    }
                    Element countt = doc.Select("tbody").First().Select("tr:eq(" + i + ")").First().Select("td:eq(6)").First();
                    int count = 0;
                    try
                    {
                        count = Int32.Parse(countt.Text());
                    }
                    catch (Exception e)
                    {
                        count = 0;
                    }
                    if (count >= countmax)
                    {
                        Element torrent = doc.Select("tbody").First().Select("tr:eq(" + i + ")").First()
                                  .Select("td[class=ltext ttitle]").First().Select("a[class=quick-down cmbg]").First(); /* 种子地址 */
                        countmax = count;
                        str_url = ktxp + torrent.Attr("href");
                    }
                }
            }
            catch (System.Net.WebException e)
            {
                kwList.Add(keywordURL);
                return ("fail");
            }
            catch (Exception e)
            {
                MessageBox.Show(e.ToString());
                kwList.Add(keywordURL);
                return ("fail");
            }
            return (str_url);
        }
Exemple #6
0
 private void useDmhyKeyword(Newtonsoft.Json.Linq.JArray jsonList)
 {
     if(jsonList==null || jsonList.Count == 0)
     {
         return;
     }
     MyWebClient webClient = new MyWebClient();
     byte[] contentBytes = webClient.DownloadData(dmhyBgmListUrl);
     string content = Encoding.UTF8.GetString(contentBytes, 0, contentBytes.Length);
     int startIndex = content.IndexOf("sunarray.push(['");
     List<string[]> bgmList = new List<string[]>();
     while (startIndex != -1)
     {
         int endIndex = content.IndexOf("','", startIndex);
         if (endIndex == -1)
         {
             break;
         }
         startIndex = endIndex + 3;
         endIndex = content.IndexOf("','", startIndex);
         if (endIndex == -1)
         {
             break;
         }
         string bgmName = content.Substring(startIndex, endIndex - startIndex);
         startIndex = endIndex + 3;
         endIndex = content.IndexOf("','", startIndex);
         string bgmKeyword = content.Substring(startIndex, endIndex - startIndex);
         bgmList.Add(new string[] { bgmName, bgmKeyword});
         startIndex = content.IndexOf("array.push(['", endIndex);
     }
     if (bgmList.Count > 0)
     {
         foreach (Newtonsoft.Json.Linq.JObject json in jsonList)
         {
             foreach(string[] bgm in bgmList)
             {
                 if (isSameAnimate(json["titleCN"].ToString(), bgm[0]))
                 {
                     json.Remove("searchKeyword");
                     json.Add("searchKeyword", System.Web.HttpUtility.UrlDecode(bgm[1]));
                     bgmList.Remove(bgm);
                     break;
                 }
             }
         }
     }
 }
Exemple #7
0
        private void readJson(int month) /* 读取动画详细信息json */
        {
            Newtonsoft.Json.Linq.JArray jsonList1;
            string url = "";
            int t_month = month >= 10 ? 10 : month >= 7 ? 7 : month >= 4 ? 4 : month >= 1 ? 1 : 1;
            int t_year = comboBox3.SelectedIndex == -1 ? year : Int32.Parse(comboBox3.Items[comboBox3.SelectedIndex].ToString());
            foreach (archive a in archiveList)
            {
                if (a.year == t_year + "")
                {
                    foreach (months m in a.months)
                    {
                        if (m.month == t_month + "")
                        {
                            url = bgmlist + m.json;
                        }
                    }
                }
            }
            int adasd = "http://bgmlist.com/json/".Length;
            jsonName = url.Substring(adasd, url.Length - adasd);

            /* **   本地json没有创建的话 */
            if (System.IO.File.Exists(Path.Combine(appdataFAPI, @jsonName)))
            {
                readLocalJson(Path.Combine(appdataFAPI, @jsonName));
            }
            else
            {
                try
                {
                    var pt = ProxyDetails.ProxyType;
                    ProxyDetails.ProxyType = (ProxyType)System.Enum.Parse(typeof(ProxyType), "None");

                    MyWebClient webClient = new MyWebClient();
                    byte[] b = webClient.DownloadData(url);
                    string jsonText = Encoding.UTF8.GetString(b, 0, b.Length);
                    Newtonsoft.Json.Linq.JObject aaaa = (Newtonsoft.Json.Linq.JObject)JsonConvert.DeserializeObject(jsonText);
                    jsonList1=new Newtonsoft.Json.Linq.JArray();
                    foreach (var item in aaaa)
                    {
                        jsonList1.Add(item.Value);
                        //Console.WriteLine(item.Key + item.Value);
                    }
                    //jsonList1 = (Newtonsoft.Json.Linq.JArray)JsonConvert.DeserializeObject(jsonText);
                    foreach (Newtonsoft.Json.Linq.JObject a in jsonList1)
                    {
                        a.Add("isOrderRabbit", "0");                                          /* 是否订阅 */
                        a.Add("episode", "01");                                               /* 集数 默认01 */
                        a.Add("searchKeyword", a["titleCN"].ToString().Replace("-", " "));  /* 搜索用关键字 默认用json提供的 */
                        a.Add("fansub", " ");                                                 /* 字幕组 */
                        a.Add("longepisode", "0");                                            /* 长期连载 */
                        a.Add("lastDate", "");                                                /* 上一次完成时间 */
                    }
                    useDmhyKeyword(jsonList1);
                    writeLocalJson(jsonList1, jsonName);
                    readLocalJson(Path.Combine(appdataFAPI, @jsonName));
                    checkBox1.Checked = false;

                    ProxyDetails.ProxyType = pt;
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.ToString());
                }
            }
            dataGridView1.DataSource = (from a in jsonList
                                        where Convert.ToInt32(a.weekDayCN) == day
                                        select a).ToList(); ;
        }
Exemple #8
0
        private void readArchiveJson() /* 读取json汇总的json */
        {
            MyWebClient webClient = new MyWebClient();
            string url = "http://bgmlist.com/json/archive.json";
            bool local = System.IO.File.Exists(archive);
            try
            {
                if (local)
                {
                    readLocalArchiveJson();
                    var maxMonth = Int32.Parse(archiveList.OrderByDescending(item => item.year).First().months.OrderByDescending(item => item.month).First().month);
                    var maxYear = Int32.Parse(archiveList.OrderByDescending(item => item.year).First().year);
                    if (year > maxYear)
                    {
                        local = false;
                    }
                    else
                    {
                        if (maxMonth + 3 <= month)
                        {
                            local = false;
                        }
                    }
                }

                if (local)
                {
                    readLocalArchiveJson();
                }
                else
                {
                    archiveList=new List<I.archive>();
                    byte[] b = webClient.DownloadData(url);
                    string jsonText = Encoding.UTF8.GetString(b, 0, b.Length);
                    Newtonsoft.Json.Linq.JObject aaaa = (Newtonsoft.Json.Linq.JObject)JsonConvert.DeserializeObject(jsonText);
                    Newtonsoft.Json.Linq.JObject bb = (Newtonsoft.Json.Linq.JObject)aaaa.GetValue("data");
                    foreach (var item in bb)
                    {
                        archive asd=new archive();
                        asd.year=item.Key;
                        asd.months=new List<months>();
                        Newtonsoft.Json.Linq.JObject cc = (Newtonsoft.Json.Linq.JObject)item.Value;
                        foreach (var item1 in cc)
                        {
                            months m=new months();
                            m.month = item1.Key;
                            m.json = ((Newtonsoft.Json.Linq.JObject)item1.Value).GetValue("path").ToString();
                            asd.months.Add(m);
                        }
                        archiveList.Add(asd);
                    }
                    jsonText = JsonConvert.SerializeObject(archiveList);
                    //archiveList = JsonConvert.DeserializeObject<List<archive>>(jsonText);
                    System.IO.File.WriteAllText(archive, jsonText);
                }
            }
            catch (Exception ex)
            {
                if (System.IO.File.Exists(archive))
                {
                    readLocalArchiveJson();
                }
                if (archiveList == null || archiveList.Count < 1)
                {
                    MessageBox.Show(ex.Message);
                }
            }
        }
Exemple #9
0
        private List<JsonClass> readJson(int month, ComboBox comboBox2)//读取动画详细信息json
        {
            Newtonsoft.Json.Linq.JArray jsonList1;
            String url = getJsonNameUrl(month, comboBox2);
            String jsonName = getJsonName(url);

            //**   本地json没有创建的话
            if (System.IO.File.Exists(Path.Combine(appdataFAPI, @jsonName)))
            {
                return readLocalJson(Path.Combine(appdataFAPI, @jsonName));
            }
            else
            {
                MyWebClient webClient = new MyWebClient();
                byte[] b = webClient.DownloadData(url);
                string jsonText = Encoding.UTF8.GetString(b, 0, b.Length);
                jsonList1 = (Newtonsoft.Json.Linq.JArray)JsonConvert.DeserializeObject(jsonText);
                foreach (Newtonsoft.Json.Linq.JObject a in jsonList1)
                {
                    a.Add("isOrderRabbit", "0");//是否订阅
                    a.Add("episode", "01");//集数 默认01
                    a.Add("searchKeyword", a["titleCN"].ToString());//搜索用关键字 默认用json提供的
                    a.Add("fansub", " ");//字幕组
                    a.Add("longepisode", "0");//长期连载
                }
                writeLocalJson(jsonList1, jsonName);
                return readLocalJson(Path.Combine(appdataFAPI, @jsonName));
            }
        }
Exemple #10
0
        private void readArchiveJson()//读取json汇总的json
        {
            /**
            if (System.IO.File.Exists(archive))
            {
                readLocalArchiveJson();
            }
            else
            {
                MyWebClient webClient = new MyWebClient();
                string url = "http://bgmlist.com/json/archive.json";
                byte[] b = webClient.DownloadData(url);
                string jsonText = Encoding.UTF8.GetString(b, 0, b.Length);
                archiveList = JsonConvert.DeserializeObject<List<archive>>(jsonText);
                System.IO.File.WriteAllText(archive, jsonText);
            }
             * */
            /*
            MyWebClient webClient = new MyWebClient();
            string url = "http://bgmlist.com/json/archive.json";
            byte[] b = webClient.DownloadData(url);
            string jsonText = Encoding.UTF8.GetString(b, 0, b.Length);
            archiveList = JsonConvert.DeserializeObject<List<archive>>(jsonText);
            System.IO.File.WriteAllText(archive, jsonText);
             * */

            MyWebClient webClient = new MyWebClient();
            string url = "http://bgmlist.com/json/archive.json";
            archiveList = new List<I.archive>();
            byte[] b = webClient.DownloadData(url);
            string jsonText = Encoding.UTF8.GetString(b, 0, b.Length);
            Newtonsoft.Json.Linq.JObject aaaa = (Newtonsoft.Json.Linq.JObject)JsonConvert.DeserializeObject(jsonText);
            Newtonsoft.Json.Linq.JObject bb = (Newtonsoft.Json.Linq.JObject)aaaa.GetValue("data");
            foreach (var item in bb)
            {
                archive asd = new archive();
                asd.year = item.Key;
                asd.months = new List<months>();
                Newtonsoft.Json.Linq.JObject cc = (Newtonsoft.Json.Linq.JObject)item.Value;
                foreach (var item1 in cc)
                {
                    months m = new months();
                    m.month = item1.Key;
                    m.json = ((Newtonsoft.Json.Linq.JObject)item1.Value).GetValue("path").ToString();
                    asd.months.Add(m);
                }
                archiveList.Add(asd);
            }
            jsonText = JsonConvert.SerializeObject(archiveList);
            //archiveList = JsonConvert.DeserializeObject<List<archive>>(jsonText);
            System.IO.File.WriteAllText(archive, jsonText);
        }