diff --git a/README.md b/README.md index a1e3ba0..b2d9516 100644 --- a/README.md +++ b/README.md @@ -98,6 +98,9 @@ ##更新履歴 +* 14/04/03 2.0.1 Rev.14 + - 次スレ検索ロジックを追加。次スレ検索キーワードが入力されている場合、現在のスレより新しい、指定のキーワードを含むスレを新スレとして開く。 + * 14/04/03 2.0.1 Rev.13 - 画像をビューアに表示するURL判別が小文字固定になってたので、大文字小文字を無視して判別するよう修正 - 左のレス一覧を隠すオプションボタンを追加 diff --git a/SpeechCast/FormMain.Designer.cs b/SpeechCast/FormMain.Designer.cs index 5769d4c..cf7f5f7 100644 --- a/SpeechCast/FormMain.Designer.cs +++ b/SpeechCast/FormMain.Designer.cs @@ -140,6 +140,8 @@ private void InitializeComponent() this.myToolStripBrowser = new SpeechCast.Controls.MyToolStrip(); this.toolStripLabel6 = new System.Windows.Forms.ToolStripLabel(); this.toolStripButtonListToggle = new System.Windows.Forms.ToolStripButton(); + this.toolStripLabel7 = new System.Windows.Forms.ToolStripLabel(); + this.toolStripTextBoxThreadKeyword = new System.Windows.Forms.ToolStripTextBox(); this.statusStrip1.SuspendLayout(); this.panel1.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).BeginInit(); @@ -988,8 +990,7 @@ private void InitializeComponent() this.toolStripButtonNext, this.toolStripButtonLast, this.toolStripSeparator6, - this.toolStripButtonTurbo, - this.toolStripButtonAutoNextThread}); + this.toolStripButtonTurbo}); this.myToolStripPlay.Location = new System.Drawing.Point(0, 52); this.myToolStripPlay.Name = "myToolStripPlay"; this.myToolStripPlay.Size = new System.Drawing.Size(949, 25); @@ -1213,8 +1214,11 @@ private void InitializeComponent() // this.myToolStripBrowser.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { this.toolStripLabel6, + this.toolStripButtonListToggle, this.toolStripButtonAutoScroll, - this.toolStripButtonListToggle}); + this.toolStripButtonAutoNextThread, + this.toolStripLabel7, + this.toolStripTextBoxThreadKeyword}); this.myToolStripBrowser.Location = new System.Drawing.Point(0, 102); this.myToolStripBrowser.Name = "myToolStripBrowser"; this.myToolStripBrowser.Size = new System.Drawing.Size(949, 25); @@ -1238,6 +1242,17 @@ private void InitializeComponent() this.toolStripButtonListToggle.Text = "レス一覧を非表示"; this.toolStripButtonListToggle.Click += new System.EventHandler(this.toolStripButtonListToggle_Click); // + // toolStripLabel7 + // + this.toolStripLabel7.Name = "toolStripLabel7"; + this.toolStripLabel7.Size = new System.Drawing.Size(104, 22); + this.toolStripLabel7.Text = "次スレキーワード"; + // + // toolStripTextBoxThreadKeyword + // + this.toolStripTextBoxThreadKeyword.Name = "toolStripTextBoxThreadKeyword"; + this.toolStripTextBoxThreadKeyword.Size = new System.Drawing.Size(100, 25); + // // FormMain // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F); @@ -1405,6 +1420,8 @@ private void InitializeComponent() private Controls.MyToolStrip myToolStripBrowser; private System.Windows.Forms.ToolStripLabel toolStripLabel6; private System.Windows.Forms.ToolStripButton toolStripButtonListToggle; + private System.Windows.Forms.ToolStripLabel toolStripLabel7; + private System.Windows.Forms.ToolStripTextBox toolStripTextBoxThreadKeyword; } } diff --git a/SpeechCast/FormMain.cs b/SpeechCast/FormMain.cs index 8ddabfa..c1c4706 100644 --- a/SpeechCast/FormMain.cs +++ b/SpeechCast/FormMain.cs @@ -371,7 +371,8 @@ private async Task GetFromURL(bool next) if (m.Success) { rawURL = m.Groups[1].Value + "/bbs/rawmode.cgi" + m.Groups[2]; - AddLog("jbbs rawmode: {0}", rawURL); + threadId = m.Groups[5].Value; + AddLog("jbbs rawmode: {0} {1}", rawURL, threadId); Response.Style = Response.BBSStyle.jbbs; encodingName = "EUC-JP"; @@ -383,9 +384,10 @@ private async Task GetFromURL(bool next) if (m.Success) { rawURL = m.Groups[1].Value + "/" + m.Groups[2].Value + "/dat/" + m.Groups[3].Value + ".dat"; + threadId = m.Groups[3].Value; Response.Style = Response.BBSStyle.yykakiko; - AddLog("yykakiko dat mode: {0}", rawURL); + AddLog("yykakiko dat mode: {0} {1}", rawURL , threadId); encodingName = "Shift_JIS"; baseURL = string.Format("{0}/{1}/", m.Groups[1], m.Groups[2]); @@ -396,9 +398,10 @@ private async Task GetFromURL(bool next) if (m.Success) { rawURL = m.Groups[1].Value + "/" + m.Groups[2].Value + "/dat/" + m.Groups[3].Value + ".dat"; + threadId = m.Groups[3].Value; Response.Style = Response.BBSStyle.nichan; - AddLog("2ch dat mode: {0}", rawURL); + AddLog("2ch dat mode: {0} {1}", rawURL , threadId); encodingName = "Shift_JIS"; baseURL = string.Format("{0}/{1}/", m.Groups[1], m.Groups[2]); @@ -443,38 +446,37 @@ private async Task GetFromURL(bool next) // Webアクセス部分を非同期化するためTask.Runで囲む await Task.Run(() => { - System.Net.HttpWebRequest webReq = (System.Net.HttpWebRequest)System.Net.WebRequest.Create(url); - webReq.KeepAlive = false; - FormMain.UserConfig.SetProxy(webReq); - - if (UserConfig.GZipCompressionEnabled && useRangeHeader == false) - { - webReq.AutomaticDecompression = System.Net.DecompressionMethods.GZip; - } -#if DEBUG - //AddLog("datSize={0} lastModifiedTime={1} useRangeHeader={2}", - // datSize, lastModifiedDateTime.ToLongTimeString(), useRangeHeader); -#endif - if (useRangeHeader) + try { - webReq.AddRange(datSize - 1); - webReq.IfModifiedSince = lastModifiedDateTime; - } + System.Net.HttpWebRequest webReq = (System.Net.HttpWebRequest)System.Net.WebRequest.Create(url); + webReq.KeepAlive = false; + FormMain.UserConfig.SetProxy(webReq); + + if (UserConfig.GZipCompressionEnabled && useRangeHeader == false) + { + webReq.AutomaticDecompression = System.Net.DecompressionMethods.GZip; + } + if (useRangeHeader) + { + webReq.AddRange(datSize - 1); + webReq.IfModifiedSince = lastModifiedDateTime; + } - gettingWebTime = System.DateTime.Now; //例外が発生した場合、連続してwebアクセスが起こるのを防ぐ + gettingWebTime = System.DateTime.Now; //例外が発生した場合、連続してwebアクセスが起こるのを防ぐ - stopWatch.Start(); - //サーバーからの応答を受信するためのWebResponseを取得 - webReq.Timeout = 10000; - webRes = (System.Net.HttpWebResponse)webReq.GetResponse(); + stopWatch.Start(); + //サーバーからの応答を受信するためのWebResponseを取得 + webReq.Timeout = 10000; + webRes = (System.Net.HttpWebResponse)webReq.GetResponse(); - lastModifiedDateTime = webRes.LastModified; - responseTime = stopWatch.ElapsedMilliseconds; - //if (useRangeHeader) - //{ - // throw (new Exception(" 416 ")); - //} + lastModifiedDateTime = webRes.LastModified; + responseTime = stopWatch.ElapsedMilliseconds; + } + catch (System.Net.WebException e) + { + webReqResult = false; + } });// 非同期処理終了 } catch (System.Net.WebException e) @@ -1295,7 +1297,7 @@ private async void timerWeb_Tick(object sender, EventArgs e) // レス取得の条件判定 if ( - responses.Count <= Response.MaxResponseCount + responses.Count < Response.MaxResponseCount && this.endWebRequest ) { @@ -1368,6 +1370,8 @@ private void FormMain_Load(object sender, EventArgs e) this.splitContainerResCaption.SplitterDistance = 2000; toolStripButtonAutoScroll.Checked = UserConfig.EnableAutoScroll; toolStripButtonListToggle.Checked = !UserConfig.ViewResList; + toolStripTextBoxThreadKeyword.Text = UserConfig.ThreadKeyword; + this.viewResList(UserConfig.ViewResList); } catch (Exception ex) @@ -1439,6 +1443,7 @@ private void FormMain_FormClosing(object sender, FormClosingEventArgs e) UserConfig.SetFormToRect(ref UserConfig.FormMainRect, this); UserConfig.SetFormToRect(ref UserConfig.FormCaptionRect, FormCaption.Instance); UserConfig.URL = toolStripTextBoxURL.Text; + UserConfig.ThreadKeyword = toolStripTextBoxThreadKeyword.Text; UserConfig.Serialize(); Bookmarks.Serialize(); } @@ -1887,6 +1892,7 @@ private void toolStripButtonAutoNextThread_Click(object sender, EventArgs e) // 「現在の条件+現在のスレより後に立てられたスレに絞り込む」 // 「現在のスレより後に立てられたスレが1件のみであれば数字の一致を確認しない」 // 等を想定。そういえばゴミスレはどうすりゃいいんだ・・・ + private string threadId = null; private int openNextThreadUrl(){ // 最初の数字検索用の正規表現オブジェクト System.Text.RegularExpressions.Regex r = @@ -1896,7 +1902,7 @@ private int openNextThreadUrl(){ // スレタイのレス数の削除用正規表現オブジェクト System.Text.RegularExpressions.Regex rTitle = new System.Text.RegularExpressions.Regex( - @"(?\\d+?)\([0-9]+\)", + @"(?<title>\\d+?)\\([0-9]+\\)", System.Text.RegularExpressions.RegexOptions.IgnoreCase); string nextUrl = null; try @@ -1908,7 +1914,7 @@ private int openNextThreadUrl(){ // 現在のスレタイから連番と思われる部分を抽出 System.Text.RegularExpressions.Match m = r.Match(searchTitle); string nextNumber = null; - AddLog(searchTitle); + // AddLog(searchTitle); if (m.Success) { // 取得した数字をインクリメントして文字列として格納 @@ -1953,14 +1959,29 @@ private int openNextThreadUrl(){ // スレタイを取得 parseSubject = s.Replace("<>", ",").Split(','); string searchSubject = zen2han(parseSubject[1]); + string searchThreadid = parseSubject[0].Split('.')[0]; // スレタイの連番部分を取得 System.Text.RegularExpressions.Match m2 = r.Match(searchSubject); - if(m2.Success) + if ( + // 指定キーワードを含む、今スレより当たらしいスレが見つかれば + toolStripTextBoxThreadKeyword.Text.Trim().Length > 0 + && searchSubject.IndexOf(toolStripTextBoxThreadKeyword.Text) >= 0 + && Int32.Parse(threadId) < Int32.Parse(searchThreadid) + ) + { + // 一致データをメンバ変数に入れてループを抜ける + threadId = null; + nextUrl = parseSubject[0]; + threadTitle = parseSubject[1]; + break; + } + if (m2.Success) { // 連番部分が次スレ連番候補と一致したら if (m2.Value == nextNumber) { // 一致データをメンバ変数に入れてループを抜ける + threadId = null; nextUrl = parseSubject[0]; threadTitle = parseSubject[1]; break; @@ -1969,7 +1990,6 @@ private int openNextThreadUrl(){ } } System.Text.RegularExpressions.Match m3 = r.Match(nextUrl); - string threadId = null; if (m3.Success) { //一致した対象が見つかったときキャプチャした部分文字列を表示 @@ -1984,8 +2004,11 @@ private int openNextThreadUrl(){ // スレタイを更新して、フラグを次スレオープン状態に変更 toolStripTextBoxURL.Text = threadUrl; rawURL = null; - - System.Text.RegularExpressions.Match mtitle = r.Match(parseSubject[1]); + responses.Clear(); + oldResCount = 0; + Object[] objArray = new Object[1]; + webBrowser.Document.InvokeScript("clearRes", objArray); + System.Text.RegularExpressions.Match mtitle = rTitle.Match(threadTitle); if (mtitle.Success) threadTitle = mtitle.Groups["title"].Value; return OpenNextThread; } diff --git a/SpeechCast/Properties/AssemblyInfo.cs b/SpeechCast/Properties/AssemblyInfo.cs index a4c7cbe..9cfd235 100644 --- a/SpeechCast/Properties/AssemblyInfo.cs +++ b/SpeechCast/Properties/AssemblyInfo.cs @@ -32,5 +32,5 @@ // すべての値を指定するか、下のように '*' を使ってビルドおよびリビジョン番号を // 既定値にすることができます: // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("2.0.1.13")] -[assembly: AssemblyFileVersion("2.0.1.13")] +[assembly: AssemblyVersion("2.0.1.14")] +[assembly: AssemblyFileVersion("2.0.1.14")] diff --git a/SpeechCast/UseConfig.cs b/SpeechCast/UseConfig.cs index 5a6e1b9..82e6348 100644 --- a/SpeechCast/UseConfig.cs +++ b/SpeechCast/UseConfig.cs @@ -140,8 +140,16 @@ public void SupplementSettings() /// </summary> public int AutoScrollSpeed = 1; + /// <summary> + /// レス一覧の表示非表示フラグ + /// </summary> public bool ViewResList = true; + /// <summary> + /// 自動次スレ検索時のHIT条件キーワード + /// </summary> + public string ThreadKeyword = ""; + /// <summary> /// 読み上げONOFF /// </summary>