English > Development
Script for egafd.com
Ivek23:
--- Quote from: pra15 on December 30, 2011, 05:38:31 pm ---Thank you
--- End quote ---
Welcome.
--- Quote from: pra15 on December 30, 2011, 05:38:31 pm --- happy new year at all!
--- End quote ---
The same other users.
Ivek23:
egafd_movie
For prList :
Corrected search results for part of the code for alias Name,
--- Code: ---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
--- End code ---
where the missing first letter in the mail (not was) for alternative Movie title.
Now is OK.
Whole prList code:
--- 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 ----------//
--- End code ---
Ivek23:
egafd_movie
Small change for Director:
--- Quote from: Ivek23 on December 30, 2011, 12:27:51 pm ---egafd_movie
The reason why I do the following:
For Director:
When the Director is now displayed only the first director now, because otherwise the People section you can not find information for example, such associations in Director Title:
* Alessandro Perrella as Alex Perry
* Alessandro Perrella aas Alex Perry
* Alessandro Perrella / Alex Perry
* Alessandro Perrella, Alex Perry
* Alessandro Perrella and Alex Perry
--- End quote ---
--- Code: ---//Director
dbgstrg := '';
curPos := Pos('<td valign="top">Director: ', HTML);
EndPos := curPos;
LogMessage('getting Director');
dbgstrg:= TextBetween(HTML, '<td valign="top">Director: </td><td width="100%" class="notes">', '</td>', False, CurPos);
LogMessage('DIRECTOR:' + dbgstrg);
If dbgstrg <> '' then
AddFieldValueXML('comment', ' • • ' + SCRIPT_NAME + ' ' + SCRIPT_VERSION +
' • • ' + 'Directors: ' + dbgstrg)
else
AddFieldValueXML('comment', ' • • ' + SCRIPT_NAME + ' ' + SCRIPT_VERSION +
' • • ');
debug_pos1:=Pos('(',dbgstrg);
if debug_pos1 >0 then
dbgstrg := Copy(dbgstrg,0,debug_pos1-1);
LogMessage(dbgstrg);
debug_pos1:=Pos(', ',dbgstrg);
if debug_pos1 >0 then
dbgstrg := Copy(dbgstrg,0,debug_pos1-1);
LogMessage(dbgstrg);
debug_pos1:=Pos(' as ',dbgstrg);
if debug_pos1 >0 then
dbgstrg := Copy(dbgstrg,0,debug_pos1-1);
LogMessage(dbgstrg);
debug_pos1:=Pos(' aas ',dbgstrg);
if debug_pos1 >0 then
dbgstrg := Copy(dbgstrg,0,debug_pos1-1);
LogMessage(dbgstrg);
debug_pos1:=Pos('/',dbgstrg);
if debug_pos1 >0 then
dbgstrg := Copy(dbgstrg,0,debug_pos1-1);
LogMessage(dbgstrg);
debug_pos1:=Pos(' and ',dbgstrg);
if debug_pos1 >0 then
dbgstrg := Copy(dbgstrg,0,debug_pos1-1);
LogMessage(dbgstrg);
debug_pos1:=Pos('?',dbgstrg);
if debug_pos1 >0 then
dbgstrg := Copy(dbgstrg,0,debug_pos1-1);
LogMessage(dbgstrg);
If dbgstrg <> '' then
AddMoviePerson(dbgstrg, '', '', '', ctDirectors);
--- End code ---
pra15:
Thank you!
Do you think we must add more style of search sentence (with 3 words for example) or this is not necessary.
Ivek23:
--- Quote from: pra15 on January 03, 2012, 09:59:08 am ---Thank you!
Do you think we must add more style of search sentence (with 3 words for example) or this is not necessary.
--- End quote ---
If the search results will certainly be better than it is in force until now, of course, and therefore more effective search movie titles, definitely yes, yes, this also makes.
We'll see where this is a test of how it works.
Navigation
[0] Message Index
[#] Next page
[*] Previous page
Go to full version