the changes:
-adds the german title into the translated title field (sometimes it add some more then it should be, maybe someone can help me, read below code on)
-adds all excutive producers to the producer field, same like the actors with comma
-adds the german imdb url into the url field (german.imdb.com/...)
-translated the questions in the script to german (type in title, wrong version, etc.)
does not add following fields anymore (i don't need them)
-lenght (i got it already from the avi(s) )
-language (it always differs for me, so i add it manualy)
-comment (i don't need them, therefore i have the imdb link and sometimes own comments)
so here it is:
Code: Select all
// GETINFO SCRIPTING
// IMDB (DE) import, with translated title / excutive producer and without lenght, language and comment
(****************************************************
* Movie importation script for: *
* IMDB (DE), http://german.imdb.com *
* *
* (c) 2002 Antoine Potten antoine@buypin.com *
* Improvements made by Danny Falkov *
* German Additions and Modifications *
* made by Bad Joker badjoker@gmx.net *
* *
* For use with Ant Movie Catalog 3.2.1 or greater *
* www.ant.be.tf/moviecatalog ··· www.buypin.com *
***************************************************)
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="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, FullValue, CastValue, ProValue, URL, Ger: string;
LineNr: Integer;
BeginPos, EndPos, URLStart, URLEnd: Integer;
begin
//Original Title & Year
LineNr := FindLine('<TITLE>', Page, 0);
Line := Page.GetString(LineNr);
if LineNr > -1 then
begin
BeginPos := pos('<TITLE>', Line);
if BeginPos > 0 then
BeginPos := BeginPos + 7;
EndPos := pos('(', Line);
if EndPos = 0 then
EndPos := Length(Line);
Value := copy(Line, BeginPos, EndPos - BeginPos - 1);
HTMLDecode(Value);
SetField(fieldOriginalTitle, Value);
BeginPos := pos('(', Line) + 1;
if BeginPos > 0 then
begin
EndPos := pos(')', Line);
Value := copy(Line, BeginPos, EndPos - BeginPos);
SetField(fieldYear, Value);
end;
end;
//URL
LineNr := FindLine('<BASE HREF="', Page, 0);
if LineNr > -1 then
begin
Line := Page.GetString(LineNr);
URLStart := pos('/Title?', Line) + 7;
URLEnd := pos('">', Line);
Value := copy(Line, URLStart, URLEnd - URLStart);
SetField(fieldURL, 'http://german.imdb.com/Title?' + Value);
end;
// Rating
LineNr := FindLine('User Rating:', Page, 0);
if LineNr > -1 then
begin
Line := Page.GetString(LineNr);
BeginPos := pos('<B>', Line) + 3;
Value := IntToStr(Round(StrToInt(StrGet(Line, BeginPos), 0) + (StrToInt(StrGet(Line, BeginPos + 2), 0) / 10)));
SetField(fieldRating, Value);
end;
//Director
LineNr := FindLine('Directed by', Page, 0);
if LineNr > -1 then
begin
FullValue := '';
repeat
LineNr := LineNr + 1;
Line := Page.GetString(LineNr);
BeginPos := pos('">', Line) + 2;
EndPos := pos('</A>', Line);
Value := copy(Line, BeginPos, EndPos - BeginPos);
if (Value <> '(more)') and (Value <> '') then
begin
if FullValue <> '' then
FullValue := FullValue + ', ';
FullValue := FullValue + Value;
end;
until (pos('<BR><BR>', Line) > 0) or (LineNr >= Page.Count-1) or (Line = '<BR>');
HTMLDecode(FullValue);
SetField(fieldDirector, FullValue);
end;
//Actors
LineNr := FindLine('Cast overview', Page, 0);
if LineNr = -1 then
LineNr := FindLine('cast overview', Page, 0);
if LineNr = -1 then
LineNr := FindLine('Complete credited cast', Page, 0);
if LineNr > -1 then
begin
CastValue := '';
repeat
LineNr := LineNr + 1;
Line := Page.GetString(LineNr);
if pos('<TD VALIGN="TOP">', Line) > 0 then
begin
Line := copy(Line, 25, Length(Line));
BeginPos := pos('">', Line) + 2;
EndPos := pos('</A>', Line);
Value := copy(Line, BeginPos, EndPos - BeginPos);
if (Value <> '(more)') and (Value <> '') then
begin
if CastValue <> '' then
CastValue := CastValue + ', ';
CastValue := CastValue + Value;
end;
end else
begin
Line := '';
end;
until Line = '';
HTMLDecode(CastValue);
SetField(fieldActors, CastValue);
end;
//Country
LineNr := FindLine('Country</B>', Page, 0);
if LineNr > -1 then
begin
Line := Page.GetString(LineNr);
BeginPos := pos('/">', Line) + 3;
EndPos := pos('</A>', Line);
Value := copy(Line, BeginPos, EndPos - BeginPos);
HTMLDecode(Value);
SetField(fieldCountry, Value);
end;
//Category
LineNr := FindLine('Genre</B>', Page, 0);
if LineNr > -1 then
begin
Line := Page.GetString(LineNr);
BeginPos := pos('/">', Line) + 3;
EndPos := pos('</A>', Line);
Value := copy(Line, BeginPos, EndPos - BeginPos);
HTMLDecode(Value);
SetField(fieldCategory, Value);
end;
//Description
LineNr := FindLine('Plot Summary:', Page, 0);
if LineNr < 1 then
LineNr := FindLine('Plot Outline:', Page, 0);
if LineNr > -1 then
begin
Line := Page.GetString(LineNr);
BeginPos := pos('</B>', Line) + 4;
EndPos := pos('<A HREF', Line);
if EndPos < 1 then
Line := Line + Page.GetString(LineNr+1);
EndPos := pos('<A HREF', Line);
PickListClear;
Value := copy(Line, BeginPos, EndPos - BeginPos);
HTMLDecode(Value);
PickListAdd(Value);
BeginPos := pos('/Plot?', Line);
EndPos := pos('"> (more)', Line);
Value := copy(Line, BeginPos, EndPos - BeginPos);
GetDescriptions(Value);
Value := '';
if PickListExec('Wähle eine Beschreibung für "' + MovieName + '"', Value) then
SetField(fieldDescription, Value);
end;
//Translated Title
LineNr := FindLine('<BASE HREF="', Page, 0);
if LineNr > -1 then
begin
Line := Page.GetString(LineNr);
URLStart := pos('/Title?', Line) + 7;
URLEnd := pos('">', Line);
URL := copy(Line, URLStart, URLEnd - URLStart);
Page.Text := GetPage('http://german.imdb.com/Title?' + URL);
LineNr := FindLine('Alternativ:', Page, 0);
if LineNr > -1 then
begin
Ger := '';
repeat
LineNr := LineNr + 1;
Line := Page.GetString(LineNr);
if Pos('[de]', Line) or Pos('(Germany)', Line) > 0 then
begin
BeginPos := pos('CLASS="transl">', Line) + 15;
EndPos := pos('[de]', Line) - 18;
Ger := copy(Line, BeginPos, EndPos - BeginPos);
end;
until (pos('</TD></TR>', Line) > 0 );
SetField(fieldTranslatedTitle, Ger);
end;
end;
//Producer
LineNr := FindLine('<BASE HREF="', Page, 0);
if LineNr > -1 then
begin
Line := Page.GetString(LineNr);
URLStart := pos('/Title?', Line) + 7;
URLEnd := pos('">', Line);
URL := copy(Line, URLStart, URLEnd - URLStart);
Page.Text := GetPage('http://us.imdb.com/Details?' + URL);
LineNr := FindLine('Produced by', Page, 0);
if LineNr > -1 then
begin
ProValue := '';
repeat
LineNr := LineNr + 1;
Line := Page.GetString(LineNr);
BeginPos := pos('">', Line) + 2;
EndPos := pos('</A>', Line);
if Pos('executive producer', Line) > 0 then
begin
Value := copy(Line, BeginPos, EndPos - BeginPos);
if (Value <> '(more)') and (Value <> '') then
begin
if ProValue <> '' then
ProValue := ProValue + ', ';
ProValue := ProValue + Value;
end;
end;
until (pos('</TABLE>', Line) > 0 );
HTMLDecode(ProValue);
HTMLRemoveTags(ProValue);
SetField(fieldProducer, ProValue);
end;
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,2,1) then
begin
MovieName := GetField(fieldOriginalTitle);
if MovieName = '' then
MovieName := GetField(fieldTranslatedTitle);
if Input('IMDb Import', 'Geben den Titel des Filmes ein:', 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('Dieses Script benötigt eine neuere Version des Ant Movie Catalog (Version 3.2.1 oder höher)');
end.
http://badjoker.cdaweb.de/IMDB_(DE).ifs
maybe antoine will add it into the next release
so here is now my problem:
when adding the german title, i reads the full title from the html source from:
CLASS="transl"> to [de]
the title in the browser looks like that:
"Faculty - Trau keinem Lehrer (1999) (Germany) [de]"
after that i kill the rest, but it must look like that, because i only subtract 18 chars if the title looks like that, it won't work properly:
"Conan, der Zerstörer (1984) (West Germany) [de]"
can anyone tell me, how i can not subtract but can kill the "(1984) (West Germany) [de]" part?
there must be a way to kill it instead of only substract, it's just all in () and the [de] after the title
feedback would be nice, maybe i did some mistakes, i hate coding and this was the first coding in this language from me