antp wrote:I think that I'll add that to the comments field

Yep that would be the best, but I didn't add it there because of two reasons:
1.- I don't know programing nor scripting... I made this one based on other fields without much real knowledge of what I was doing

so I don't figure how to add it to comments without actually replacing the comments, and
2.- I wanted to be able to export it (html) on a single field next to title/director/actors...
Any way, here is the complete script for adding only the certification to the movies on a catalog (
on the borrowers field), in case is usefull for someone
Code: Select all
// GETINFO SCRIPTING
// IMDB (US) import USA Certification (on borrowers field)
(***************************************************
* Movie importation script for: *
* IMDB (US), http://us.imdb.com *
* *
* (c) 2002 Antoine Potten antoine@buypin.com *
* Improvements made by Danny Falkov *
* Improvements made by Kai Blankenhorn *
* *
* For use with Ant Movie Catalog 3.4.0 *
* www.ant.be.tf/moviecatalog ยทยทยท www.buypin.com *
* *
* The source code of the script can be used in *
* another program only if full credits to *
* script author and a link to Ant Movie Catalog *
* website are given in the About box or in *
* the documentation of the program *
***************************************************)
program IMDb;
var
MovieName: string;
function FindLine(Pattern: string; List: TStringList; StartAt: Integer): Integer;
var
i: Integer;
begin
result := -1;
if StartAt < 0 then
StartAt := 0;
for i := StartAt to List.Count-1 do
if Pos(Pattern, List.GetString(i)) <> 0 then
begin
result := i;
Break;
end;
end;
procedure AnalyzePage(Address: string);
var
Page: TStringList;
LineNr: Integer;
begin
Page := TStringList.Create;
Page.Text := GetPage(Address);
if pos('<TITLE>IMDb', Page.Text) = 0 then
begin
SetField(fieldURL, Address);
AnalyzeMoviePage(Page)
end else
begin
PickTreeClear;
LineNr := 0;
LineNr := FindLine('<H2><A NAME="top">Most popular searches</A></H2>', Page, LineNr);
if LineNr > -1 then
begin
PickTreeAdd('Most popular searches', '');
AddMoviesTitles(Page, LineNr);
end;
LineNr := FindLine('<H2><A NAME="mov">Movies</A></H2>', Page, LineNr);
if LineNr > -1 then
begin
PickTreeAdd('Movies', '');
AddMoviesTitles(Page, LineNr);
end;
LineNr := FindLine('<H2><A NAME="tvm">TV-Movies</A></H2>', Page, LineNr);
if LineNr > -1 then
begin
PickTreeAdd('TV-Movies', '');
AddMoviesTitles(Page, LineNr);
end;
LineNr := FindLine('<H2><A NAME="tvs">TV series</A></H2>', Page, LineNr);
if LineNr > -1 then
begin
PickTreeAdd('TV Series', '');
AddMoviesTitles(Page, LineNr);
end;
LineNr := FindLine('<H2><A NAME="vid">Made for video</A></H2>', Page, LineNr);
if LineNr > -1 then
begin
PickTreeAdd('Made for video', '');
AddMoviesTitles(Page, LineNr);
end;
if PickTreeExec(Address) then
AnalyzePage(Address);
end;
Page.Free;
end;
procedure AnalyzeMoviePage(Page: TStringList);
var
Line, Value, Value2, FullValue: string;
LineNr: Integer;
BeginPos, EndPos: Integer;
begin
//Certification
LineNr := FindLine('Certification:', Page, 0);
if LineNr > -1 then
begin
Line := Page.GetString(LineNr + 1);
BeginPos := pos(';USA:', Line) + 5;
EndPos := pos('">USA:', Line);
Value := copy(Line, BeginPos, EndPos - BeginPos);
HTMLDecode(Value);
SetField(fieldBorrower, Value);
end;
DisplayResults;
end;
procedure GetDescriptions(Address: string);
var
Line, Value: string;
LineNr: Integer;
BeginPos, EndPos: Integer;
Page: TStringList;
begin
Page := TStringList.Create;
Page.Text := GetPage('http://us.imdb.com' + Address);
LineNr := FindLine('<p class="plotpar">', Page, 0);
while LineNr > -1 do
begin
Value := '';
repeat
Line := Page.GetString(LineNr);
BeginPos := pos('"plotpar">', Line);
if BeginPos > 0 then
BeginPos := BeginPos + 10
else
BeginPos := 1;
EndPos := pos('</p>', Line);
if EndPos < 1 then
EndPos := Length(Line) + 1;
if Value <> '' then
Value := Value + ' ';
Value := Value + copy(Line, BeginPos, EndPos - BeginPos);
LineNr := LineNr + 1;
until (pos('</p>', Line) > 0) or (LineNr = Page.Count);
PickListAdd(Value);
LineNr := FindLine('<p class="plotpar">', Page, LineNr);
end;
Page.Free;
end;
procedure AddMoviesTitles(Page: TStringList; var LineNr: Integer);
var
Line: string;
MovieTitle, MovieAddress: string;
StartPos: Integer;
begin
repeat
LineNr := LineNr + 1;
Line := Page.GetString(LineNr);
StartPos := pos('="', Line);
if StartPos > 0 then
begin
Startpos := Startpos + 2;
MovieAddress := copy(Line, StartPos, pos('">', Line) - StartPos);
StartPos := pos('">', Line) + 2;
MovieTitle := copy(Line, StartPos, pos('</A>', Line) - StartPos);
HTMLDecode(Movietitle);
PickTreeAdd(MovieTitle, 'http://us.imdb.com' + MovieAddress);
end;
until pos('</OL>', Line) > 0;
end;
begin
if CheckVersion(3,4,0) then
begin
MovieName := GetField(fieldOriginalTitle);
if MovieName = '' then
MovieName := GetField(fieldTranslatedTitle);
if Input('IMDb Import', 'Enter the title of the movie:', MovieName) then
begin
// AnalyzePage('http://us.imdb.com/Tsearch?title='+UrlEncode(MovieName)+'&restrict=Movies+only');
AnalyzePage('http://us.imdb.com/Tsearch?title='+UrlEncode(MovieName));
end;
end else
ShowMessage('This script requires a newer version of Ant Movie Catalog (at least the version 3.4.0)');
end.
Best regards,
Mguel