OSDN Git Service

過去ログにあるのを取り込めるようにした。
[gikonavigoeson/gikonavi.git] / res / ExternalBoardPlugIn / ShitarabaJBBSPlugIn.dpr
index 6ead5d5..c1c1445 100644 (file)
@@ -3,7 +3,7 @@ library ShitarabaJBBSPlugIn;
 {
        ShitarabaJBBSPlugIn
        \82µ\82½\82ç\82Î\8f\88\97\9d\83\86\83j\83b\83g
-       $Id: ShitarabaJBBSPlugIn.dpr,v 1.22 2004/04/12 15:47:22 h677 Exp $
+       $Id: ShitarabaJBBSPlugIn.dpr,v 1.23 2004/07/07 13:35:01 h677 Exp $
 }
 
 uses
@@ -33,6 +33,7 @@ type
 
        private
                function        Download : TDownloadState;
+               function        StorageDownload(Path, Document : string) : TDownloadState;
                function        Write( inName : string; inMail : string; inMessage : string ) : TDownloadState;
                function        GetRes( inNo : Integer ) : string;
                function        GetDat( inNo : Integer ) : string;
@@ -287,16 +288,20 @@ begin
                uri                     := TIdURI.Create( inURL );
                uriList := TStringList.Create;
                try
-                       ExtractHttpFields( ['/'], [], uri.Path, uriList );
+                       ExtractHttpFields( ['/'], [], uri.Path, uriList );
                        foundPos := AnsiPos( BBS_HOST, uri.Host );
                        if (foundPos > 0) and (Length( uri.Host ) - foundPos + 1 = Length( BBS_HOST )) then begin
-                               foundPos := ANsiPos( THREAD_MARK, inURL );
+                               foundPos := AnsiPos( THREAD_MARK, inURL );
+
                                if foundPos > 0 then
                                        Result := atThread
+                               else if (uriList.Count > 2) and (AnsiPos('.html', uri.Document) > 0) then
+                                       Result := atThread
                                else if uriList.Count > 2 then  // \8dÅ\8cã\82ª '/' \82Å\95Â\82ß\82ç\82ê\82Ä\82é\82È\82ç 4
                                        Result := atBoard
                                else
                                        Result := atBBS;
+
                        end else begin
                                Result := atNoAccept;
                        end;
@@ -489,9 +494,23 @@ begin
        uriList := TStringList.Create;
        try
                ExtractHttpFields( ['/', '?'], [], uri.Path, uriList );
-               FileName        := uriList[ 5 ] + '.dat';
-               FilePath        := MyLogFolder + uriList[ 3 ] + '\' + uriList[ 4 ] + '\' + uriList[ 5 ] + '.dat';
-               IsLogFile       := FileExists( FilePath );
+               if (AnsiPos('.html', uri.Document) = 0) then begin //\92Ê\8fí
+                       if uriList[ 5 ] = 'l100' then begin
+                               FileName        := uriList[ 4 ] + '.dat';
+                               FilePath        := MyLogFolder + uriList[ 2 ] + '\' + uriList[ 3 ] + '\' + uriList[ 4 ] + '.dat';
+                               IsLogFile       := FileExists( FilePath );
+                       end else begin
+                               FileName        := uriList[ 5 ] + '.dat';
+                               FilePath        := MyLogFolder + uriList[ 3 ] + '\' + uriList[ 4 ] + '\' + uriList[ 5 ] + '.dat';
+                               IsLogFile       := FileExists( FilePath );
+                       end;
+               end else begin  //\89ß\8b\8e\83\8d\83O
+                       //http://jbbs.shitaraba.com/game/1578/storage/1086710948.html
+                       FileName        := Copy(uri.Document, 1, Length(uri.Document) - 5) + '.dat';
+                       FilePath        := MyLogFolder + CustomStringReplace(CustomStringReplace(uri.Path, '/storage', ''), '/', '\') + FileName;
+                       IsLogFile       := FileExists( FilePath );
+
+               end;
        finally
                uri.Free;
                uriList.Free;
@@ -534,41 +553,361 @@ begin
        Result := dsError;
 
        uri := TIdURI.Create( ReadURL );
-       uriList := TStringList.Create;
+       if(( AnsiPos('.html', uri.Document) >0 ) and ( AnsiPos('/storage/', uri.Path) > 0 )) then begin
+               //\89ß\8b\8e\83\8d\83O
+               Result := StorageDownload(uri.Path, uri.Document);
+               uri.Free;
+       end else begin
+               //\8c»\8dÝ\90\82«\82Ä\82é\83X\83\8c\83b\83h
+               uriList := TStringList.Create;
+               try
+                       ExtractHttpFields( ['/', '?'], [], uri.Path, uriList );
+                       FileName := uriList[ 5 ] + '.dat';
+                       // http://jbbs.shitaraba.com/bbs/rawmode.cgi/game/1578/1067968274/l100
+                       // protocol://host/1/2/3/4/5/uriList.Count - 1
+                       if MyLogFolder = '' then begin
+                               // \82Ç\82±\82É\95Û\91\82µ\82Ä\82¢\82¢\82Ì\82©\95ª\82©\82ç\82È\82¢\82Ì\82Å\88ê\8e\9e\83t\83@\83C\83\8b\82É\95Û\91
+                               FilePath                        := TemporaryFile;
+                               FIsTemporary    := True;
+                       end else begin
+                               FilePath                        := MyLogFolder + uriList[ 3 ] + '\' + uriList[ 4 ] + '\' + uriList[ 5 ] + '.dat';
+                               FIsTemporary    := False;
+                       end;
+               finally
+                       uri.Free;
+                       uriList.Free;
+               end;
+
+               // \95Û\91\97p\82Ì\83f\83B\83\8c\83N\83g\83\8a\82ð\8c@\82é
+               ForceDirectoriesEx( Copy( FilePath, 1, LastDelimiter( '\', FilePath ) ) );
+
+               // \93Æ\8e©\82É\83_\83E\83\93\83\8d\81[\83h\82â\83t\83B\83\8b\83^\83\8a\83\93\83O\82ð\8ds\82í\82È\82¢\8fê\8d\87\82Í
+               // InternalDownload \82É\94C\82¹\82é\82±\82Æ\82ª\8fo\97\88\82é
+               modified        := LastModified;
+               datURL          := ReadURL + IntToStr( Count + 1 ) + '-'; // \90V\92\85\82Ì\82Ý
+               responseCode := InternalDownload( PChar( datURL ), modified, tmp, 0 );
+
+               try
+                       if (responseCode = 200) or (responseCode = 206) then begin
+                               downResult := TStringList.Create;
+                               try
+                                                                       tmpText := CustomStringReplace( string( tmp ), '¡÷¡®', ',' );
+                                       downResult.Text := EUCtoSJIS( tmpText );
+                                                                       ArrangeDownloadData(Count, downResult);
+                                       if downResult.Count > 0 then begin
+                                               if FileExists( FilePath ) then
+                                                       logStream := TFileStream.Create( FilePath, fmOpenReadWrite or fmShareDenyWrite )
+                                               else
+                                                       logStream := TFileStream.Create( FilePath, fmCreate or fmShareDenyWrite );
+                                               try
+                                                       logStream.Position      := logStream.Size;
+                                                       logStream.Write( PChar( downResult.Text )^, Length( downResult.Text ) );
+                                               finally
+                                                       logStream.Free;
+                                               end;
+
+                                               if Count = 0 then
+                                                                                               // \90V\8bK
+                                                       Result := dsComplete
+                                               else
+                                                       // \92Ç\8bL
+                                                       Result := dsDiffComplete;
+
+                                                                                       Size                                    := Size + Length( downResult.Text );
+                                               // CGI \82©\82ç\82Í\90³\82µ\82¢\93ú\95t\82ª\93¾\82ç\82ê\82È\82¢\82Ì\82Å\8c»\8dÝ\82É\90Ý\92è
+                                               LastModified    := Now;
+
+
+
+                                               NewReceive              := Count + 1;
+                                               Count                                   := Count + downResult.Count;
+                                               NewResCount             := downResult.Count;
+
+
+
+                                       end else begin
+                                               Result := dsNotModify;
+                                       end;
+                               finally
+                                       downResult.Free;
+                               end;
+                       end else if responseCode = 304 then begin
+                               Result := dsNotModify;
+                       end;
+               finally
+                       DisposeResultString( tmp );
+               end;
+       end;
+
+end;
+// *************************************************************************
+// download\82µ\82Ä\82«\82½Dat\82Ì\82 \82Ú\81[\82ñ\82³\82ê\82½\95ª\82ð\95â\8f[\82µ\82Ä\81A
+// \83\8c\83X\90\94\82Æ\88ê\92v\82·\82é\82æ\82¤\82É\82·\82é
+// *************************************************************************
+procedure      TShitarabaThreadItem.ArrangeDownloadData(
+       start: Integer; // \90V\8bK\81F\82O\81@\92Ç\8bL\81F\91O\89ñ\82Ü\82Å\82Ì\8eæ\93¾\90\94
+               var Data: TStringList   //Dat\82Ì\83f\81[\83^
+);
+var
+       i: Integer;
+               n: Integer;
+               tmp: string;
+begin
+       i := start;
+               while i < Data.count + start do begin
+                       try
+                                       tmp := Copy(Data[i - start], 1 , AnsiPos('<>', Data[ i - start ] )-1 );
+                                               try
+                                                       n := StrToInt(tmp);
+                                                               if n > i + 1 then begin
+                                                                       Data.Insert(i - start, Format('%d<><><><><><>', [i+1]));
+                                                               end;
+                                                               Inc(i);
+                                               except
+                                                       Inc(i);
+                       end;
+                               except
+
+                               end;
+               end;
+
+end;
+// *************************************************************************
+// \89ß\8b\8e\83\8d\83O\97pDownload\8aÖ\90\94
+// *************************************************************************
+function       TShitarabaThreadItem.StorageDownload(
+       Path, Document : string
+) : TDownloadState;
+var
+       modified                        : Double;
+       tmp                                             : PChar;
+       downResult              : TStringList;
+       responseCode    : Longint;
+       logStream                       : TFileStream;
+       //uri                                           : TIdURI;
+       //uriList                               : TStringList;
+       datURL                          : string;
+       tmpText, tmpLine, tmpTitle: string;
+       tmpHTML: TStringList;
+
+       i, j, tS, tE: Integer;
+       tmpDatToken : array[0..6] of string;
+begin
+
+       Result := dsError;
+
+       //uri := TIdURI.Create( ReadURL );
        try
-               ExtractHttpFields( ['/', '?'], [], uri.Path, uriList );
-               FileName := uriList[ 5 ] + '.dat';
-               // http://jbbs.shitaraba.com/bbs/rawmode.cgi/game/1578/1067968274/l100
-               // protocol://host/1/2/3/4/5/uriList.Count - 1
+               FileName := Copy(Document, 1, Length(Document) - 5) + '.dat';
                if MyLogFolder = '' then begin
                        // \82Ç\82±\82É\95Û\91\82µ\82Ä\82¢\82¢\82Ì\82©\95ª\82©\82ç\82È\82¢\82Ì\82Å\88ê\8e\9e\83t\83@\83C\83\8b\82É\95Û\91
                        FilePath                        := TemporaryFile;
                        FIsTemporary    := True;
                end else begin
-                       FilePath                        := MyLogFolder + uriList[ 3 ] + '\' + uriList[ 4 ] + '\' + uriList[ 5 ] + '.dat';
+                       FilePath        := MyLogFolder
+                                                       + CustomStringReplace(CustomStringReplace(Path, '/storage', ''), '/', '\')
+                                                       + FileName;
+
                        FIsTemporary    := False;
                end;
        finally
-               uri.Free;
-               uriList.Free;
+               //uri.Free;
        end;
 
        // \95Û\91\97p\82Ì\83f\83B\83\8c\83N\83g\83\8a\82ð\8c@\82é
        ForceDirectoriesEx( Copy( FilePath, 1, LastDelimiter( '\', FilePath ) ) );
 
+
+
        // \93Æ\8e©\82É\83_\83E\83\93\83\8d\81[\83h\82â\83t\83B\83\8b\83^\83\8a\83\93\83O\82ð\8ds\82í\82È\82¢\8fê\8d\87\82Í
        // InternalDownload \82É\94C\82¹\82é\82±\82Æ\82ª\8fo\97\88\82é
        modified        := LastModified;
-       datURL          := ReadURL + IntToStr( Count + 1 ) + '-'; // \90V\92\85\82Ì\82Ý
+
+       datURL          := ReadURL;
        responseCode := InternalDownload( PChar( datURL ), modified, tmp, 0 );
 
        try
                if (responseCode = 200) or (responseCode = 206) then begin
                        downResult := TStringList.Create;
                        try
-                                                               tmpText := CustomStringReplace( string( tmp ), '¡÷¡®', ',' );
-                               downResult.Text := EUCtoSJIS( tmpText );
-                                                               ArrangeDownloadData(Count, downResult);
+                               tmpText := CustomStringReplace( string( tmp ), '¡÷¡®', ',' );
+
+
+
+                               //**\82±\82±\82ÅHTML\83t\83@\83C\83\8b\82ð\82µ\82½\82ç\82ÎJBBS\82Ìdat\8c`\8e®\82É\95Ï\8a·\82·\82é
+                               tmpHTML := TStringList.Create;
+
+                               try
+                                       tmpHTML.Text := EUCtoSJIS( tmpText );
+                                       //Title\82Ì\8eæ\93¾
+                                       for i := 0 to tmpHTML.Count - 1 do begin
+                                               tmpLine := AnsiLowerCase(tmpHTML[i]);
+                                               tS := AnsiPos('<title>', tmpLine);
+                                               tE := AnsiPos('</title>', tmpLine);
+
+                                               if tS > 0 then begin
+                                                       if tE - tS  = 1 then begin
+                                                               tmpTitle := '';
+                                                       end else begin
+                                                               tmpTitle := Copy(tmpHTML[i], ts + 7, Length(tmpHTML[i]));
+                                                               tmpLine := AnsiLowerCase(tmpTitle);
+                                                               tE := AnsiPos('</title>', tmpLine);
+
+                                                               if tE > 0 then begin
+                                                                       tmpTitle := Copy(tmpTitle, 1, tE - 1);
+                                                               end else begin
+                                                                       j := i + 1;
+                                                                       tmpLine := AnsiLowerCase(tmpHTML[j]);
+                                                                       tE := AnsiPos('</title>', tmpLine);
+                                                                       tmpTitle := tmpTitle  + tmpHTML[j];
+                                                                       while( tE = 0 ) do begin
+                                                                               j := i + 1;
+                                                                               if j = tmpHTML.Count then break;
+                                                                               tmpLine := AnsiLowerCase(tmpHTML[j]);
+                                                                               tE := AnsiPos('</title>', tmpLine);
+                                                                               tmpTitle := tmpTitle  + tmpHTML[j];
+                                                                       end;
+                                                                       if tE = 0 then tmpTitle := ''
+                                                                       else begin
+                                                                               tmpLine := AnsiLowerCase(tmpTitle);
+                                                                               tE := AnsiPos('</title>', tmpLine);
+                                                                               tmpTitle := Copy(tmpTitle, 1, tE - 1);
+                                                                       end;
+                                                               end;
+                                                       end;
+                                               end;
+                                       end;
+                                       //Title := tmpTitle;
+                                       tS := 0; tE := 0;
+                                       //\96{\95\82Ì\8eæ\93¾ <DL>\82Ì\8e\9f\82Ì\8ds\82©\82ç</DL>\82Ì\91O\82Ì\8ds\82Ü\82Å
+                                       for i := tmpHTML.Count - 1 downto 0 do begin
+                                               tmpLine := AnsiLowerCase(tmpHTML[i]);
+                                               tE := AnsiPos('</dl>', tmpLine);
+                                               if tE > 0 then begin
+                            tmpHTML[i] := COpy(tmpHTML[i], 1, tE -1);
+                                                       break;
+                                               end;
+                                               tmpHTML.Delete(i);
+                                       end;
+                    j := 0;
+                                       for i := 0 to tmpHTML.Count - 1 do begin
+                                               tmpLine := AnsiLowerCase(tmpHTML[i]);
+                                               tS := AnsiPos('<dl>', tmpLine);
+                                               if tS > 0 then begin
+                                                       j := i + 1;
+                                                       break;
+                                               end;
+                                       end;
+                                       for i := j downto 0 do
+                                               tmpHTML.Delete(i);
+
+                                       //<DD><DT>\82»\82ê\82¼\82ê\88ê\8ds\82É\95Ï\8a·\82·\82é
+                                       for i := tmpHTML.Count - 1 downto 1 do begin
+                                               tmpLine := AnsiLowerCase(tmpHTML[i]);
+                                               if (AnsiPos('<dd>', tmpLine) = 0) and (AnsiPos('<dt>', tmpLine) = 0) then begin
+                                                       tmpLine := CustomStringReplace(tmpHTML[i-1], #13#10, '') +
+                                                                                       CustomStringReplace(tmpHTML[i], #13#10, '');
+                                                       tmpHTML.Insert(i-1, tmpLine);
+                                                       tmpHTML.Delete(i + 1);
+                                                       tmpHTML.Delete(i);
+                                               end;
+                                       end;
+                                       //\8fã\82Ü\82Å\82Ì\8f\88\97\9d\82Å\88È\89º\82Ì\82æ\82¤\82È\8c`\82É\82È\82Á\82Ä\82é
+                                       //<dt><a name="958">958 </a> \96¼\91O\81F<font color="#008800"><b> \96¼\82à\96³\82«\8cR\8et </b></font> \93\8a\8de\93ú\81F 2004/06/30(\90\85) 15:17 [ r1FsjJhA ]<br><dd>\81`\81`
+                                       //<dt><a name="951">951 </a> \96¼\91O\81F<a href="mailto:sage"><b> \96¼\82à\96³\82«\8cR\8et </B></a> \93\8a\8de\93ú\81F 2004/06/30(\90\85) 12:31 [ .oGr0rtc ]<br><dd>\81`\81`
+                                       //\8fã\82Ì\82æ\82¤\82È\82Ì\82ð\89º\82Ì\82æ\82¤\82Èdat\82Ì\8c`\8e®\82É\95Ï\8a·\82·\82é
+                                       //\83\8c\83X\94Ô\8d\86<><font color=#FF0000>HN</font><>\83\81\83\8b\97\93<>\93ú\95t\8e\9e\8d\8f<>\96{\95¶<>\83^\83C\83g\83\8b\81i\82P\82Ì\82Ý\81j<>ID
+                                       //2<>\96¼\82à\96³\82«\8cR\8et<>sage<>2004/06/22(\89Î) 09:05<>\82Q\82°\82Æ\81[<><>26bmLAzg
+                                       for i := 0 to tmpHTML.Count - 1 do begin
+                                               tmpDatToken[0] := ''; tmpDatToken[1] := ''; tmpDatToken[2] := '';
+                                               tmpDatToken[3] := ''; tmpDatToken[4] := ''; tmpDatToken[6] := '';
+                                               //==\82Ü\82¸\82Í\96{\95\82ð\8eæ\93¾==//
+                                               tmpLine := AnsiLowerCase(tmpHTML[i]);
+                                               tS := AnsiPos('<dd>', tmpLine);
+                                               if tS > 0 then begin
+                                                       tmpDatToken[4] := Copy(tmpHTML[i], tS + 4, Length(tmpHTML[i]));
+                                                       tmpHTML[i] := Copy(tmpHTML[i], 1, tS -1);
+                                               end else
+                                                       tmpDatToken[4] := '';
+                                               //====================//
+                                               //==\83\8c\83X\94Ô\8d\86\8eæ\93¾==//
+                                               tmpLine := AnsiLowerCase(tmpHTML[i]);
+                                               tS := AnsiPos('">', tmpLine);
+                                               tE := AnsiPos('</a>', tmpLine);
+                                               if tE > tS then begin
+                                                       tmpDatToken[0] := Copy(tmpHTML[i], tS + 2, tE - (tS + 2) - 1);
+                                                       tmpDatToken[0] := Trim(tmpDatToken[0]);
+                                                       tmpHTML[i] := Copy(tmpHTML[i], tE + 4, Length(tmpHTML[i]));
+                                               end else
+                                                       tmpDatToken[0] := IntToStr(i);
+                                               tS := AnsiPos('<', tmpHTML[i]);
+                                               if tS > 0 then begin
+                                                       tmpHTML[i] := Copy(tmpHTML[i], tS, Length(tmpHTML[i]));
+                                               end;
+                                               //====================//
+                                               //==\83\81\83\8b\97\93\8eæ\93¾==//
+                                               tmpLine := AnsiLowerCase(tmpHTML[i]);
+                                               tS := AnsiPos('<a href="mailto:', tmpLine);
+                                               if tS > 0 then begin //\83\81\83\8b\97\93\83A\83\8a
+                                                       tE := AnsiPos('">', tmpLine);
+                                                       tmpDatToken[2] := Copy(tmpHTML[i], tS + 16, tE - (tS + 16));
+                                                       tmpHTML[i] := Copy(tmpHTML[i], tE + 5, Length(tmpHTML[i]));
+                            tmpHTML[i] := CustomStringReplace(tmpHTML[i], '</a>', '', true);
+                                               end else begin  //\83\81\83\8b\97\93\96³\82µ
+                                                       tmpDatToken[2] := '';
+                                               end;
+                                               //====================//
+                                               //==HN\8eæ\93¾==//
+                                               tmpLine := AnsiLowerCase(tmpHTML[i]);
+                                               tE := AnsiPos('\93\8a\8de\93ú\81F', tmpLine);
+                                               if tE > 0 then begin
+                                                       tmpDatToken[1] := Trim(Copy(tmpHTML[i], 1, tE - 1 ));
+                                                       tmpDatToken[1] := CustomStringReplace(tmpDatToken[1], '<b>', '', true);
+                                                       tmpDatToken[1] := CustomStringReplace(tmpDatToken[1], '</b>', '', true);
+                                                       tmpHTML[i] := Copy(tmpHTML[i], tE + 8, Length(tmpHTML[i]));
+                                               end else begin
+                                                       tmpDatToken[1] := '';
+                                               end;
+                                               //====================//
+                                               //==\93ú\95t\8e\9e\8d\8f\82Ì\8eæ\93¾==//
+                                               tmpLine := AnsiLowerCase(tmpHTML[i]);
+                                               tE := AnsiPos('[', tmpLine);
+                                               if tE > 0 then begin
+                                                       tmpDatToken[3] := Trim(Copy(tmpHTML[i], 1, tE - 1 ));
+                                                       tmpHTML[i] := Copy(tmpHTML[i], tE + 1, Length(tmpHTML[i]));
+                                               end else begin
+                                                       tmpDatToken[3] := '';
+                                               end;
+                                               //====================//
+                                               //==ID\82Ì\8eæ\93¾==//
+                                               tmpLine := AnsiLowerCase(tmpHTML[i]);
+                                               tE := AnsiPos(']', tmpLine);
+                                               if tE > 0 then begin
+                                                       tmpDatToken[6] := Trim(Copy(tmpHTML[i], 1, tE - 1 ));
+                                               end else begin
+                                                       tmpDatToken[6] := '';
+                                               end;
+                                               //====================//
+                                               tS := StrToIntDef(tmpDatToken[0], -1);
+                                               if  tS = 1      then
+                                                       tmpLine := tmpDatToken[0] + '<>' + tmpDatToken[1] + '<>' + tmpDatToken[2] + '<>' +
+                                                                       tmpDatToken[3] + '<>' + tmpDatToken[4] + '<>' + tmpTitle + '<>' + tmpDatToken[6]
+                                               else
+                                                       tmpLine := tmpDatToken[0] + '<>' + tmpDatToken[1] + '<>' +tmpDatToken[2] + '<>' +
+                                                                       tmpDatToken[3] + '<>' + tmpDatToken[4] + '<><>' + tmpDatToken[6];
+                                               tmpHTML[i] := tmpLine;
+                                       end;
+
+
+
+
+                                       downResult.Text := tmpHTML.Text;
+                               finally
+                                       tmpHTML.free;
+                               end;
+
+                               ArrangeDownloadData(Count, downResult);
+
                                if downResult.Count > 0 then begin
                                        if FileExists( FilePath ) then
                                                logStream := TFileStream.Create( FilePath, fmOpenReadWrite or fmShareDenyWrite )
@@ -588,7 +927,7 @@ begin
                                                // \92Ç\8bL
                                                Result := dsDiffComplete;
 
-                                                                               Size                                    := Size + Length( downResult.Text );
+                                       Size    := Size + Length( downResult.Text );
                                        // CGI \82©\82ç\82Í\90³\82µ\82¢\93ú\95t\82ª\93¾\82ç\82ê\82È\82¢\82Ì\82Å\8c»\8dÝ\82É\90Ý\92è
                                        LastModified    := Now;
 
@@ -597,9 +936,12 @@ begin
                                        NewReceive              := Count + 1;
                                        Count                                   := Count + downResult.Count;
                                        NewResCount             := downResult.Count;
-
-
-
+                                       //http://jbbs.shitaraba.com/bbs/read.cgi/game/1578/1086710948/l100
+                                       //http://jbbs.shitaraba.com/game/1578/storage/1086710948.html
+                                       //URL := 'http://jbbs.shitaraba.com/bbs/read.cgi' +
+                                       //              CustomStringReplace(Path, '/storage', '')
+                                       //              + FileName;
+                                       DownloadHost := 'storage';
                                end else begin
                                        Result := dsNotModify;
                                end;
@@ -614,39 +956,6 @@ begin
        end;
 
 end;
-// *************************************************************************
-// download\82µ\82Ä\82«\82½Dat\82Ì\82 \82Ú\81[\82ñ\82³\82ê\82½\95ª\82ð\95â\8f[\82µ\82Ä\81A
-// \83\8c\83X\90\94\82Æ\88ê\92v\82·\82é\82æ\82¤\82É\82·\82é
-// *************************************************************************
-procedure      TShitarabaThreadItem.ArrangeDownloadData(
-       start: Integer; // \90V\8bK\81F\82O\81@\92Ç\8bL\81F\91O\89ñ\82Ü\82Å\82Ì\8eæ\93¾\90\94
-               var Data: TStringList   //Dat\82Ì\83f\81[\83^
-);
-var
-       i: Integer;
-               n: Integer;
-               tmp: string;
-begin
-       i := start;
-               while i < Data.count + start do begin
-                       try
-                                       tmp := Copy(Data[i - start], 1 , AnsiPos('<>', Data[ i - start ] )-1 );
-                                               try
-                                                       n := StrToInt(tmp);
-                                                               if n > i + 1 then begin
-                                                                       Data.Insert(i - start, Format('%d<><><><><><>', [i+1]));
-                                                               end;
-                                                               Inc(i);
-                                               except
-                                                       Inc(i);
-                       end;
-                               except
-
-                               end;
-               end;
-
-end;
-
 
 // *************************************************************************
 // \8f\91\82«\8d\9e\82Ý\82ð\8ew\8e¦\82³\82ê\82½
@@ -828,11 +1137,18 @@ begin
        uriList := TStringList.Create;
        try
                ExtractHttpFields( ['/', '?'], [], uri.Path, uriList );
-               FileName := uriList[ 5 ] + '.dat';
-               // http://jbbs.shitaraba.com/bbs/read.cgi/game/1578/1067968274/l100
-               // http://jbbs.shitaraba.com/game/1000/subject.txt
-               Result          := CreateResultString(
-                       uri.Protocol + '://' + uri.Host + '/' + uriList[ 3 ] + '/' + uriList[ 4 ] + '/' );
+               if( AnsiPos('.html', uri.Document) = 0 ) then begin //\92Ê\8fí
+                       FileName := uriList[ 5 ] + '.dat';
+                       // http://jbbs.shitaraba.com/bbs/read.cgi/game/1578/1067968274/l100
+                       // http://jbbs.shitaraba.com/game/1000/subject.txt
+                       Result          := CreateResultString(
+                               uri.Protocol + '://' + uri.Host + '/' + uriList[ 3 ] + '/' + uriList[ 4 ] + '/' );
+               end else begin
+                       //http://jbbs.shitaraba.com/game/1578/storage/1086710948.html
+                       Result  := CreateResultString(
+                               uri.Protocol + '://' + uri.Host + CustomStringReplace(uri.Path, '/storage', ''));
+               end;
+
        finally
                uri.Free;
                uriList.Free;
@@ -873,6 +1189,8 @@ end;
 // \88À\91S\82È\83u\83\89\83E\83U\95\\8e¦\97p\82Ì URL
 // *************************************************************************
 function       TShitarabaThreadItem.BrowsableURL : string;
+const
+       THREAD_MARK     = '/bbs/read.cgi';
 var
        uri                             : TIdURI;
        uriList         : TStringList;
@@ -901,12 +1219,22 @@ begin
                        uri := TIdURI.Create( URL )
                else
                        uri := TIdURI.Create( URL + '/' );
+
                uriList := TStringList.Create;
                try
                        ExtractHttpFields( ['/'], [], uri.Path, uriList );
-                       Result :=
-                               uri.Protocol + '://' + uri.Host + '/bbs/read.cgi/' +
-                               uriList[ 3 ] + '/' + uriList[ 4 ] + '/' + uriList[ 5 ] + '/l100';
+                       if( AnsiPos(THREAD_MARK, URL) > 0) and (uriList.Count > 5) then begin
+                               Result :=
+                                       uri.Protocol + '://' + uri.Host + THREAD_MARK + '/' +
+                                       uriList[ 3 ] + '/' + uriList[ 4 ] + '/' + uriList[ 5 ] + '/l100';
+
+                       end else if AnsiPos(THREAD_MARK, URL) = 0 then begin
+                       //\83R\83R\82Å\89ß\8b\8e\83\8d\83O\82©\82Ç\82¤\82©\83`\83F\83b\83N\81H
+                               if(AnsiPos('.html/', uri.Path) > 0) then begin
+                                       Result := uri.Protocol + '://' + uri.Host + Copy(uri.Path, 1, Length(uri.Path) - 1);
+                               end else
+                                       Result := URL;
+                       end;
                finally
                        uri.Free;
                        uriList.Free;
@@ -919,6 +1247,8 @@ end;
 // \88À\91S\82È( '/' \82Å\8fI\82í\82é )\93Ç\82Ý\8d\9e\82Ý\82Ì URL
 // *************************************************************************
 function       TShitarabaThreadItem.ReadURL : string;
+const
+       THREAD_MARK     = '/bbs/read.cgi';
 var
        uri                             : TIdURI;
        uriList         : TStringList;
@@ -952,9 +1282,17 @@ begin
                try
                        ExtractHttpFields( ['/'], [], uri.Path, uriList );
                        // http://jbbs.shitaraba.com/bbs/read.cgi/game/1578/1067968274/l100
-                       Result :=
-                               uri.Protocol + '://' + uri.Host + '/bbs/rawmode.cgi/' +
-                               uriList[ 3 ] + '/' + uriList[ 4 ] + '/' + uriList[ 5 ] + '/';
+                       if( AnsiPos(THREAD_MARK, URL) > 0) and (uriList.Count > 5) then begin
+                               Result :=
+                                       uri.Protocol + '://' + uri.Host + '/bbs/rawmode.cgi/' +
+                                       uriList[ 3 ] + '/' + uriList[ 4 ] + '/' + uriList[ 5 ] + '/';
+                       end else if AnsiPos(THREAD_MARK, URL) = 0 then begin
+                       //\83R\83R\82Å\89ß\8b\8e\83\8d\83O\82©\82Ç\82¤\82©\83`\83F\83b\83N\81H
+                               if(AnsiPos('.html/', uri.Path) > 0) then begin
+                                       Result := uri.Protocol + '://' + uri.Host + Copy(uri.Path, 1, Length(uri.Path) - 1);
+                               end else
+                                       Result := URL;
+                       end;
                finally
                        uri.Free;
                        uriList.Free;