egafd_movie
For prList :
Corrected search results for part of the code for alias Name,
end
else begin // Name is in Alternative title for ......
// Alias Name
actPosStart := Prevpos('"flma">', HTML, curpos);
actPosEnd := Posfrom('</a>', HTML, actPosStart);
Aliasname := Trim(Copy(HTML, (actPosStart + 7), (actPosEnd - actPosStart - 7)));
Logmessage('AliasName: '+ AliasName);
// Real Name
where the missing first letter in the mail (not was) for alternative Movie title.
Now is OK.
Whole prList code:
//---------- Procedure SearchResults ----------//
// Create list of movies found during the search
procedure SearchResults (HTML : String);
Var
URLXPage, URLTemp, NameTemp, BeforeName, ifAlias, AliasName, RealName, firstStr2, noteSearch : String;
TabPartTitle, TabNoteSearch : TwideArray;
TabPartSearch : Array[0..1] of string;
nSearch, ifFind, actPosStart, actPosEnd, URLPosStart, URLPosEnd, notPosStart, notPosEnd : Integer;
CurPos, endPos, actalPosStart, actalPosEnd, TypPVD : Integer;
essai : string;
Begin
ifFind := 0; //Initialisation variable
// Separate parts of title :
If Pos(#32,nMovie) = 0 then begin
nSearch := 1;
TabPartSearch[0] := nMovie;
end
else begin
ExplodeString(nMovie,TabPartTitle,#32);
// Case where option in PVD is 'Title, the' :
If Copy(TabPartTitle[High(TabPartTitle)-1],Length(TabPartTitle[High(TabPartTitle)-1]),1) = ',' then begin
TypPVD := 1;
TabPartTitle[High(TabpartTitle)-1] := Copy(TabPartTitle[High(TabpartTitle)-1], 1, Length(TabpartTitle[High(TabpartTitle)-1])-1);
For I := Low(TabPartTitle) to (High(TabPartTitle)-1) do
Begin
nMovie := '';
If I = 0 then begin
nMovie := TabpartTitle[I];
end
else begin
nMovie := nMovie + #32 + TabPartTitle[I];
end;
end;
nMovie := TabPartTitle[High(TabPartTitle)] + #32 + nMovie;
LogMessage(nMovie);
firstStr2 := LowerCase(Copy(TabPartTitle[High(TabPartTitle)], 1 ,1));
end
else begin
TypPVD := 0;
FirstStr2 := LowerCase(Copy(TabPartTitle[1],1,1));
end;
For I := Low(TabPartTitle) to High(TabPartTitle) do
Begin
TabPartTitle[I] := Lowercase(TabPartTitle[I]);
end;
// Second value to search :
TabPartSearch [0] := LowerCase(nMovie);
nSearch := 1;
If High(TabPartTitle) > 0 then begin
If Length(TabPartTitle[0]) > 3 then begin
TabPartSearch [1] := TabPartTitle[0];
nSearch := 2;
end
else
If (Length(TabPartTitle[0]) < 4) AND (Length(TabPartTitle[1]) > 3) then begin
TabPartSearch [1] := TabPartTitle[1];
nSearch := 2;
end
else begin
TabPartSearch [1] := TabPartTitle[0] + #32 + TabPartTitle[1];
nSearch := 2;
end;
LogMessage('Second search : ' + TabPartSearch[1]);
end;
LogMessage ('nSearch' + IntToStr(nSearch));
end;
//Search:
I:= 0;
While (I < nSearch) AND (ifFind = 0) do Begin
logMessage ('while commence');
Curpos := Pos(TabPartSearch[I], HTML);
If curpos > 0 then begin
endPos := curpos;
While (curpos > 0) AND (curpos < PosFrom('<h2 class="index">Films:', HTML, Endpos)) do begin
endpos := curpos;
actPosStart:= PrevPos('>', HTML, curpos);
actPosEnd := Posfrom('</', HTML, actposStart);
NameTemp := LowerCase(Trim(Copy(HTML, actPosStart+1, (actPosEnd-actPosStart-1))));
LogMessage ('NameTemp: '+ NameTemp);
LogMessage ('nmovie: '+ nMovie);
beforeName := Trim(Copy(HTML, actposStart-3, 1));
If copy(NameTemp,1,21) = 'alternative title for' then
ifAlias := 'True'
else
ifAlias := '';
Case NameTemp of
nMovie : Begin //Same name as Title
//logmessage('Same Movie as title');
Case BeforeName of
'l' : Begin //Real Name
RealName := NameTemp;
AliasName := NameTemp;
//Notes
notPosStart := Posfrom('/a>', HTML, Curpos);
essai := copy(HTML, notPosStart+3,1);
LogMessage('essai: ' + essai);
If copy(HTML, notPosStart+3,1) = #32 then begin
logmessage('if begin');
notPosStart := PosFrom('class="notes">', HTML, notPosstart)+14;
notPosEnd := PosFrom('</i>', HTML, notPosStart);
noteSearch := Trim(Copy(HTML, notPosStart, (notPosEnd-notPosStart)));
logmessage(notesearch);
end
else begin
noteSearch := '';
end;
// Get URL
urlPosStart := Prevpos('href="', HTML, actposStart);
urlPosend := PosFrom('" class="', HTML, urlPosstart);
URLTemp := BASE_URL + Trim(Copy(HTML, urlposStart + 6, (urlPosEnd-urlPosStart-6)));
AddSearchResult(AliasName, NoteSearch, '', LowerCase(URLTemp),'');
actPosEnd := PosFrom('href="', HTML, urlPosEnd);
ifFind := 1;
LogMessage('TYPE I: Same Title as original movie');
end;
else begin // Good Name but Alternative title
//logmessage('Good Name but Alias');
AliasName := nMovie;
// Real Name
actalPosStart := Posfrom('alternative title for ', HTML, actposEnd);
actalposEnd := Posfrom('</span>', HTML, actalposstart);
RealName := Trim(Copy(HTML, (actalposStart + 22), (actalposEnd - actalposStart - 22)));
// Name Temp
NameTemp := 'Alternative title for ' + RealName;
// Get URL
urlPosStart := PrevPos('href="', HTML, actPosstart);
urlPosend := PosFrom('" class="', HTML, urlPosstart);
URLTemp := BASE_URL + Trim(Copy(HTML, urlposStart + 6, (urlPosEnd-urlPosStart-6)));
AddSearchResult(AliasName, NameTemp, '', LowerCase(URLTemp),'');
actPosEnd := PosFrom('href="', HTML, urlPosEnd);
ifFind := 1;
LogMessage('TYPE II: Same Title as an alternative title of a Movie');
end;
end;
end;
else begin
//Part of Name
If ifAlias <> 'True' then begin
If Copy(HTML, actPosStart-1,1) <> '>' then actPosStart := PrevPos('>', HTML, curpos);
actPosEnd := Posfrom('</', HTML, actposStart);
AliasName := Trim(Copy(HTML, actPosStart+1, (actPosEnd-actPosStart-1)));
beforeName := Trim(Copy(HTML, actposStart-3, 1));
Case beforename of
'l' : Begin // Title is a part of a real Movie
// Real Name
RealName := AliasName;
logmessage(Realname);
logmessage(AliasName);
//Notes
notPosStart := Posfrom('/a>', HTML, Curpos);
essai := copy(HTML, notPosStart+3,1);
LogMessage('essai: ' + essai);
If copy(HTML, notPosStart+3,1) = #32 then begin
logmessage('if begin');
notPosStart := PosFrom('class="notes">', HTML, notPosstart)+14;
notPosEnd := PosFrom('</i>', HTML, notPosStart);
noteSearch := Trim(Copy(HTML, notPosStart, (notPosEnd-notPosStart)));
logmessage(notesearch);
end
else begin
noteSearch := '';
end;
// Get URL
urlPosStart := Prevpos('href="', HTML, actposStart);
urlPosend := PosFrom('" class="', HTML, urlPosstart);
URLTemp := BASE_URL + Trim(Copy(HTML, urlposStart + 6, (urlPosEnd-urlPosStart-6)));
logmessage(URLTemp);
AddSearchResult(RealName, NoteSearch, '', LowerCase(URLTemp),'');
ifFind := 1;
actPosEnd := PosFrom('href="', HTML, urlPosEnd);
logmessage('TYPE III: Part of a Real Name');
end;
else begin
// Real Name
actalPosStart := Posfrom('alternative title for ', HTML, actPosEnd);
actalPosEnd := Posfrom('</span>', HTML, actalPosStart);
RealName := Trim(Copy(HTML, (actalposStart + 10), (actalposEnd - actalposStart - 10)));
NameTemp := 'alternative title for ' + Realname;
// Get URL
urlPosStart := PrevPos('href="', HTML, actPosstart);
urlPosend := PosFrom('" class="', HTML, urlPosstart);
URLTemp := BASE_URL + Trim(Copy(HTML, urlposStart + 6, (urlPosEnd-urlPosStart-6)));
AddSearchResult(AliasName, NameTemp, '', LowerCase(URLTemp),'');
actPosEnd := PosFrom('href="', HTML, actalPosEnd);
ifFind := 1;
Logmessage('TYPE IV: Part of an alternative Name');
end;
end;
end
else begin // Name is in Alternative title for ......
// Alias Name
actPosStart := Prevpos('"flma">', HTML, curpos);
actPosEnd := Posfrom('</a>', HTML, actPosStart);
Aliasname := Trim(Copy(HTML, (actPosStart + 7), (actPosEnd - actPosStart - 7)));
Logmessage('AliasName: '+ AliasName);
// Real Name
actalPosStart := Posfrom('alternative title for ', HTML, actposEnd);
actalPosEnd := Posfrom('</span>', HTML, actalposStart);
RealName := Trim(Copy(HTML, (actalposStart + 22), (actalposEnd - actalposStart - 22)));
LogMessage('RealName: '+ RealName);
// Get URL
urlPosStart := PrevPos('href="', HTML, actalPosstart);
urlPosend := PosFrom('" class="', HTML, urlPosstart);
URLTemp := BASE_URL + Trim(Copy(HTML, urlposStart + 6, (urlPosEnd-urlPosStart-6)));
AddSearchResult(AliasName, NameTemp, '', LowerCase(URLTemp),'');
ifFind := 1;
actPosEnd := PosFrom('href="', HTML, urlPosEnd);
logmessage('TYPE V: Part find in alternative title for...');
end;
end;
end;
curpos := PosFrom(TabPartSearch[I], HTML, actPosEnd);
end;
end;
I := I + 1;
end; // End first while
// Add others alphabetics page in prList (who had not seen) if no result in actual page:
If (ifFind = 0) then begin
ShowMessage('Try to find movie in another alphabetic page!', 'MOVIE NOT FIND IN THIS PAGE :');
For A := Low(TabSeenXPage) to High(TabSeenXPage) do
Begin
If TabSeenXPage[A] = '0' then begin
URLXPage := 'http://www.egafd.com/films/index.php/index/' + TabXPage[A];
AddSearchResult('Search in Alphabetic page',UpperCase(TabXPage[A]),'', URLXPage,'');
end;
end;
end
else begin
CurPos := Pos('<title>Films: ', HTML);
If (Copy(URLSearch, Length(URLSearch), 1)) = (LowerCase(Copy(HTML,Curpos+14,1))) then begin
URLXPage := 'http://www.egafd.com/films/index.php/index/' + firstStr2;
AddSearchResult('Search in Alphabetic page',UpperCase(firstStr2),'', URLXPage,'');
end;
end;
end;
//---------- PARSE PAGE ----------//