procedure TMainForm.parseLinks(x :
String);
var
y :
String;
i, j : Integer;
errorCount : Integer;
origList : TStringList;
newList : TList;
url, httpAnswer :
String;
nowLink : 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;
origList.DelimitedText := x;
for i := origList.Count - 1
downto 0
do
begin
if(pos('
rapidshare.com/files/', origList.Strings[i]) < 1)
then
begin
origList.Delete(i);
end;
end;
newList := TList.Create;
////////////////////////////////////////
// LINKS BEARBEITEN
////////////////////////////////////////
for i := 0
to origList.Count - 1
do
begin
Application.ProcessMessages;
nowLink := TRSLink.create;
nowLink.URL := origList.Strings[i];
x := nowLink.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);
nowLink.FileID := x;
nowLink.FileName := y;
////////////////////////////////////////
// RS.COM API - HOSTNAMEN ABRUFEN
////////////////////////////////////////
Application.ProcessMessages;
URL := API_LINK + '
sub=checkfiles';
URL :=
URL + '
&files=' + nowLink.FileID;
URL :=
URL + '
&filenames=' + nowLink.FileName;
// Dateistatus abfragen...
httpAnswer := '
';
httpAnswer := myHTTPGet(
URL);
// ... und verarbeiten
if(pos('
ERROR:', httpAnswer) < 1)
then
begin
// SIZE IN BYTES
httpAnswer := copy(httpAnswer, pos('
,', httpAnswer) + 1, length(httpAnswer));
httpAnswer := copy(httpAnswer, pos('
,', httpAnswer) + 1, length(httpAnswer));
nowlink.SizeInBytes := StrToInt(copy(httpAnswer, 0, pos('
,', httpAnswer) - 1));
httpAnswer := copy(httpAnswer, pos('
,', httpAnswer) + 1, length(httpAnswer));
// SERVER-ID
nowlink.ServerID := copy(httpAnswer, 0, pos('
,', httpAnswer) - 1);
httpAnswer := copy(httpAnswer, pos('
,', httpAnswer) + 1, length(httpAnswer));
// STATUS
nowlink.Status := StrToInt(copy(httpAnswer, 0, pos('
,', httpAnswer) - 1));
httpAnswer := copy(httpAnswer, pos('
,', httpAnswer) + 1, length(httpAnswer));
// SHORT HOST
nowlink.ShortHost := copy(httpAnswer, 0, pos('
,', httpAnswer) - 1);
// STATUS AUSGABE
case nowlink.Status
of
0 : nowlink.StatusStr := ARR_FileStatus[0];
1 : nowlink.StatusStr := ARR_FileStatus[1];
3 : nowlink.StatusStr := ARR_FileStatus[2];
4 : nowlink.StatusStr := ARR_FileStatus[3];
5 : nowlink.StatusStr := ARR_FileStatus[3];
50..99 : nowlink.StatusStr := ARR_FileStatus[1];
100..200: nowlink.StatusStr := ARR_FileStatus[1];
else nowlink.StatusStr := ARR_FileStatus[5];
end;
nowlink.Percent := 0;
newList.Add(nowLink);
end
else
begin
inc(errorCount);
end;
L_Status.Caption := '
Status: getting Fileinfo... ' + IntToStr(i + 1) + '
/ ' + IntToStr(origList.Count);
L_Status.Caption := L_Status.Caption + '
- Errors: ' + IntToStr(errorCount);
end;
for i := 0
to newList.Count - 1
do
begin
nowlink := TRSLink(newList.Items[i]);
inList := false;
for j := 0
to ARR_Links.Count - 1
do
begin
if(nowlink.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;