Esempio n. 1
0
 /// <summary>
 /// DatのURLをread.cgiのURLに変換します
 /// </summary>
 /// <param name="datUrl">datのURL</param>
 /// <param name="bt">板の帰属元</param>
 /// <returns>read.cgi形式のURL</returns>
 static public string DatToReadcgi(string datUrl, BBSType bt)
 {
     if (bt == BBSType._2ch)
     {
         Match m = new Regex(@"http://(?<host>.+)/(?<folder>.+)/dat/(?<key>\d{9,10})/?", RegexOptions.Compiled).Match(datUrl);
         if (m.Success)
         {
             return("http://" + m.Groups["host"].Value + "/test/read.cgi/" + m.Groups["folder"].Value + "/" + m.Groups["key"].Value + "/");
         }
         else
         {
             throw new ArgumentException();
         }
     }
     else if (bt == BBSType.jbbs)
     {
         Match m = new Regex(@"http://jbbs.(shitaraba.net|livedoor.jp)/bbs/rawmode.cgi/(?<category>\w+)/(?<number>\d+)/(?<key>\d{9,10})/?", RegexOptions.Compiled).Match(datUrl);
         if (m.Success)
         {
             return("http://jbbs.shitaraba.net/bbs/read.cgi/" + m.Groups["category"].Value + "/" + m.Groups["number"].Value + "/" + m.Groups["key"].Value + "/");
         }
         else
         {
             throw new ArgumentException();
         }
     }
     else if (bt == BBSType.machibbs)
     {
         Match m = Regex.Match(datUrl, @"http://(?<host>\w+)[.]machi[.]to/bbs/offlaw.cgi/(?<folder>\w+)/(?<key>\d{9,10})/?", RegexOptions.Compiled);
         if (m.Success)
         {
             return("http://" + m.Groups["host"].Value + ".machi.to/bbs/read.cgi/" + m.Groups["folder"].Value + "/" + m.Groups["key"].Value + "/");
         }
         else
         {
             var sm = Regex.Match(datUrl, @"http://(?<host>\w+)[.]machi[.]to/(?<folder>\w+)/dat/(?<key>\d{9,10})[.]dat", RegexOptions.Compiled);
             if (sm.Success)
             {
                 return("http://" + sm.Groups["host"].Value + ".machi.to/bbs/read.cgi/" + sm.Groups["folder"].Value + "/" + sm.Groups["key"].Value + "/");
             }
             throw new ArgumentException();
         }
     }
     else
     {
         throw new ArgumentException();
     }
 }
Esempio n. 2
0
 /// <summary>
 /// DatのURLをbbs.cgiとその他bbs.cgiに送信するデータに変換します
 /// </summary>
 /// <param name="datUrl">datのURL</param>
 /// <param name="bt">板の帰属元</param>
 /// <param name="t">スレッドか新規スレか</param>
 /// <param name="key">抽出したスレッドキー</param>
 /// <param name="folder">抽出したフォルダー</param>
 /// <returns>bbs.cgiのアドレス</returns>
 static public string DatToBBScgi(string datUrl, BBSType bt, Type t, out string key, out string folder)
 {
     if (bt == BBSType._2ch)
     {
         if (Type.thread == t)
         {
             Match m = new Regex(@"http://(?<host>.+)/(?<folder>.+)/dat/(?<key>\d{9,10})[.]dat", RegexOptions.Compiled).Match(datUrl);
             key    = m.Groups["key"].Value;
             folder = m.Groups["folder"].Value;
             return("http://" + m.Groups["host"].Value + "/test/bbs.cgi");
         }
         else
         {
             Match m = new Regex(@"http://(?<host>.+)/(?<folder>.+)/", RegexOptions.Compiled).Match(datUrl);
             key    = String.Empty;
             folder = m.Groups["folder"].Value;
             return("http://" + m.Groups["host"].Value + "/test/bbs.cgi");
         }
     }
     else if (bt == BBSType.jbbs)
     {
         if (t == Type.thread)
         {
             //http://jbbs.livedoor.jp/bbs/rawmode.cgi/news/5720/1222345678/
             Match m = Regex.Match(datUrl, @"http://jbbs([.]shitaraba.net|[.]livedoor[.]jp)/bbs/rawmode[.]cgi/(?<category>\w+)/(?<folder>\d+)/(?<key>\d{9,10})/?", RegexOptions.Compiled);
             key    = m.Groups["key"].Value;
             folder = m.Groups["category"].Value + "/" + m.Groups["folder"].Value;
             return("http://jbbs.shitaraba.net/bbs/write.cgi");
         }
         else
         {
             //http://jbbs.livedoor.jp/news/5720/
             Match m = Regex.Match(datUrl, @"http://jbbs.(shitaraba.net|livedoor.jp)/(?<category>\w+)/(?<folder>\d+)/?", RegexOptions.Compiled);
             key    = String.Empty;
             folder = m.Groups["category"].Value + "/" + m.Groups["folder"].Value;
             return("");
         }
     }
     else
     {
         throw new NotSupportedException();
     }
 }
Esempio n. 3
0
 /// <summary>
 /// dat形式のURLを板のアドレスに変換します
 /// </summary>
 /// <param name="datUrl">datのURL</param>
 /// <param name="bt">板の帰属元</param>
 /// <returns>板のアドレス</returns>
 static public string DatToFolder(string datUrl, BBSType bt)
 {
     if (bt == BBSType._2ch)
     {
         return(Regex.Replace(datUrl, @"dat/\d{9,10}[.]dat", "", RegexOptions.Compiled));
     }
     else if (bt == BBSType.jbbs)
     {
         //http://jbbs.livedoor.jp/news/5720
         //http://jbbs.livedoor.jp/bbs/rawmode.cgi/news/5720/**********/
         Match m = Regex.Match(datUrl, "http://jbbs.(shitaraba.net|livedoor.jp)/bbs/rawmode.cgi/(?<category>.+)/(?<folder>.+)/", RegexOptions.Compiled);
         return("http://jbbs.shitaraba.net/" + m.Groups["category"].Value + "/" + m.Groups["folder"].Value + "/");
     }
     else
     {
         //http://kinki.machi.to/osaka/
         //http://kinki.machi.to/bbs/offlaw.cgi/osaka/*****************/
         Match m = Regex.Match(datUrl, @"http://(?<host>\w+)[.]machi[.]to/bbs/offlaw.cgi/(?<folder>\w+)/", RegexOptions.Compiled);
         return("http://" + m.Groups["host"] + ".machi.to/" + m.Groups["folder"].Value + "/");
     }
 }
Esempio n. 4
0
 /// <summary>
 /// read.cgi形式のURLをdat形式のURLに変換します
 /// </summary>
 /// <param name="readUrl">read.cgiのURL</param>
 /// <param name="bt">板の帰属元</param>
 /// <returns>dat形式のURL</returns>
 static public string ReadcgiToDat(string readUrl, BBSType bt)
 {
     if (bt == BBSType._2ch)
     {
         Match m = new Regex(@"http://(?<host>.+)/test/read.cgi/(?<folder>.+)/(?<key>\d{9,10})/?", RegexOptions.Compiled).Match(readUrl);
         return(String.Concat("http://", m.Groups["host"].Value, "/", m.Groups["folder"].Value, "/dat/", m.Groups["key"].Value, ".dat"));
     }
     else if (bt == BBSType.jbbs)
     {
         Match m = Regex.Match(readUrl, @"http://jbbs.(shitaraba.net|livedoor.jp)/bbs/read.cgi/(?<category>\w+)/(?<folder>\d+)/(?<key>\d{9,10})/?", RegexOptions.Compiled);
         return("http://jbbs.shitaraba.net/bbs/rawmode.cgi/" + m.Groups["category"].Value + "/" + m.Groups["folder"].Value + "/" + m.Groups["key"].Value + "/");
     }
     else if (bt == BBSType.machibbs)
     {
         // もしかしてString.Replaceでおk?まちBBS関連すべて
         //Match m = Regex.Match(readUrl, @"http://(?<host>\w+)[.]machi[.]to/bbs/offlaw.cgi/", RegexOptions.Compiled);
         return(readUrl.Replace("read.cgi", "offlaw.cgi"));
     }
     else
     {
         throw new NotSupportedException();
     }
 }
Esempio n. 5
0
        /// <summary>
        /// 指定したURLの形式を表示します
        /// </summary>
        /// <param name="url">形式を表すURL</param>
        /// <returns>指定されたURLの形式</returns>
        public static Type TypeJudg(string url)
        {
            BBSType bt = BBSTypeJudg(url);

            if (bt == BBSType._2ch)
            {
                if (new Regex(@"http://.+/test/read[.]cgi/.+/(\d{9,10}/.*|\d{9,10})", RegexOptions.Compiled).IsMatch(url) || new Regex(@"http://.+/.+/dat/\d{9,10}[.]dat", RegexOptions.Compiled).IsMatch(url))
                {
                    return(Type.thread);
                }
                else
                {
                    return(Type.threadlist);
                }
            }
            else if (bt == BBSType.jbbs)
            {
                if (new Regex(@"http://jbbs.(shitaraba.net|livedoor[.]jp)/bbs/read[.]cgi/.+/\d+/(\d{9,10}/.*|\d{9,10})", RegexOptions.Compiled).IsMatch(url) || Regex.IsMatch(url, @"http://jbbs.(livedoor.jp|shitaraba.net)/bbs/rawmode.cgi/\w+/\d+/\d{9,10}/?", RegexOptions.Compiled))
                {
                    return(Type.thread);
                }
                else
                {
                    return(Type.threadlist);
                }
            }
            else
            if (new Regex(@"http://.+[.]machi[.]to/bbs/read[.]cgi/.+/(\d{9,10}/.*|\d{9,10})", RegexOptions.Compiled).IsMatch(url))
            {
                return(Type.thread);
            }
            else
            {
                return(Type.threadlist);
            }
        }
Esempio n. 6
0
 /// <summary>
 /// 指定したURLの形式を表示します
 /// </summary>
 /// <param name="url">形式を示すためのURL</param>
 /// <param name="bt">指定されたURLの板の帰属元</param>
 /// <param name="t">指定されたURLの形式</param>
 public static void AllJudg(string url, out BBSType bt, out Type t)
 {
     Setting.GeneralSetting gs = new Setting.GeneralSetting();
     if (url.Contains(gs.DatFilePath))
     {
         t = Type.thread;
         if (url.Contains("machi.to-"))
         {
             bt = BBSType.machibbs;
         }
         else if (url.Contains("jbbs-"))
         {
             bt = BBSType.jbbs;
         }
         else
         {
             bt = BBSType._2ch;
         }
         return;
     }
     if (url.IndexOf("2ch.net") != -1 || url.IndexOf("bbspink.com") != -1)
     {
         bt = BBSType._2ch;
     }
     else
     {
         if (url.IndexOf("jbbs.livedoor.jp") != -1 || url.IndexOf("jbbs.shitaraba.net") != -1)
         {
             bt = BBSType.jbbs;
         }
         else if (url.IndexOf("machi.to") != -1)
         {
             bt = BBSType.machibbs;
         }
         else
         {
             bt = BBSType._2ch;
         }
     }
     if (bt == BBSType._2ch)
     {
         if (new Regex(@"http://.+/test/read[.]cgi/.+/(\d{9,10}/.*|\d{9,10})", RegexOptions.Compiled).IsMatch(url) || new Regex(@"http://.+/.+/dat/\d{9,10}[.]dat", RegexOptions.Compiled).IsMatch(url))
         {
             t = Type.thread;
         }
         else
         {
             t = Type.threadlist;
         }
     }
     else if (bt == BBSType.jbbs)
     {
         if (new Regex(@"http://jbbs([.]shitaraba.net|[.]livedoor[.]jp)/bbs/read[.]cgi/.+/\d+/(\d{9,10}/.*|\d{9,10})", RegexOptions.Compiled).IsMatch(url) || Regex.IsMatch(url, @"http://jbbs.(livedoor.jp|shitaraba.net)/bbs/rawmode.cgi/\w+/\d+/\d{9,10}/?", RegexOptions.Compiled))
         {
             t = Type.thread;
         }
         else
         {
             t = Type.threadlist;
         }
     }
     else
     {
         if (new Regex(@"http://.+[.]machi[.]to/bbs/(read|offlaw)[.]cgi/.+/(\d{9,10}/.*|\d{9,10})", RegexOptions.Compiled).IsMatch(url))
         {
             t = Type.thread;
         }
         else
         {
             t = Type.threadlist;
         }
     }
 }