procedure TMainForm.parseLinks(x :
String);
var
y :
String;
i, j : Integer;
errorCount : Integer;
origList : TStringList;
newList : TList;
tmp,
url, httpAnswer :
String;
newLink : TRSLink;
inList : Boolean;
begin
// AUSLESEN DER LINKS
origList := TStringList.Create;
x := StringReplace(x, #13, '
', [rfReplaceAll, rfIgnoreCase]);
x := StringReplace(x, #10, '
', [rfReplaceAll, rfIgnoreCase]);
x := x + '
';
errorCount := 0;
while(pos('
rapidshare.com/files/', x) > 0)
do
begin
x := copy(x, pos('
rapidshare.com/files/', x), length(x));
tmp := copy(x, 0, pos('
', x)- 1);
origList.add(tmp);
x := copy(x, length(tmp) + 1, length(x));
end;
//origList.Delimiter := ' ';
//origList.DelimitedText := x;
newList := TList.Create;
for i := 0
to origList.Count - 1
do
begin
x := origList.Strings[i];
newLink := TRSLink.create;
newLink.URL := x;
newList.Add(newLink);
end;
////////////////////////////////////////
// LINKS BEARBEITEN
////////////////////////////////////////
for i := 0
to newList.Count - 1
do
begin
Application.ProcessMessages;
newLink := TRSLink(newList.Items[i]);
x := newLink.URL;
x := copy(x, pos('
//', x) + 2, length(x));
x := copy(x, pos('
/', x) + 1, length(x));
x := copy(x, pos('
/', x) + 1, length(x));
y := copy(x, pos('
/', x) + 1, length(x));
x := copy(x, 0, pos('
/', x) - 1);
newLink.FileID := x;
newLink.FileName := y;
////////////////////////////////////////
// RS.COM API - HOSTNAMEN ABRUFEN
////////////////////////////////////////
Application.ProcessMessages;
URL := API_LINK + '
sub=checkfiles';
URL :=
URL + '
&files=' + newLink.FileID;
URL :=
URL + '
&filenames=' + newLink.FileName;
// Dateistatus abfragen...
httpAnswer := '
';
httpAnswer := idHTTP.Get(
URL);
// ... und verarbeiten
if(pos('
ERROR:', httpAnswer) < 1)
then
begin
// SIZE IN BYTES
httpAnswer := copy(httpAnswer, length(newLink.FileID) + length(newLink.FileName) + 3, length(httpAnswer));
newLink.SizeInBytes := StrToInt(copy(httpAnswer, 0, pos('
,', httpAnswer) - 1));
// SERVER-ID
httpAnswer := copy(httpAnswer, pos('
,', httpAnswer) + 1, length(httpAnswer));
newLink.ServerID := copy(httpAnswer, 0, pos('
,', httpAnswer) - 1);
// STATUS
httpAnswer := copy(httpAnswer, pos('
,', httpAnswer) + 1, length(httpAnswer));
newLink.Status := StrToInt(copy(httpAnswer, 0, pos('
,', httpAnswer) - 1));
// SHORT HOST
httpAnswer := copy(httpAnswer, pos('
,', httpAnswer) + 1, length(httpAnswer));
newLink.ShortHost := copy(httpAnswer, 0, pos('
,', httpAnswer) - 1);
// STATUS AUSGABE
case newLink.Status
of
0 : newLink.StatusStr := ARR_FileStatus[0];
1 : newLink.StatusStr := ARR_FileStatus[1];
3 : newLink.StatusStr := ARR_FileStatus[2];
4 : newLink.StatusStr := ARR_FileStatus[3];
5 : newLink.StatusStr := ARR_FileStatus[3];
50..99 : newLink.StatusStr := ARR_FileStatus[1];
100..200: newLink.StatusStr := ARR_FileStatus[1];
else newLink.StatusStr := ARR_FileStatus[5];
end;
newLink.Percent := 0;
end
else
begin
inc(errorCount);
end;
L_Status.Caption := '
Status: getting Fileinfo... ' + IntToStr(i + 1) + '
/ ' + IntToStr(newList.Count);
L_Status.Caption := L_Status.Caption + '
- Errors: ' + IntToStr(errorCount);
end;
for i := 0
to newList.Count - 1
do
begin
newLink := TRSLink(newList.Items[i]);
inList := false;
for j := 0
to ARR_Links.Count - 1
do
begin
if(newLink.URL = TRSLink(ARR_Links.Items[j]).URL)
then
begin
inList := true;
break;
end;
end;
if(inList = false)
then
begin
ARR_Links.Add(TRSLink(newList.Items[i]));
end;
end;
////////////////////////////////////////
// FREIGABE
////////////////////////////////////////
newList.Free;
origList.Free;
end;