void changeToc(int index) { if (index < 0) { //混合源 if (mMixToc != null) { mChapers = mMixToc.chapters; } label_toc.Text = "当前书源:混合源"; } else { var toc = mTocs[index]; var info = LibZhuiShu.getChaperList(toc._id); if (info != null) { mChapers = info.chapters; } label_toc.Text = "当前书源:" + toc.name; } if (mChapers != null) { UpdateChapterList(mChapers); } txtFrom.Maximum = mChapers.Length; txtTo.Maximum = mChapers.Length + 1; txtTo.Value = txtTo.Maximum; lblChapterCount.Text = $"共 {mChapers.Length + 1} 章"; }
/// <summary> /// 开始下载 /// </summary> public void StartDownload() { // 获得章节列表和所有书源 var mixTocInfo = LibZhuiShu.getMixToc(mBookID); // 获得所有书源 var tocs = LibZhuiShu.getTocSummary(mBookID); List <TocChaperListInfo> tocChaperListInfoList = new List <TocChaperListInfo>(); foreach (var toc in tocs) { if (toc.name == "优质书源") { continue; } var tocChaperList = LibZhuiShu.getChaperList(toc._id); tocChaperListInfoList.Add(tocChaperList); } foreach (var chapter in mixTocInfo.chapters) { ChapterDownloadContext context = new ChapterDownloadContext() { title = chapter.title }; context.links.Add(chapter.link); foreach (var tocChaterListInfo in tocChaperListInfoList) { foreach (var tocChapter in tocChaterListInfo.chapters) { if (tocChapter.title.Replace(" ", "").ToLower() == context.title.Replace(" ", "").ToLower()) { if (!context.links.Contains(tocChapter.link)) { context.links.Add(tocChapter.link); } break; } } } mChapters.Add(context); mChaptersDownloadQueue.Enqueue(context); } for (int i = 0; i < 10; i++) { Thread workThread = new Thread(DownLoadThread); mWorkThreads.Add(workThread); workThread.Start(); } }
static void Main(string[] args) { var result = LibZhuiShu.autoComplate("完美"); var books = LibZhuiShu.fuzzySearch("完美世界", 0, 1); foreach (var book in books) { Console.WriteLine(string.Format("{0} {1} {2}", book._id, book.title, book.author)); var tocs = LibZhuiShu.getTocSummary(book._id); var chapertList = LibZhuiShu.getChaperList(tocs[0]._id); Console.WriteLine(LibZhuiShu.getChapter(chapertList.chapters[0].link).body); } foreach (var item in result) { Console.WriteLine("章节:" + item); Console.ReadKey(); } }
void ChangeToc(int index) { if (index < 0) { //混合源 if (mMixToc != null) { mChapers = mMixToc.chapters; } label_toc.Text = "当前书源:混合源"; } else { var toc = mTocs[index]; var info = LibZhuiShu.getChaperList(toc._id); if (info != null) { mChapers = info.chapters; } label_toc.Text = "当前书源:" + toc.name; } if (mChapers != null) { listview_chapers.BeginUpdate(); listview_chapers.Items.Clear(); foreach (var chaper in mChapers) { ListViewItem item = new ListViewItem() { Text = chaper.title }; item.SubItems.Add(chaper.link); listview_chapers.Items.Add(item); } listview_chapers.EndUpdate(); } }