English > Development
Script for egafd.com
Ivek23:
--- Quote from: pra15 on December 05, 2011, 02:29:48 pm ---Just a little modification in the case where the last movie in the list has not "role".
--- Code: ---// Get Role (Not yet defined)
difpos := (PosFrom('<i>', HTML, (actposEnd-1))+4) - actposend;
logmessage('DIFFERENCE : ' + intToStr(difpos));
If difpos > 0 then begin
If difpos < 200 then begin
actPosStart := PosFrom('<i>', HTML, (actposend-1)) + 4;
actPosEnd:=PosFrom('</i></li>', HTML, actPosStart) - 1;
Role := Trim(Copy(HTML, actposStart, (actPosEnd - actPosStart)));
LogMessage('Role: ' + Role);
debug_pos1:=Pos('(',Role);
if debug_pos1 >0 then
Role:= Copy(Role,0,debug_pos1-1);
LogMessage(Role);
end;
end;
--- End code ---
--- End quote ---
THANK YOU.
This code is now excellent it works.
--- Quote from: pra15 on December 05, 2011, 03:11:52 pm ---As a suggestion up,
I add this :
--- Code: ---//If Original:
actposstart := actposEnd + 5;
actposstart := PosFrom('">', HTML, actposstart) + 2;
actPosEnd := PosFrom('</', HTML, actPosstart) - 1;
If copy(HTML, actposstart, 3) = 'alt' then
OrigT := Copy(HTML, (actPosstart + 22),(actPosEnd-actPosStart-21))
else
OrigT := Title;
--- End code ---
and :
--- Code: ---// Total Line
If Lien <> '' then
Lien := Lien + #13;
If URL1 <> '' then begin
If OrigT <> Title then
Lien := Lien + Name
else
Lien := Lien + '<link url="' + URL1 + '">' + Name + '</link>';
end;
If Year <> '' then
Lien := Lien + ' • ' + Year;
If Note <> '' then
Lien := Lien + ' • ' + Note;
If Role <> '' then
Lien := Lien + ' • ' + Role;
LogMessage('LIEN :' + Lien);
--- End code ---
So in the list of movie in Field Bio, there's only link with original title!
I think it's clearly.
--- End quote ---
True, it is more transparent, to see the original movie links, which is very nice.
Thank you again.
BTW:
I tried to EGAFD MOVIE SCRIPT in section Cast add Role with this code or part of the code:
--- Code: ---
// Get Role
actPosStart := PosFrom('href="', HTML, EndPos); // search for url start;
actPosStart2 := PosFrom('</a> <', HTML, actPosStart)
actPosEnd:=PosFrom('</', HTML, actPosStart2); // search for url end
Role := Trim(Copy(HTML, (actPosStart2 + 7), (actPosEnd - actPosStart2 - 7) ));
LogMessage(Role);
debug_pos1:=Pos('(',Role);
if debug_pos1 >0 then
Role:= Copy(Role,0,debug_pos1-1);
LogMessage(Role);
AddMoviePerson(Trim(Name), '', Role, LowerCase(URL), ctActors);
--- End code ---
which should look like this in whole code
--- Code: --- //Cast
curPos:= Pos('<th>Actresses</th>', HTML);
LogMessage('Cast readout');
if curPos > 0 then begin
EndPos := curPos;
while (curPos > 0) AND (curPos < PosFrom('</ul>', HTML, EndPos)) do begin
EndPos := curPos; // Set last position to actual position
// get url
UrlPosStart := PosFrom('href="', HTML, EndPos); // search for url start
UrlPosEnd := PosFrom('>', HTML, UrlPosStart); // search for url end
URL := BASE_URL + Trim(Copy(HTML, UrlPosStart + 6, (UrlPosEnd - UrlPosStart - 7) ));
LogMessage(URL);
// Get Name
actPosStart := PosFrom('href="', HTML, EndPos); // search for url start;
actPosStart2 := PosFrom('">', HTML, actPosStart)
actPosEnd:=PosFrom('</a>', HTML, actPosStart2); // search for url end
Name := Trim(Copy(HTML, (actPosStart2 + 2), (actPosEnd - actPosStart2 - 2) ));
LogMessage(Name);
debug_pos1:=Pos('(',Name);
if debug_pos1 >0 then
Name := Copy(Name,0,debug_pos1-1);
LogMessage(Name);
// Get Role
actPosStart := PosFrom('href="', HTML, EndPos); // search for url start;
actPosStart2 := PosFrom('</a> <', HTML, actPosStart)
actPosEnd:=PosFrom('</', HTML, actPosStart2); // search for url end
Role := Trim(Copy(HTML, (actPosStart2 + 7), (actPosEnd - actPosStart2 - 7) ));
LogMessage(Role);
debug_pos1:=Pos('(',Role);
if debug_pos1 >0 then
Role:= Copy(Role,0,debug_pos1-1);
LogMessage(Role);
AddMoviePerson(Trim(Name), '', Role, LowerCase(URL), ctActors);
curPos := PosFrom('href="', HTML, actPosEnd);
end;
end;
--- End code ---
but does not work.
That is what changed.
pra15:
It's a good idea, if we can put role.
I made somes tests with egafd_movie and saw there's many bugs!
The same that we had first with egafe_people; If an info fail, the script doesn't give data.
I'll try to see that tomorow!
I made two minor modif in egafd_people, for vision only :
--- Code: ---Born := Trim(Copy(HTML, (PosStart + 25), (PosEnd - PosStart - 25)));
Born := Uppercase(Copy(Born,0,1)) + Copy(Born,2, length(Born)-1) + #13;
--- End code ---
--- Code: ---// BIO: //
curpos := Pos('<th>Films</th>', HTML);
LogMessage('Films readout');
if curPos > 0 then begin
Lien := '----- Filmography (EGAFD) -----' + #09;
EndPos := curPos;
--- End code ---
Ivek23:
--- Quote from: pra15 on December 05, 2011, 10:38:12 pm ---
I made two minor modif in egafd_people, for vision only :
--- Code: ---Born := Trim(Copy(HTML, (PosStart + 25), (PosEnd - PosStart - 25)));
Born := Uppercase(Copy(Born,0,1)) + Copy(Born,2, length(Born)-1) + #13;
--- End code ---
--- Code: ---// BIO: //
curpos := Pos('<th>Films</th>', HTML);
LogMessage('Films readout');
if curPos > 0 then begin
Lien := '----- Filmography (EGAFD) -----' + #09;
EndPos := curPos;
--- End code ---
--- End quote ---
I have a better and simple solution, the effect is the same as before.
--- Code: ---// Total Line
If Lien <> '' then
Lien := Lien + #13;
...
...
...
LogMessage('LIEN :' + Lien);
curPos := PosFrom('<a href="', HTML, actPosEnd);
end;
if (Lien <> '') AND (Born = '') then
AddFieldValue(pfBio, Lien);
if (Lien <> '') AND (Born <> '') then
AddFieldValue(pfBio, Born + #13 + #13 + Lien);
end;
--- End code ---
I modified the part of the Bio code
--- Code: ---//If Title:
actposstart := actposEnd + 5;
actposstart := PosFrom('">', HTML, actposstart) + 2;
actPosEnd := PosFrom('</', HTML, actPosstart) - 1;
If copy(HTML, actposstart, 11) = 'alternative' then
Title := Copy(HTML, (actPosstart + 22),(actPosEnd-actPosStart-21))
else
Title := OrigT;
//If Original:
actposstart := actposEnd + 5;
actposstart := PosFrom('">', HTML, actposstart) + 2;
actPosEnd := PosFrom('</', HTML, actPosstart) - 1;
If copy(HTML, actposstart, 3) = 'alt' then
OrigT := Copy(HTML, (actPosstart + 22),(actPosEnd-actPosStart-21))
else
OrigT := Title;
--- End code ---
and
--- Code: ---// Total Line
If Lien <> '' then
Lien := Lien + #13;
If URL1 <> '' then begin
If Title <> OrigT then
Lien := Lien + Name
else
If OrigT <> Title then
Lien := Lien + Name
else
Lien := Lien + '<link url="' + URL1 + '">' + Name + '</link>';
end;
If Year <> '' then
Lien := Lien + ' • ' + Year;
If Note <> '' then
Lien := Lien + ' • ' + Note;
If Role <> '' then
Lien := Lien + ' • ' + Role;
LogMessage('LIEN :' + Lien);
--- End code ---
and now, in addition to Original Title also that Title, which are not Alternative Title.
Not the best.
In Bio movie list is not as transparent as yours, I like it, Of course, if that is what change is also OK.
Could be done in BORN that all was as up to now, Birthplace field arranged so that there are visible such data like these for example:
Czech, b. 1985
Hungarian. b. 1978
pra15:
Thanks,
i'll see that later becaause i live in the middle of nowhere and the connection is very very slow during the day!
For "role" in egafd movie :
--- Code: ---// -------------- Procedure ParseMovie --------------//
// - after searchlist selection this function is called with the new html content
procedure ParseMovie(MovieURL : String; HTML : String);
var
curPos, EndPos, P, P2, L: Integer;
actPosStart,actPosStart2,
actPosEnd, UrlPosStart,UrlPosEnd,debug_pos1:Integer;
Tmp, URL, Name,dbgstrg,tmpstrg, Role : String;
ActorNames: TWideArray;
ActorNumber,I,J: Integer;
/////
begin
AddFieldValue(mfURL, MovieURL);
LogMessage('Page parsing started');
EndPos := 1;
//Check for title. No orig. title info present, so duplicate..
dbgstrg:= TextBetween(HTML, '<title>', '</title>', False, EndPos);
LogMessage('Title: ' + dbgstrg);
If dbgstrg <> '' then begin
AddFieldValue(mfOrigTitle,dbgstrg);
AddFieldValue(mfTitle,dbgstrg);
end;
//Year
dbgstrg := '';
CurPos := Pos('Released: ', HTML);
endpos := CurPos;
LogMessage('getting year');
dbgstrg := TextBetween(HTML, '">', '</td>', False, CurPos);
LogMessage('YEAR:' + dbgstrg);
If dbgstrg <> '' then
AddFieldValue(mfYear,dbgstrg);
//Director
dbgstrg := '';
curPos := Pos('Director: ', HTML);
EndPos := curPos;
LogMessage('getting Director');
dbgstrg:= TextBetween(HTML, '">', '</td>', False, CurPos);
LogMessage('DIRECTOR:' + dbgstrg);
If dbgstrg <> '' then
AddMoviePerson(dbgstrg, '', '', '', ctDirectors);
//Notes
dbgstrg := '';
curpos := Pos('Notes: ' , HTML);
EndPos := curPos;
LogMessage('Notes')
dbgstrg := TextBetween(HTML, '">', '</td>', False, CurPos);
LogMessage('Notes :' + dbgstrg);
If dbgstrg <> '' then
AddFieldValue(mfDescription, dbgstrg);
//AKA - Titles...
dbgstrg := '';
LogMessage('getting all titles')
Curpos := Pos('<th>Alternate Titles</th>' ,HTML);
EndPos := curPos;
////
while (curPos > 0) AND (curPos < PosFrom('<th>Actresses</th>', HTML, EndPos)) do begin
EndPos := curPos;
actPosStart := PosFrom('class="flma"', HTML, EndPos);
actPosEnd := PosFrom('</span>', HTML, actPosStart);
dbgstrg := Trim(Copy(HTML, (actPosstart + 13), (actPosEnd - actPosStart - 13) ));
LogMessage('AKA: ' + dbgstrg);
If dbgstrg <> '' then
AddFieldValue(mfAka, dbgstrg);
curpos := PosFrom('class="flma"', HTML, actPosEnd);
////
end;
//Cast
curPos:= Pos('<th>Actresses</th>', HTML);
LogMessage('Cast readout');
/////
if curPos > 0 then begin
EndPos := curPos;
///
while (curPos > 0) AND (curPos < PosFrom('<th>Notes</th>', HTML, EndPos)) do begin
EndPos := curPos;
// get url
UrlPosStart := PosFrom('href="', HTML, EndPos);
UrlPosEnd := PosFrom('">', HTML, UrlPosStart);
URL := BASE_URL + Trim(Copy(HTML, UrlPosStart + 6, (UrlPosEnd - UrlPosStart - 7) ));
LogMessage(URL);
// Get Name
//actPosStart := PosFrom('href="', HTML, EndPos); // search for url start;
//actPosStart2 := PosFrom('">', HTML, actPosStart)
//actPosEnd:=PosFrom('</a>', HTML, actPosStart2); // search for url end
//Name := Trim(Copy(HTML, (actPosStart2 + 2), (actPosEnd - actPosStart2 - 2) ));
//LogMessage(Name);
{Name := TextBetween(HTML, '">', '</a>', false, urlpostart);}
// Get Name
actposstart := urlposend + 2;
actposend := Posfrom('</a>', HTML, actposstart);
Name := Trim(Copy(HTML, actposstart, (actposend-actposstart)));
Logmessage('Name: ' + Name);
debug_pos1:=Pos('(',Name);
if debug_pos1 >0 then
Name := Copy(Name,0,debug_pos1-1);
LogMessage('Name:' + Name);
// Role
Role := '';
actposStart := actposend;
If (copy(HTML, actposstart + 4, 1)) <> '<' then begin
actposStart := actposstart -6;
Role := TextBetween(HTML, '<i>', '</i>', false, actposstart);
end;
debug_pos1:=Pos('(',Role);
if debug_pos1 >0 then
Role := Copy(Role,0,debug_pos1-1);
LogMessage('Role:'+ Role);
If URL <> '' then
If Name <> '' then
AddMoviePerson(Trim(Name), '', Role, LowerCase(URL), ctActors);
curPos := PosFrom('href="', HTML, actPosEnd);
///
end;
/////
end;
/////
end;
--- End code ---
It seems to be OK!
pra15:
Sorry, i don't understand your modification!
Certainly i made mistakes in modifying my code!
could you post your total code of Parse people?
I'm noting two errors in the code up :
If no "Notes" in the web page :
--- Code: ---//Cast
curPos:= Pos('<th>Actresses</th>', HTML);
LogMessage('Cast readout');
If pos('<th>Notes</th>', HTML) > 0 then
endListStr := '<th>Notes</th>'
else
endListStr := '>Suppliers</th>';
/////
if curPos > 0 then begin
EndPos := curPos;
///
while (curPos > 0) AND (curPos < PosFrom(endlistStr, HTML, EndPos)) do begin
--- End code ---
and an error in getting URL of actresse :
--- Code: ---// get url
UrlPosStart := PosFrom('href="', HTML, EndPos) + 6;
UrlPosEnd := PosFrom('">', HTML, UrlPosStart);
URL := BASE_URL + Trim(Copy(HTML, UrlPosStart, UrlPosEnd - UrlPosStart));
LogMessage(URL);
--- End code ---
Navigation
[0] Message Index
[#] Next page
[*] Previous page
Go to full version