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); }
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); }
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); }
private bool filter(JsonClass jc, Element td) { bool filterflag = false; List<string> filterDate = new List<string>(); string year = comboBox3.SelectedItem.ToString(); string year2 = comboBox2.SelectedItem.ToString(); string[] months = "1".Equals(comboBox2.SelectedItem.ToString()) == true ? "01,02,03".Split(',') : "4".Equals(comboBox2.SelectedItem.ToString()) == true ? "04,05,06".Split(',') : "7".Equals(comboBox2.SelectedItem.ToString()) == true ? "07,08,09".Split(',') : "10".Equals(comboBox2.SelectedItem.ToString()) == true ? "10,11,12".Split(',') : null; for (int i = 0; i < 3; ++i) { for (int j = 1; j < 32; ++j) { filterDate.Add(year + "-" + months[i] + "-" + (j < 10 ? "0" + j : j + "")); filterDate.Add(year + "." + months[i] + "." + (j < 10 ? "0" + j : j + "")); } } string asd = ""; /* * if (jc.episode.Equals(comboBox2.SelectedItem.ToString())) * { */ NSoup.Select.Elements td_a = td.Select("a"); /* NSoup.Select.Elements td_span = td.Select("span"); */ foreach (Element a in td_a) { asd += a.Text(); } /* * foreach (Element a in td_span) * { * asd += a.Text(); * } */ foreach (string s in filterList) { asd = asd.Replace(s, " "); } foreach (string s in filterDate) { asd = asd.Replace(s, " "); } if (asd.IndexOf(jc.episode) == -1) { filterflag = true; } foreach (string s in filterList2) { if (asd.IndexOf(s) > -1) { filterflag = true; } } /* } */ return (filterflag); }
private void button4_Click(object sender, EventArgs e) /* 新增 */ { string name = prompt.ShowDialog("input your title", "我爱冷泉麻子"); if (name != "") { string[] lines = name.Split('\n'); for (int i = 0; i < lines.Length; i += 1) lines[i] = lines[i].Trim(); for (int i = 0; i < lines.Length; i += 1) { JsonClass jc = new JsonClass(); jc.titleCN = lines[i]; jc.weekDayCN = comboBox1.SelectedIndex + ""; jc.weekDayJP = comboBox1.SelectedIndex + ""; jc.isOrderRabbit = "0"; jc.episode = "01"; jc.searchKeyword = lines[i]; jc.fansub = " "; jsonList.Add(jc); writeLocalJson(jsonList, jsonName); comboBox1comboBox2_SelectedIndexChanged(); } } }