Modified Script 'OFDb - IMDb - mod'
-
- Posts: 17
- Joined: 2011-12-22 21:42:40
Modified Script 'OFDb - IMDb - mod'
Hi,
I modified the script 'OFDb - IMDb - mod'. New name for the script should be 'OFDb - IMDb - TMDb - mod'.
I added the query for TMDb to get the Picture.
The User-Review from OFDb can be imported to the Comments.
I changed the User-Rating query, too.
(***************************************************
Ant Movie Catalog importation script
www.antp.be/software/moviecatalog/
[Infos]
Authors=Fabian Filipczyk<FFJaro@gmx.de>, Bad Joker<badjoker@gmx.de>, VisualMAx<visualmax@gmail.com>, U. Pollaehne<u.pollaehne@web.de>, gerol, Crap_Inhuman<crap_inhuman@hotmail.com>
Title=OFDb - IMDb - TMDb - mod
Description=Combined OFDb / IMDb (DE + COM)| / TMDb Picture from TMDb or OFDb | German Title and Description from OFDb|All other from IMDb (DE + COM)
Site=www.ofdb.de
Language=DE,EN
Version=1.8.2
Requires=3.5.0
Comments=Import from Online-Filmdatenbank (OFDb) http://www.ofdb.de|and Internet Movie Database (IMDb) http:www.imdb.com||Import Picture from TMDb (Need api Key from www.themoviedb.org)|The api key need to store in the script (Search the script for 'Enter here the api key')
License=This program is free software; you can redistribute it and/or modify it under the|terms of the GNU General Public License as published by the Free Software Foundation;|either version 2 of the License, or (at your option) any later version.
GetInfo=1
[Options]
AllFromOFDB=0|0|0=Import most Values from IMDB (default)|1=Import all Values from OFDB
CommentContent=0|0|0=Import from OFDb/IMDb User Reviews (default)|1=Import from IMDb User Review only
ActorsLayout=0|0|0=Separate actors by comma (default)|1=Separate actors by slash|2=Separate actors by linebreak
DirectorsLayout=0|0|0=Separate directors by comma (default)|1=Separate directors by slash
ProducersLayout=0|0|0=Separate producers by comma (default)|1=Separate producers by slash
LanguageLayout=0|0|0=Separate languages by comma (default)|1=Separate languages by slash
CountryLayout=0|0|0=Separate countries by comma (default)|1=Separate countries by slash
CategoryLayout=0|0|0=Separate categories by comma (default)|1=Separate categories by slash
AudioFormatLayout=0|0|0=Separate Audio-Format by comma (default)|1=Separate Audio-Format by slash
AspectRatio=0|0|0=don't import Aspect Ratio (default)|1=Import Aspect Ratio to resolution field|2=Import Aspect Ratio to video format field
Audio=0|0|0=don't import Sound Mix (Tonverfahren) (default)|1=Import Sound Mix (Tonverfahren) to audio format field
FSK=0|0|0=don't import certification (Altersfreigabe) (default)|1=Add certification (Altersfreigabe) to description field|2=Import certification (Altersfreigabe) to comments field
DescriptionContent=0|0|0=Import from OFDb/IMDb Description (default)|1=Import only from OFDb Description
PictureImport=1|0|0=Get Picture from OFDb (default)|1=Get Picture from TMDb - if not found get it from OFDb
***************************************************)
(***************************************************
* *
* (c) 2002 Fabian Filipczyk FFJaro@gmx.de *
* *
* @2003 *
* Overworked by Bad Joker badjoker@gmx.de *
* *
* @16.10.2004 *
* Modified by VisualMAx (at)gmail.com *
* *
* @19.12.2004 *
* Modified by u.pollaehne (at)web.de *
* *
* @08.01.2006 *
* Modified by Bad Joker badjoker@gmx.de *
* *
* @2008 *
* Modified by bad4u and gerol *
* *
* @2009, 2010, 2011 *
* Modified by gerol *
* *
* 18.12.2011 crap_inhuman *
* User-Rating Abfrage korrigiert *
* User-Review von OFDb wird in *
* Comments eingefügt *
* *
* 19.12.2011 crap_inhuman *
* TheMovieDB.org wird nach Bildern abgefragt *
* *
* *
***************************************************)
var
IMDb, MovieName, IMDbURL, GerIMDbDURL, GerIMDbDURLMain: string;
ActorsSeparator, DirectorsSeparator, ProducersSeparator, CountriesSeparator, LanguagesSeparator, CategoriesSeparator, AudioFormatSeparator: string;
ImdbFound: boolean;
procedure SetSeparators;
begin
case GetOption('ActorsLayout') of
0: ActorsSeparator := ', ';
1: ActorsSeparator := ' / ';
end;
case GetOption('DirectorsLayout') of
0: DirectorsSeparator := ', ';
1: DirectorsSeparator := ' / ';
end;
case GetOption('ProducersLayout') of
0: ProducersSeparator := ', ';
1: ProducersSeparator := ' / ';
end;
case GetOption('CountryLayout') of
0: CountriesSeparator := ', ';
1: CountriesSeparator := ' / ';
end;
case GetOption('LanguageLayout') of
0: LanguagesSeparator := ', ';
1: LanguagesSeparator := ' / ';
end;
case GetOption('CategoryLayout') of
0: CategoriesSeparator := ', ';
1: CategoriesSeparator := ' / ';
end;
case GetOption('AudioFormatLayout') of
0: AudioFormatSeparator := ', ';
1: AudioFormatSeparator := ' / ';
end;
end;
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 AnalysePicPage(Address: string);
var
URL, Token, APIKey, Value, NewURL, Line: string;
Page: TStringList;
StartPos, BeginPos, EndPos, LineNr: Integer;
begin
if GetOption('PictureImport') = 1 then
begin
(* Enter here the api key !!!! *)
APIKey := '';
(* Enter here the api key !!!! *)
URL := 'http://api.themoviedb.org/2.1/Auth.getToken/xml/' + APIKey;
Page := TStringList.Create;
Page.Text := GetPage(URL);
LineNr := FindLine('<token>', Page, 0);
Line := Page.GetString(LineNr);
StartPos := pos('<token>', Line);
EndPos := pos('</token>', Line);
Token := copy(Line, Startpos+7, EndPos-StartPos-7);
URL := 'http://api.themoviedb.org/2.1/Auth.getSession/xml/' + APIKey + '/' + Token;
Page := TStringList.Create;
Page.Text := GetPage(URL);
URL := 'http://api.themoviedb.org/2.1/Movie.getImages/en/xml/' + APIKey + '/tt' + IMDb;
Page := TStringList.Create;
Page.Text := GetPage(URL);
LineNr := FindLine('size="original"', Page, 0);
if LineNr > -1 then
begin
Line := Page.GetString(LineNr);
BeginPos := pos('url="', Line) + 5;
if BeginPos > 5 then
begin
EndPos := pos('" size="original"', Line);
Value := copy(Line, BeginPos, EndPos - BeginPos);
GetPicture(Value);
end;
end;
end;
end;
procedure AnalysePage(Address: string);
var
Page: TStringList;
LineNr: Integer;
begin
Page := TStringList.Create;
Page.Text := GetPage(Address);
if pos('<title>OFDb - Suchergebnis', Page.Text) = 0 then
begin
AnalyseOFDBPage(Page);
if not ImdbFound then
ShowMessage('Keine IMDB-Nr. gefunden' + #13#10 + 'Hole Daten von OFDB');
if ImdbFound and (GetOption('AllFromOFDB') = 0) then
begin
AnalyseIMDBDPage(Page);
AnalyseIMDBPage(Page);
AnalysePicPage(IMDb);
end else
begin
SetField(fieldURL, Address);
AnalyseOFDBPageMore(Page);
end;
end else
begin
if FindLine('<b>Titel:</b><br><br><b>•</b> <i>Keine Ergebnisse', Page, 0) > 0 then
begin
if (Pos('das', AnsiLowerCase(MovieName)) = 1) or
(Pos('der', AnsiLowerCase(MovieName)) = 1) or
(Pos('die', AnsiLowerCase(MovieName)) = 1) or
(Pos('ein', AnsiLowerCase(MovieName)) = 1) or
(Pos('eine', AnsiLowerCase(MovieName)) = 1) then
begin
MovieName := Trim(Copy(MovieName, 5, Length(MovieName)));
AnalysePage('http://www.ofdb.de/view.php?page=sucher ... +UrlEncode(UTF8Encode(MovieName))+'&Kat=All');
end else
begin
ShowMessage('Die Suche nach "' + MovieName +'" ergab kein Ergebnis, bitte den Titel ändern.');
if (Input('OFDb IMDb (DE)', 'Bitte einen anderen Titel eingeben :', MovieName)) and (MovieName <> '') then
AnalysePage('http://www.ofdb.de/view.php?page=sucher ... +UrlEncode(UTF8Encode(MovieName))+'&Kat=All');
end;
end else
begin
PickTreeClear;
LineNr := FindLine('<b>Titel:</b>', Page, 0);
if LineNr > 0 then
begin
PickTreeAdd('Suche nach "' + MovieName + '" ergab:', '');
PickTreeMoreLink('dummy');
Address := AddMoviesTitles(Page, LineNr);
if Address = '' then
begin
if PickTreeExec(Address) then
begin
if Address = 'dummy' then
begin
if (Input('Kein passender Titel dabei?', 'Bitte ändern Sie den Titel ab:', MovieName)) and (MovieName <> '') then
AnalysePage('http://www.ofdb.de/view.php?page=sucher ... +UrlEncode(UTF8Encode(MovieName))+'&Kat=All')
end else
AnalysePage(Address);
end;
end else
AnalysePage(Address);
end;
end;
end;
Page.Free;
end;
function AddMoviesTitles(Page: TStringList; var LineNr: Integer) : string;
var
Line: string;
Headline, MovieTitle, MovieTitleCopy, MovieAddress: string;
StartPos, HeadlinePos, EndPos, NumTitles: Integer;
Multi: boolean;
begin
Multi := true;
result := '';
Headline := '';
Line := Page.GetString(LineNr);
NumTitles := 0;
MovieTitleCopy := '';
repeat
StartPos := pos('<a href=''view.php?page=film&fid=', Line);
if StartPos < 1 then
StartPos := Pos('<a href=''film/', Line);
if StartPos < 1 then
begin
StartPos := pos('<a href="view.php?page=film&fid=', Line);
Multi := false;
end;
if StartPos < 1 then
begin
StartPos := Pos('<a href="film/', Line);
Multi := false;
end;
if StartPos > 0 then
begin
HeadlinePos := pos('<br><i>', Line);
if (HeadlinePos > 0) and (HeadlinePos < StartPos) then
begin
Headline := copy(Line, HeadlinePos + 7, Pos('</i><br>', Line) - HeadlinePos - 7);
Headline := UTF8Decode(Headline);
HTMLDecode(Headline);
PickTreeAdd(Headline, '');
end;
Delete(Line, 1, StartPos + 8);
MovieAddress := copy(Line, 1, pos('''>', Line) - 1);
if Multi = false then
MovieAddress := copy(Line, 1, pos('" onmouseover=', Line) - 1);
StartPos := pos('''>', Line) + 2;
if Multi = false then
StartPos := pos('">', Line) + 2;
MovieTitle := copy(Line, StartPos, pos('</a>', Line) - StartPos);
MovieTitle := UTF8Decode(MovieTitle);
HTMLRemoveTags(MovieTitle);
if NumTitles > 0 then
begin
if MovieTitleCopy <> MovieTitle then
begin
PickTreeAdd(MovieTitle, 'http://www.ofdb.de/' + MovieAddress);
NumTitles := NumTitles + 1;
end;
end;
if NumTitles = 0 then
begin
NumTitles := NumTitles + 1;
PickTreeAdd(MovieTitle, 'http://www.ofdb.de/' + MovieAddress);
MovieTitleCopy := MovieTitle;
end;
end;
until (StartPos < 1);
if NumTitles = 1 then
result := 'http://www.ofdb.de/' + MovieAddress;
end;
procedure AnalyseOFDBPage(Page: TStringList);
var
Line, Temp, Value, NewURL: string;
LineNr, BeginPos, EndPos: Integer;
// Get IMDb URL + Set german IMDb URL
begin
LineNr :=Findline('http://www.imdb.com/Title?', Page, 0);
Line := Page.GetString(LineNr);
BeginPos := pos('Title?', Line)+6;
EndPos := pos('" target', Line);
Value := copy(Line, BeginPos, EndPos - BeginPos);
Value := StringReplace(Value, 'tt', '');
NewURL := ('http://www.imdb.de/title/tt' + Value);
SetField(fieldURL, NewURL);
BeginPos := pos('Title?', Line)+6;
EndPos := pos('" target', Line);
Temp := copy(Line, BeginPos, EndPos - BeginPos);
Temp := StringReplace(Temp, 'tt', '');
if Temp <> '' then
ImdbFound := true
else
ImdbFound := false;
GerIMDbDURLMain := ('http://www.imdb.de/title/tt' + Temp + '/');
Value := ('http://www.imdb.de/title/tt' + Temp + '/fullcredits#cast');
GerIMDbDURL := Value;
Value := ('http://www.imdb.com/title/tt' + Temp + '/');
IMDbURL := Value;
IMDb := TEMP;
// Original & Translated Title
LineNr := FindLine('Originaltitel:</font>', Page, 0);
if LineNr > -1 then
begin
LineNr:= LineNr+2;
Line := Page.GetString(LineNr);
BeginPos := pos('class="Daten"><b>', Line) + 17;
EndPos := pos('</b></font>', Line);
Value := copy(Line, BeginPos, EndPos - BeginPos);
Value := UTF8Decode(Value);
SetField(fieldOriginalTitle, Value);
LineNr := Findline('sans-serif" size="3"><b>', Page, 0);
if LineNr > -1 then
begin
Line:= Page.GetString(LineNr);
BeginPos := pos('sans-serif" size="3"><b>',Line) +24;
Endpos := pos('</b></font></h2></td>',Line);
Value := copy(Line,BeginPos, Endpos-Beginpos);
Value := UTF8Decode(Value);
SetField(fieldTranslatedTitle,Value);
end;
end;
// Picture
LineNr := FindLine('<img src="http://img.ofdb.de/film', Page, 0);
if LineNr > -1 then
begin
Line := Page.GetString(LineNr);
BeginPos := pos('<img src="', Line) + 10;
if BeginPos > 10 then
begin
EndPos := pos(' alt=', Line)-1;
Value := copy(Line, BeginPos, EndPos - BeginPos);
GetPicture(Value);
end;
end;
// Description
LineNr := Findline('<b>Inhalt:</b>', Page, 0);
if LineNr > -1 then
begin
LineNr := Findline('<a href="view.php?page=inhalt', Page, 0);
if LineNr > -1 then
begin
Line := Page.GetString(LineNr);
BeginPos := pos('<a href="view.php?page=inhalt', Line)+9;
end else
begin
LineNr := Findline ('<a href="plot/', Page, 0);
Line := Page.GetString(LineNr);
BeginPos := pos('<a href="plot/', Line)+9;
end;
EndPos := pos('"><b>[mehr]', Line);
Value := copy(Line, BeginPos, EndPos - BeginPos);
HTMLRemoveTags(Value);
Value := UTF8Decode(Value);
GetDescriptions(Value);
end;
if CanSetField(fieldComments) then
begin
if GetOption('CommentContent') = 0 then
begin
LineNr := FindLine('Lokale Reviews:', Page, 0);
end;
if LineNr > -1 then
begin
Line := Page.GetString(LineNr);
BeginPos := pos('<a href=', Line)+9;
Line := copy(Line, BeginPos, Length(Line));
EndPos := Pos('">', Line);
Value := copy(Line, 1, EndPos-1);
HTMLRemoveTags(Value);
Value := UTF8Decode(Value);
GetComments(Value);
end;
end;
end;
procedure GetDescriptions(Address: string);
var
Line, Temp, Value: string;
LineNr, BeginPos, EndPos: Integer;
Page: TStringList;
begin
Temp:= '';
Page := TStringList.Create;
Page.Text := GetPage('http://www.ofdb.de/' + Address);
LineNr := FindLine('Eine Inhaltsangabe von', Page, 0);
if LineNr > -1 then
begin
Line := Page.GetString(LineNr);
BeginPos := pos('</b></b><br><br>', Line)+16;
while (pos('<br />', Line) >0) do
begin
EndPos := pos('<br />', Line);
Temp := Temp + copy(Line, BeginPos, EndPos - BeginPos)+#13#10;
LineNr:=LineNr+1;
Line:=Page.GetString(LineNr);
BeginPos:=1;
end;
EndPos := pos('</font></p>', Line);
Temp:= Temp + copy(Line, BeginPos, EndPos - BeginPos);
Value:= Temp;
Value := UTF8Decode(Value);
SetField(fieldDescription, Value);
end;
Page.Free;
end;
procedure GetComments(Address: string);
var
Line, Temp, Value: string;
LineNr, BeginPos, EndPos: Integer;
Page: TStringList;
begin
Temp:= '';
Page := TStringList.Create;
Page.Text := GetPage('http://www.ofdb.de/' + Address);
LineNr := FindLine('Eine Kritik von <a ', Page, 0);
if LineNr > -1 then
begin
LineNr:=LineNr+1;
Line := Page.GetString(LineNr);
BeginPos :=1;
if pos('<p class="Blocksatz">', Line) > 0 then
begin
BeginPos := pos('<p class="Blocksatz">', Line)+21;
end;
while (pos('<br />', Line) >0) do
begin
EndPos := pos('<br />', Line);
Temp := Temp + copy(Line, BeginPos, EndPos - BeginPos)+#13#10;
LineNr:=LineNr+1;
Line:=Page.GetString(LineNr);
BeginPos:=1;
end;
EndPos := pos('</font></p>', Line);
Temp:= Temp + copy(Line, BeginPos, EndPos - BeginPos);
Value:= Temp;
Value := UTF8Decode(Value);
HTMLDecode(Value);
HTMLRemoveTags(Value);
SetField(fieldComments, Value);
end;
Page.Free;
end;
procedure AnalyseIMDBDPage(Page: TStringList);
var
Line, Value, Value2, FullValue, GerTitle, Ger, Temp: string;
BeginPos, EndPos, LineNr, TempPos: Integer;
begin
Page.Text := GetPage(GerIMDbDURL);
// Producers
LineNr := FindLine(' name="producers"', Page, 0);
if LineNr > -1 then
begin
Value := '';
EndPos := 0;
Line := Page.GetString(LineNr);
BeginPos := Pos('>Produktion<', Line);
EndPos := Pos(' name="music_original"', Line);
if EndPos = 0 then
EndPos := Pos(' name="cinematographers"', Line);
Line := copy(Line, BeginPos, EndPos - BeginPos);
BeginPos := pos('/">', Line) + 2;
Delete(Line, 1, BeginPos);
EndPos := pos('</a>', Line);
Value := copy(Line, 1, EndPos - 1);
repeat
Delete(Line, 1, EndPos);
BeginPos := pos('/">', Line) + 3;
if BeginPos > 3 then
begin
EndPos := pos('</a>', Line);
Value := Value + ProducersSeparator + copy(Line, BeginPos, EndPos - BeginPos);
end;
until (Line = '') or (BeginPos = 3);
Value := UTF8Decode(Value);
HTMLDecode(Value);
SetField(fieldProducer, Value);
end;
//Length (get it here, but set it from imdb.com, if possible - see later)
if GetField(fieldLength) = '' then
begin
Page.Text := GetPage(GerIMDbDURLMain);
LineNr := FindLine('<h5>Länge:</h5>', Page, 0);
if LineNr > -1 then
begin
Line := Page.GetString(LineNr);
BeginPos := pos('<h5>Länge:</h5>', Line) + 20;
Delete(Line, 1, BeginPos);
EndPos := pos(' Min', Line);
if EndPos > 0 then
begin
Delete(Line, 1, EndPos - 5);
BeginPos := pos('>', Line) + 1;
EndPos := pos(' Min', Line);
Value := Trim(copy(Line, BeginPos, EndPos - BeginPos));
if Value <> '' then
SetField(fieldLength, Value);
end;
end;
end;
end;
procedure AnalyseIMDBPage(Page: TStringList);
var
Line, Value, Value2, FullValue: string;
BeginPos, EndPos, LineNr: Integer;
begin
// Year
Page.Text := GetPage(IMDbURL);
LineNr := FindLine('<title>', Page, 0);
Line := Page.GetString(LineNr);
if LineNr > -1 then
begin
BeginPos := pos('(', Line) + 1;
if BeginPos > 0 then
begin
EndPos := pos(')', Line);
BeginPos := EndPos - 4;
Value := copy(Line, BeginPos, EndPos - BeginPos);
SetField(fieldYear, Value);
end;
end;
// IMDb Rating
LineNr := FindLine('"ratingValue"', Page, 0);
if LineNr > -1 then
begin
Line := Page.GetString(LineNr);
BeginPos := pos('"ratingValue"', Line) + 14;
EndPos := BeginPos + 3;
Value := copy(Line, BeginPos, EndPos - BeginPos);
SetField(fieldRating, Value);
end;
// Directors
LineNr := FindLine('Directors:', Page, 0);
if LineNr = -1 then
LineNr := FindLine('Director:', Page, 0);
if LineNr > -1 then
begin
Value := '';
repeat
LineNr := FindLine('itemprop="director"', Page, LineNr);
LineNr := LineNr + 1;
Line := Page.GetString(LineNr);
BeginPos := pos('>', Line) + 1;
EndPos := pos('</a>', Line);
If Value <> '' then
Value := Value + DirectorsSeparator;
Value := Value + copy(Line, BeginPos, EndPos - BeginPos);
until FindLine('itemprop="director"', Page, LineNr) = -1;
Value := UTF8Decode(Value);
HTMLDecode(Value);
SetField(fieldDirector, Value);
end;
// Actors
LineNr := FindLine('Cast overview', Page, 0);
if LineNr = -1 then
LineNr := FindLine('cast overview', Page, 0);
if LineNr = -1 then
LineNr := FindLine('redited cast', Page, 0);
if LineNr = -1 then
LineNr := FindLine('cast summary:', Page, 0);
if LineNr > -1 then
begin
FullValue := '';
repeat
Value2 := '';
LineNr := FindLine('<td class="name">', Page, LineNr);
LineNr := LineNr + 2;
Line := Page.GetString(LineNr);
BeginPos := pos('>', Line) + 1;
EndPos := pos('</a>', Line);
Value := copy(Line, BeginPos, EndPos - BeginPos);
LineNr := FindLine('<td class="character">', Page, LineNr);
LineNr := LineNr + 3;
Line := Page.GetString(LineNr);
BeginPos := pos('/">', Line) + 3;
EndPos := pos('</a>', Line);
If BeginPos > 3 then
Value2 := copy(Line, BeginPos, EndPos - BeginPos)
else
Value2 := Trim(Line);
if (Value2 <> '') and (Value2 <> '</td>') then
begin
if Trim(Page.Getstring(LineNr + 1)) = '(voice)' then
Value2 := Value2 + ' (voice)';
Value := Value + ' (als ' + Value2 + ')';
end;
if FullValue <> '' then
if GetOption('ActorsLayout') < 2 then
FullValue := FullValue + ActorsSeparator
else
FullValue := FullValue + #13#10;
FullValue := FullValue + Value;
until FindLine('<td class="name">', Page, LineNr) < 1;
FullValue := UTF8Decode(FullValue);
HTMLRemoveTags(FullValue);
HTMLDecode(FullValue);
SetField(fieldActors, FullValue);
end;
// Length (from imdb.com, if possible)
LineNr := FindLine('Runtime:', Page, 0);
if LineNr > -1 then
begin
Line := Page.GetString(LineNr + 2);
BeginPos := pos('">', Line) + 2;
EndPos := pos(' min', Line);
Line := copy(Line, BeginPos, EndPos - BeginPos);
Line := Trim(Line);
SetField(fieldLength, Line);
end;
// Language
LineNr := FindLine('Language:', Page, 0);
if LineNr > -1 then
begin
Value := '';
repeat
LineNr := FindLine('<a href="/language', Page, LineNr);
Line := Page.GetString(LineNr);
BeginPos := pos('">', Line) + 2;
EndPos := pos('</a>', Line);
If Value <> '' then
Value := Value + LanguagesSeparator;
Value := Value + copy(Line, BeginPos, EndPos - BeginPos);
LineNr := LineNr + 1;
until FindLine('<a href="/language', Page, LineNr) < 1;
Value := UTF8Decode(Value);
HTMLDecode(Value);
SetField(fieldLanguages, Value);
end;
// Countries
LineNr := FindLine('Country:', Page, 0);
if LineNr > -1 then
begin
Value := '';
repeat
LineNr := FindLine('<a href="/country', Page, LineNr);
Line := Page.GetString(LineNr);
BeginPos := pos('" >', Line) + 3;
EndPos := pos('</a>', Line);
If Value <> '' then
Value := Value + CountriesSeparator;
Value := Value + copy(Line, BeginPos, EndPos - BeginPos);
LineNr := LineNr + 1;
until FindLine('<a href="/country', Page, LineNr) < 1;
Value := UTF8Decode(Value);
HTMLDecode(Value);
SetField(fieldCountry, Value);
end;
// Categories
LineNr := FindLine('Genres:', Page, 0);
if LineNr > -1 then
begin
LineNr := FindLine('<a href="/genre', Page, LineNr);
Line := Page.GetString(LineNr);
BeginPos := pos('">', Line) + 2;
EndPos := pos('</a>', Line);
Value := copy(Line, BeginPos, EndPos - BeginPos);
repeat
Delete(Line, 1, EndPos);
BeginPos := pos('">', Line) + 2;
if BeginPos > 2 then
begin
EndPos := pos('</a>', Line);
Value := Value + CategoriesSeparator + copy(Line, BeginPos, EndPos - BeginPos);
end;
until (Line = '') or (BeginPos = 2);
Value := UTF8Decode(Value);
HTMLDecode(Value);
SetField(fieldCategory, Value);
end;
//AspectRatio
if GetOption('AspectRatio') > 0 then
begin
LineNr := FindLine('Aspect Ratio:', Page, 0);
if LineNr > -1 then
begin
Line := Page.GetString(LineNr);
BeginPos := pos('Aspect Ratio:', Line) + 19;
Line := copy(Line, BeginPos , Length(Line) - BeginPos + 2);
if (CanSetField(fieldResolution)) and (GetOption('AspectRatio') = 1) then
SetField(fieldResolution, Line);
if (CanSetField(fieldVideoFormat)) and (GetOption('AspectRatio') = 2) then
SetField(fieldVideoFormat, Line);
end;
end;
//Audio
if GetOption('Audio') > 0 then
begin
Value := '';
LineNr := FindLine('Sound Mix:', Page, 0);
if LineNr > -1 then
begin
Line := Page.GetString(LineNr);
repeat
Delete(Line, 1, pos('<a href="/search', Line));
BeginPos := pos('">', Line) + 2;
if BeginPos > 2 then
begin
EndPos := pos('</a>', Line);
if Value <> '' then
Value := Value + AudioFormatSeparator;
Value := Value + copy(Line, BeginPos, EndPos - BeginPos);
end;
until pos('<a href="/search', Line) < 1;
if CanSetField(fieldAudioFormat) then
SetField(fieldAudioFormat, Value);
end;
end;
// Comments
Value := '';
if CanSetField(fieldComments) then
begin
LineNr := FindLine('href="usercomments"', Page, 0);
if LineNr > -1 then
begin
Page.Text := GetPage(IMDbURL + 'usercomments');
LineNr := FindLine('<a href="/user/', Page, 0);
if LineNr > -1 then
begin
LineNr := FindLine('<p>', Page, LineNr);
if LineNr > -1 then
begin
LineNr := LineNr + 1;
repeat
Line := Page.GetString(LineNr);
Value := Value + Line + ' ';
LineNr := LineNr + 1;
until pos('</p>', Line) > 0;
LineNr := FindLine('<a href="/user/', Page, 0);
Line := Page.GetString(LineNr);
BeginPos := pos('/comments">', Line) + 11;
EndPos := pos('</a>', Line);
Value := Value + ' by ' + copy(Line, BeginPos, EndPos - BeginPos);
end;
end;
Value := UTF8Decode(Value);
HTMLDecode(Value);
HTMLRemoveTags(Value);
SetField(fieldComments, Value);
end;
end;
if GetOption('DescriptionContent') = 0 then
begin
if GetField(fieldDescription) = '' then
begin
LineNr := FindLine('<a href="plotsummary">', Page, 0);
if LineNr > -1 then
begin
Page.Text := GetPage(IMDbURL + 'plotsummary');
LineNr := FindLine('<p class="plotpar">', Page, 0);
if LineNr > -1 then
begin
LineNr := LineNr -1;
Value := '';
repeat
LineNr := FindLine('<p class="plotpar">', Page, LineNr);
LineNr := LineNr + 1;
Line := Page.GetString(LineNr + 3);
BeginPos := pos('">', Line) + 2;
EndPos := pos('</a>', Line);
Value2 := copy(Line, BeginPos, EndPos - BeginPos);
Value := Value + Page.GetString(LineNr) + ' - Written by ' + Value2 + #13#10 + #13#10;
until FindLine('<p class="plotpar">', Page, LineNr) < 1;
end;
Value := UTF8Decode(Value);
HTMLDecode(Value);
HTMLRemoveTags(Value);
SetField(fieldComments, Value);
end;
end;
end;
//FSK
if GetOption('FSK') > 0 then
begin
Page.Text := GetPage(IMDbURL + 'parentalguide#certification');
LineNr := FindLine('Certification:', Page, 0) + 2;
Line := Page.GetString(LineNr);
BeginPos := pos('Certification:', Line);
Line := copy(Line, BeginPos, Length(Line));
BeginPos := pos('Germany:', Line) + 8;
if BeginPos = 8 then
begin
BeginPos := pos('West Germany:', Line) + 13;
if BeginPos = 13 then
BeginPos := 0;
end;
if BeginPos > 0 then
begin
Line := copy(Line, BeginPos, Length(Line));
EndPos := pos('</a>', Line) - 1;
Value := copy(Line, 1, EndPos);
If Value = 'o.Al.' then
Value := 'Ohne Altersbeschränkung';
if (CanSetField(fieldDescription)) and (GetOption('FSK') = 1) then
begin
Value := 'FSK: ' + (Value + #13#10 + GetField(fieldDescription));
SetField(fieldDescription, Value);
end;
if (CanSetField(fieldComments)) and (GetOption('FSK') = 2) then
begin
Value := 'FSK: ' + Value;
SetField(fieldComments, Value);
end;
end;
end;
end;
// this procedure only, if no IMDB-Nr. is found or AllFromOFDB-Option is set to 1
procedure AnalyseOFDBPageMore(Page: TStringList);
var
Line, Temp, Value: string;
LineNr, BeginPos, EndPos: Integer;
begin
// Country
LineNr := FindLine('Herstellungsland:', Page, 0);
if LineNr > -1 then
begin
LineNr := LineNr + 2;
Line := Page.GetString(LineNr);
Delete(Line, 1, pos('<a href="', Line));
BeginPos := pos('">', Line) + 2;
EndPos := pos('</a>', Line);
Value := copy(Line, BeginPos, EndPos - BeginPos);
Value := UTF8Decode(Value);
if Value <> '' then
SetField(fieldCountry, Value);
end;
// Year
LineNr := FindLine('Erscheinungsjahr:', Page, 0);
if LineNr > -1 then
begin
LineNr := LineNr + 2;
Line := Page.GetString(LineNr);
Delete(Line, 1, pos('<a href="', Line));
BeginPos := pos('">', Line) + 2;
EndPos := pos('</a>', Line);
Value := copy(Line, BeginPos, EndPos - BeginPos);
Value := UTF8Decode(Value);
if Value <> '' then
SetField(fieldYear, Value);
end;
// Directors
LineNr := FindLine('Regie:', Page, 0);
if LineNr > -1 then
begin
Value := '';
LineNr := LineNr + 2;
Line := Page.GetString(LineNr);
repeat
Delete(Line, 1, pos('<a href="', Line));
BeginPos := pos('">', Line) + 2;
if BeginPos > 2 then
begin
EndPos := pos('</a>', Line);
if Value <> '' then
Value := Value + DirectorsSeparator;
Value := Value + copy(Line, BeginPos, EndPos - BeginPos);
end;
until pos('<a href="', Line) < 1;
Value := UTF8Decode(Value);
if Value <> '' then
SetField(fieldDirector, Value);
end;
// Actors
LineNr := FindLine('Darsteller:', Page, 0);
if LineNr > -1 then
begin
Value := '';
LineNr := LineNr + 2;
Line := Page.GetString(LineNr);
repeat
Delete(Line, 1, pos('<a href="', Line));
BeginPos := pos('">', Line) + 2;
if BeginPos > 2 then
begin
EndPos := pos('</a>', Line);
Temp := copy(Line, BeginPos, EndPos - BeginPos);
if temp <> '[mehr]' then
begin
if Value <> '' then
Value := Value + ActorsSeparator;
Value := Value + Temp;
end;
end;
until pos('<a href="', Line) < 1;
Value := UTF8Decode(Value);
if Value <> '' then
SetField(fieldActors, Value);
end;
// Categories
LineNr := FindLine('Genre(s):', Page, 0);
if LineNr > -1 then
begin
Value := '';
LineNr := LineNr + 2;
Line := Page.GetString(LineNr);
repeat
Delete(Line, 1, pos('<a href="', Line));
BeginPos := pos('">', Line) + 2;
if BeginPos > 2 then
begin
EndPos := pos('</a>', Line);
if Value <> '' then
Value := Value + CategoriesSeparator;
Value := Value + copy(Line, BeginPos, EndPos - BeginPos);
end;
until pos('<a href="', Line) < 1;
Value := UTF8Decode(Value);
if Value <> '' then
SetField(fieldCategory, Value);
end;
// Rating
LineNr := FindLine('Note:', Page, 0);
if LineNr > -1 then
begin
Line := Page.GetString(LineNr);
BeginPos := pos('Note: ', Line) + 6;
EndPos := pos(' ', Line);
Value := copy(Line, BeginPos, EndPos - BeginPos);
Value := UTF8Decode(Value);
if Value <> '' then
SetField(fieldRating, Value);
end;
end;
begin
if CheckVersion(3,5,0) then
begin
MovieName := GetField(fieldTranslatedTitle);
if MovieName = '' then
MovieName := GetField(fieldOriginalTitle);
if MovieName = '' then
Input('OFDb', 'Bitte Titel eingeben :', MovieName);
SetSeparators;
AnalysePage('http://www.ofdb.de/view.php?page=sucher ... ingReplace(UrlEncode(UTF8Encode(MovieName)),'&%','%26%'));
end
else
ShowMessage('Dieses Script benötigt eine neuere Version von Ant Movie Catalog (mindestens Version 3.5.0)');
end.
I modified the script 'OFDb - IMDb - mod'. New name for the script should be 'OFDb - IMDb - TMDb - mod'.
I added the query for TMDb to get the Picture.
The User-Review from OFDb can be imported to the Comments.
I changed the User-Rating query, too.
(***************************************************
Ant Movie Catalog importation script
www.antp.be/software/moviecatalog/
[Infos]
Authors=Fabian Filipczyk<FFJaro@gmx.de>, Bad Joker<badjoker@gmx.de>, VisualMAx<visualmax@gmail.com>, U. Pollaehne<u.pollaehne@web.de>, gerol, Crap_Inhuman<crap_inhuman@hotmail.com>
Title=OFDb - IMDb - TMDb - mod
Description=Combined OFDb / IMDb (DE + COM)| / TMDb Picture from TMDb or OFDb | German Title and Description from OFDb|All other from IMDb (DE + COM)
Site=www.ofdb.de
Language=DE,EN
Version=1.8.2
Requires=3.5.0
Comments=Import from Online-Filmdatenbank (OFDb) http://www.ofdb.de|and Internet Movie Database (IMDb) http:www.imdb.com||Import Picture from TMDb (Need api Key from www.themoviedb.org)|The api key need to store in the script (Search the script for 'Enter here the api key')
License=This program is free software; you can redistribute it and/or modify it under the|terms of the GNU General Public License as published by the Free Software Foundation;|either version 2 of the License, or (at your option) any later version.
GetInfo=1
[Options]
AllFromOFDB=0|0|0=Import most Values from IMDB (default)|1=Import all Values from OFDB
CommentContent=0|0|0=Import from OFDb/IMDb User Reviews (default)|1=Import from IMDb User Review only
ActorsLayout=0|0|0=Separate actors by comma (default)|1=Separate actors by slash|2=Separate actors by linebreak
DirectorsLayout=0|0|0=Separate directors by comma (default)|1=Separate directors by slash
ProducersLayout=0|0|0=Separate producers by comma (default)|1=Separate producers by slash
LanguageLayout=0|0|0=Separate languages by comma (default)|1=Separate languages by slash
CountryLayout=0|0|0=Separate countries by comma (default)|1=Separate countries by slash
CategoryLayout=0|0|0=Separate categories by comma (default)|1=Separate categories by slash
AudioFormatLayout=0|0|0=Separate Audio-Format by comma (default)|1=Separate Audio-Format by slash
AspectRatio=0|0|0=don't import Aspect Ratio (default)|1=Import Aspect Ratio to resolution field|2=Import Aspect Ratio to video format field
Audio=0|0|0=don't import Sound Mix (Tonverfahren) (default)|1=Import Sound Mix (Tonverfahren) to audio format field
FSK=0|0|0=don't import certification (Altersfreigabe) (default)|1=Add certification (Altersfreigabe) to description field|2=Import certification (Altersfreigabe) to comments field
DescriptionContent=0|0|0=Import from OFDb/IMDb Description (default)|1=Import only from OFDb Description
PictureImport=1|0|0=Get Picture from OFDb (default)|1=Get Picture from TMDb - if not found get it from OFDb
***************************************************)
(***************************************************
* *
* (c) 2002 Fabian Filipczyk FFJaro@gmx.de *
* *
* @2003 *
* Overworked by Bad Joker badjoker@gmx.de *
* *
* @16.10.2004 *
* Modified by VisualMAx (at)gmail.com *
* *
* @19.12.2004 *
* Modified by u.pollaehne (at)web.de *
* *
* @08.01.2006 *
* Modified by Bad Joker badjoker@gmx.de *
* *
* @2008 *
* Modified by bad4u and gerol *
* *
* @2009, 2010, 2011 *
* Modified by gerol *
* *
* 18.12.2011 crap_inhuman *
* User-Rating Abfrage korrigiert *
* User-Review von OFDb wird in *
* Comments eingefügt *
* *
* 19.12.2011 crap_inhuman *
* TheMovieDB.org wird nach Bildern abgefragt *
* *
* *
***************************************************)
var
IMDb, MovieName, IMDbURL, GerIMDbDURL, GerIMDbDURLMain: string;
ActorsSeparator, DirectorsSeparator, ProducersSeparator, CountriesSeparator, LanguagesSeparator, CategoriesSeparator, AudioFormatSeparator: string;
ImdbFound: boolean;
procedure SetSeparators;
begin
case GetOption('ActorsLayout') of
0: ActorsSeparator := ', ';
1: ActorsSeparator := ' / ';
end;
case GetOption('DirectorsLayout') of
0: DirectorsSeparator := ', ';
1: DirectorsSeparator := ' / ';
end;
case GetOption('ProducersLayout') of
0: ProducersSeparator := ', ';
1: ProducersSeparator := ' / ';
end;
case GetOption('CountryLayout') of
0: CountriesSeparator := ', ';
1: CountriesSeparator := ' / ';
end;
case GetOption('LanguageLayout') of
0: LanguagesSeparator := ', ';
1: LanguagesSeparator := ' / ';
end;
case GetOption('CategoryLayout') of
0: CategoriesSeparator := ', ';
1: CategoriesSeparator := ' / ';
end;
case GetOption('AudioFormatLayout') of
0: AudioFormatSeparator := ', ';
1: AudioFormatSeparator := ' / ';
end;
end;
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 AnalysePicPage(Address: string);
var
URL, Token, APIKey, Value, NewURL, Line: string;
Page: TStringList;
StartPos, BeginPos, EndPos, LineNr: Integer;
begin
if GetOption('PictureImport') = 1 then
begin
(* Enter here the api key !!!! *)
APIKey := '';
(* Enter here the api key !!!! *)
URL := 'http://api.themoviedb.org/2.1/Auth.getToken/xml/' + APIKey;
Page := TStringList.Create;
Page.Text := GetPage(URL);
LineNr := FindLine('<token>', Page, 0);
Line := Page.GetString(LineNr);
StartPos := pos('<token>', Line);
EndPos := pos('</token>', Line);
Token := copy(Line, Startpos+7, EndPos-StartPos-7);
URL := 'http://api.themoviedb.org/2.1/Auth.getSession/xml/' + APIKey + '/' + Token;
Page := TStringList.Create;
Page.Text := GetPage(URL);
URL := 'http://api.themoviedb.org/2.1/Movie.getImages/en/xml/' + APIKey + '/tt' + IMDb;
Page := TStringList.Create;
Page.Text := GetPage(URL);
LineNr := FindLine('size="original"', Page, 0);
if LineNr > -1 then
begin
Line := Page.GetString(LineNr);
BeginPos := pos('url="', Line) + 5;
if BeginPos > 5 then
begin
EndPos := pos('" size="original"', Line);
Value := copy(Line, BeginPos, EndPos - BeginPos);
GetPicture(Value);
end;
end;
end;
end;
procedure AnalysePage(Address: string);
var
Page: TStringList;
LineNr: Integer;
begin
Page := TStringList.Create;
Page.Text := GetPage(Address);
if pos('<title>OFDb - Suchergebnis', Page.Text) = 0 then
begin
AnalyseOFDBPage(Page);
if not ImdbFound then
ShowMessage('Keine IMDB-Nr. gefunden' + #13#10 + 'Hole Daten von OFDB');
if ImdbFound and (GetOption('AllFromOFDB') = 0) then
begin
AnalyseIMDBDPage(Page);
AnalyseIMDBPage(Page);
AnalysePicPage(IMDb);
end else
begin
SetField(fieldURL, Address);
AnalyseOFDBPageMore(Page);
end;
end else
begin
if FindLine('<b>Titel:</b><br><br><b>•</b> <i>Keine Ergebnisse', Page, 0) > 0 then
begin
if (Pos('das', AnsiLowerCase(MovieName)) = 1) or
(Pos('der', AnsiLowerCase(MovieName)) = 1) or
(Pos('die', AnsiLowerCase(MovieName)) = 1) or
(Pos('ein', AnsiLowerCase(MovieName)) = 1) or
(Pos('eine', AnsiLowerCase(MovieName)) = 1) then
begin
MovieName := Trim(Copy(MovieName, 5, Length(MovieName)));
AnalysePage('http://www.ofdb.de/view.php?page=sucher ... +UrlEncode(UTF8Encode(MovieName))+'&Kat=All');
end else
begin
ShowMessage('Die Suche nach "' + MovieName +'" ergab kein Ergebnis, bitte den Titel ändern.');
if (Input('OFDb IMDb (DE)', 'Bitte einen anderen Titel eingeben :', MovieName)) and (MovieName <> '') then
AnalysePage('http://www.ofdb.de/view.php?page=sucher ... +UrlEncode(UTF8Encode(MovieName))+'&Kat=All');
end;
end else
begin
PickTreeClear;
LineNr := FindLine('<b>Titel:</b>', Page, 0);
if LineNr > 0 then
begin
PickTreeAdd('Suche nach "' + MovieName + '" ergab:', '');
PickTreeMoreLink('dummy');
Address := AddMoviesTitles(Page, LineNr);
if Address = '' then
begin
if PickTreeExec(Address) then
begin
if Address = 'dummy' then
begin
if (Input('Kein passender Titel dabei?', 'Bitte ändern Sie den Titel ab:', MovieName)) and (MovieName <> '') then
AnalysePage('http://www.ofdb.de/view.php?page=sucher ... +UrlEncode(UTF8Encode(MovieName))+'&Kat=All')
end else
AnalysePage(Address);
end;
end else
AnalysePage(Address);
end;
end;
end;
Page.Free;
end;
function AddMoviesTitles(Page: TStringList; var LineNr: Integer) : string;
var
Line: string;
Headline, MovieTitle, MovieTitleCopy, MovieAddress: string;
StartPos, HeadlinePos, EndPos, NumTitles: Integer;
Multi: boolean;
begin
Multi := true;
result := '';
Headline := '';
Line := Page.GetString(LineNr);
NumTitles := 0;
MovieTitleCopy := '';
repeat
StartPos := pos('<a href=''view.php?page=film&fid=', Line);
if StartPos < 1 then
StartPos := Pos('<a href=''film/', Line);
if StartPos < 1 then
begin
StartPos := pos('<a href="view.php?page=film&fid=', Line);
Multi := false;
end;
if StartPos < 1 then
begin
StartPos := Pos('<a href="film/', Line);
Multi := false;
end;
if StartPos > 0 then
begin
HeadlinePos := pos('<br><i>', Line);
if (HeadlinePos > 0) and (HeadlinePos < StartPos) then
begin
Headline := copy(Line, HeadlinePos + 7, Pos('</i><br>', Line) - HeadlinePos - 7);
Headline := UTF8Decode(Headline);
HTMLDecode(Headline);
PickTreeAdd(Headline, '');
end;
Delete(Line, 1, StartPos + 8);
MovieAddress := copy(Line, 1, pos('''>', Line) - 1);
if Multi = false then
MovieAddress := copy(Line, 1, pos('" onmouseover=', Line) - 1);
StartPos := pos('''>', Line) + 2;
if Multi = false then
StartPos := pos('">', Line) + 2;
MovieTitle := copy(Line, StartPos, pos('</a>', Line) - StartPos);
MovieTitle := UTF8Decode(MovieTitle);
HTMLRemoveTags(MovieTitle);
if NumTitles > 0 then
begin
if MovieTitleCopy <> MovieTitle then
begin
PickTreeAdd(MovieTitle, 'http://www.ofdb.de/' + MovieAddress);
NumTitles := NumTitles + 1;
end;
end;
if NumTitles = 0 then
begin
NumTitles := NumTitles + 1;
PickTreeAdd(MovieTitle, 'http://www.ofdb.de/' + MovieAddress);
MovieTitleCopy := MovieTitle;
end;
end;
until (StartPos < 1);
if NumTitles = 1 then
result := 'http://www.ofdb.de/' + MovieAddress;
end;
procedure AnalyseOFDBPage(Page: TStringList);
var
Line, Temp, Value, NewURL: string;
LineNr, BeginPos, EndPos: Integer;
// Get IMDb URL + Set german IMDb URL
begin
LineNr :=Findline('http://www.imdb.com/Title?', Page, 0);
Line := Page.GetString(LineNr);
BeginPos := pos('Title?', Line)+6;
EndPos := pos('" target', Line);
Value := copy(Line, BeginPos, EndPos - BeginPos);
Value := StringReplace(Value, 'tt', '');
NewURL := ('http://www.imdb.de/title/tt' + Value);
SetField(fieldURL, NewURL);
BeginPos := pos('Title?', Line)+6;
EndPos := pos('" target', Line);
Temp := copy(Line, BeginPos, EndPos - BeginPos);
Temp := StringReplace(Temp, 'tt', '');
if Temp <> '' then
ImdbFound := true
else
ImdbFound := false;
GerIMDbDURLMain := ('http://www.imdb.de/title/tt' + Temp + '/');
Value := ('http://www.imdb.de/title/tt' + Temp + '/fullcredits#cast');
GerIMDbDURL := Value;
Value := ('http://www.imdb.com/title/tt' + Temp + '/');
IMDbURL := Value;
IMDb := TEMP;
// Original & Translated Title
LineNr := FindLine('Originaltitel:</font>', Page, 0);
if LineNr > -1 then
begin
LineNr:= LineNr+2;
Line := Page.GetString(LineNr);
BeginPos := pos('class="Daten"><b>', Line) + 17;
EndPos := pos('</b></font>', Line);
Value := copy(Line, BeginPos, EndPos - BeginPos);
Value := UTF8Decode(Value);
SetField(fieldOriginalTitle, Value);
LineNr := Findline('sans-serif" size="3"><b>', Page, 0);
if LineNr > -1 then
begin
Line:= Page.GetString(LineNr);
BeginPos := pos('sans-serif" size="3"><b>',Line) +24;
Endpos := pos('</b></font></h2></td>',Line);
Value := copy(Line,BeginPos, Endpos-Beginpos);
Value := UTF8Decode(Value);
SetField(fieldTranslatedTitle,Value);
end;
end;
// Picture
LineNr := FindLine('<img src="http://img.ofdb.de/film', Page, 0);
if LineNr > -1 then
begin
Line := Page.GetString(LineNr);
BeginPos := pos('<img src="', Line) + 10;
if BeginPos > 10 then
begin
EndPos := pos(' alt=', Line)-1;
Value := copy(Line, BeginPos, EndPos - BeginPos);
GetPicture(Value);
end;
end;
// Description
LineNr := Findline('<b>Inhalt:</b>', Page, 0);
if LineNr > -1 then
begin
LineNr := Findline('<a href="view.php?page=inhalt', Page, 0);
if LineNr > -1 then
begin
Line := Page.GetString(LineNr);
BeginPos := pos('<a href="view.php?page=inhalt', Line)+9;
end else
begin
LineNr := Findline ('<a href="plot/', Page, 0);
Line := Page.GetString(LineNr);
BeginPos := pos('<a href="plot/', Line)+9;
end;
EndPos := pos('"><b>[mehr]', Line);
Value := copy(Line, BeginPos, EndPos - BeginPos);
HTMLRemoveTags(Value);
Value := UTF8Decode(Value);
GetDescriptions(Value);
end;
if CanSetField(fieldComments) then
begin
if GetOption('CommentContent') = 0 then
begin
LineNr := FindLine('Lokale Reviews:', Page, 0);
end;
if LineNr > -1 then
begin
Line := Page.GetString(LineNr);
BeginPos := pos('<a href=', Line)+9;
Line := copy(Line, BeginPos, Length(Line));
EndPos := Pos('">', Line);
Value := copy(Line, 1, EndPos-1);
HTMLRemoveTags(Value);
Value := UTF8Decode(Value);
GetComments(Value);
end;
end;
end;
procedure GetDescriptions(Address: string);
var
Line, Temp, Value: string;
LineNr, BeginPos, EndPos: Integer;
Page: TStringList;
begin
Temp:= '';
Page := TStringList.Create;
Page.Text := GetPage('http://www.ofdb.de/' + Address);
LineNr := FindLine('Eine Inhaltsangabe von', Page, 0);
if LineNr > -1 then
begin
Line := Page.GetString(LineNr);
BeginPos := pos('</b></b><br><br>', Line)+16;
while (pos('<br />', Line) >0) do
begin
EndPos := pos('<br />', Line);
Temp := Temp + copy(Line, BeginPos, EndPos - BeginPos)+#13#10;
LineNr:=LineNr+1;
Line:=Page.GetString(LineNr);
BeginPos:=1;
end;
EndPos := pos('</font></p>', Line);
Temp:= Temp + copy(Line, BeginPos, EndPos - BeginPos);
Value:= Temp;
Value := UTF8Decode(Value);
SetField(fieldDescription, Value);
end;
Page.Free;
end;
procedure GetComments(Address: string);
var
Line, Temp, Value: string;
LineNr, BeginPos, EndPos: Integer;
Page: TStringList;
begin
Temp:= '';
Page := TStringList.Create;
Page.Text := GetPage('http://www.ofdb.de/' + Address);
LineNr := FindLine('Eine Kritik von <a ', Page, 0);
if LineNr > -1 then
begin
LineNr:=LineNr+1;
Line := Page.GetString(LineNr);
BeginPos :=1;
if pos('<p class="Blocksatz">', Line) > 0 then
begin
BeginPos := pos('<p class="Blocksatz">', Line)+21;
end;
while (pos('<br />', Line) >0) do
begin
EndPos := pos('<br />', Line);
Temp := Temp + copy(Line, BeginPos, EndPos - BeginPos)+#13#10;
LineNr:=LineNr+1;
Line:=Page.GetString(LineNr);
BeginPos:=1;
end;
EndPos := pos('</font></p>', Line);
Temp:= Temp + copy(Line, BeginPos, EndPos - BeginPos);
Value:= Temp;
Value := UTF8Decode(Value);
HTMLDecode(Value);
HTMLRemoveTags(Value);
SetField(fieldComments, Value);
end;
Page.Free;
end;
procedure AnalyseIMDBDPage(Page: TStringList);
var
Line, Value, Value2, FullValue, GerTitle, Ger, Temp: string;
BeginPos, EndPos, LineNr, TempPos: Integer;
begin
Page.Text := GetPage(GerIMDbDURL);
// Producers
LineNr := FindLine(' name="producers"', Page, 0);
if LineNr > -1 then
begin
Value := '';
EndPos := 0;
Line := Page.GetString(LineNr);
BeginPos := Pos('>Produktion<', Line);
EndPos := Pos(' name="music_original"', Line);
if EndPos = 0 then
EndPos := Pos(' name="cinematographers"', Line);
Line := copy(Line, BeginPos, EndPos - BeginPos);
BeginPos := pos('/">', Line) + 2;
Delete(Line, 1, BeginPos);
EndPos := pos('</a>', Line);
Value := copy(Line, 1, EndPos - 1);
repeat
Delete(Line, 1, EndPos);
BeginPos := pos('/">', Line) + 3;
if BeginPos > 3 then
begin
EndPos := pos('</a>', Line);
Value := Value + ProducersSeparator + copy(Line, BeginPos, EndPos - BeginPos);
end;
until (Line = '') or (BeginPos = 3);
Value := UTF8Decode(Value);
HTMLDecode(Value);
SetField(fieldProducer, Value);
end;
//Length (get it here, but set it from imdb.com, if possible - see later)
if GetField(fieldLength) = '' then
begin
Page.Text := GetPage(GerIMDbDURLMain);
LineNr := FindLine('<h5>Länge:</h5>', Page, 0);
if LineNr > -1 then
begin
Line := Page.GetString(LineNr);
BeginPos := pos('<h5>Länge:</h5>', Line) + 20;
Delete(Line, 1, BeginPos);
EndPos := pos(' Min', Line);
if EndPos > 0 then
begin
Delete(Line, 1, EndPos - 5);
BeginPos := pos('>', Line) + 1;
EndPos := pos(' Min', Line);
Value := Trim(copy(Line, BeginPos, EndPos - BeginPos));
if Value <> '' then
SetField(fieldLength, Value);
end;
end;
end;
end;
procedure AnalyseIMDBPage(Page: TStringList);
var
Line, Value, Value2, FullValue: string;
BeginPos, EndPos, LineNr: Integer;
begin
// Year
Page.Text := GetPage(IMDbURL);
LineNr := FindLine('<title>', Page, 0);
Line := Page.GetString(LineNr);
if LineNr > -1 then
begin
BeginPos := pos('(', Line) + 1;
if BeginPos > 0 then
begin
EndPos := pos(')', Line);
BeginPos := EndPos - 4;
Value := copy(Line, BeginPos, EndPos - BeginPos);
SetField(fieldYear, Value);
end;
end;
// IMDb Rating
LineNr := FindLine('"ratingValue"', Page, 0);
if LineNr > -1 then
begin
Line := Page.GetString(LineNr);
BeginPos := pos('"ratingValue"', Line) + 14;
EndPos := BeginPos + 3;
Value := copy(Line, BeginPos, EndPos - BeginPos);
SetField(fieldRating, Value);
end;
// Directors
LineNr := FindLine('Directors:', Page, 0);
if LineNr = -1 then
LineNr := FindLine('Director:', Page, 0);
if LineNr > -1 then
begin
Value := '';
repeat
LineNr := FindLine('itemprop="director"', Page, LineNr);
LineNr := LineNr + 1;
Line := Page.GetString(LineNr);
BeginPos := pos('>', Line) + 1;
EndPos := pos('</a>', Line);
If Value <> '' then
Value := Value + DirectorsSeparator;
Value := Value + copy(Line, BeginPos, EndPos - BeginPos);
until FindLine('itemprop="director"', Page, LineNr) = -1;
Value := UTF8Decode(Value);
HTMLDecode(Value);
SetField(fieldDirector, Value);
end;
// Actors
LineNr := FindLine('Cast overview', Page, 0);
if LineNr = -1 then
LineNr := FindLine('cast overview', Page, 0);
if LineNr = -1 then
LineNr := FindLine('redited cast', Page, 0);
if LineNr = -1 then
LineNr := FindLine('cast summary:', Page, 0);
if LineNr > -1 then
begin
FullValue := '';
repeat
Value2 := '';
LineNr := FindLine('<td class="name">', Page, LineNr);
LineNr := LineNr + 2;
Line := Page.GetString(LineNr);
BeginPos := pos('>', Line) + 1;
EndPos := pos('</a>', Line);
Value := copy(Line, BeginPos, EndPos - BeginPos);
LineNr := FindLine('<td class="character">', Page, LineNr);
LineNr := LineNr + 3;
Line := Page.GetString(LineNr);
BeginPos := pos('/">', Line) + 3;
EndPos := pos('</a>', Line);
If BeginPos > 3 then
Value2 := copy(Line, BeginPos, EndPos - BeginPos)
else
Value2 := Trim(Line);
if (Value2 <> '') and (Value2 <> '</td>') then
begin
if Trim(Page.Getstring(LineNr + 1)) = '(voice)' then
Value2 := Value2 + ' (voice)';
Value := Value + ' (als ' + Value2 + ')';
end;
if FullValue <> '' then
if GetOption('ActorsLayout') < 2 then
FullValue := FullValue + ActorsSeparator
else
FullValue := FullValue + #13#10;
FullValue := FullValue + Value;
until FindLine('<td class="name">', Page, LineNr) < 1;
FullValue := UTF8Decode(FullValue);
HTMLRemoveTags(FullValue);
HTMLDecode(FullValue);
SetField(fieldActors, FullValue);
end;
// Length (from imdb.com, if possible)
LineNr := FindLine('Runtime:', Page, 0);
if LineNr > -1 then
begin
Line := Page.GetString(LineNr + 2);
BeginPos := pos('">', Line) + 2;
EndPos := pos(' min', Line);
Line := copy(Line, BeginPos, EndPos - BeginPos);
Line := Trim(Line);
SetField(fieldLength, Line);
end;
// Language
LineNr := FindLine('Language:', Page, 0);
if LineNr > -1 then
begin
Value := '';
repeat
LineNr := FindLine('<a href="/language', Page, LineNr);
Line := Page.GetString(LineNr);
BeginPos := pos('">', Line) + 2;
EndPos := pos('</a>', Line);
If Value <> '' then
Value := Value + LanguagesSeparator;
Value := Value + copy(Line, BeginPos, EndPos - BeginPos);
LineNr := LineNr + 1;
until FindLine('<a href="/language', Page, LineNr) < 1;
Value := UTF8Decode(Value);
HTMLDecode(Value);
SetField(fieldLanguages, Value);
end;
// Countries
LineNr := FindLine('Country:', Page, 0);
if LineNr > -1 then
begin
Value := '';
repeat
LineNr := FindLine('<a href="/country', Page, LineNr);
Line := Page.GetString(LineNr);
BeginPos := pos('" >', Line) + 3;
EndPos := pos('</a>', Line);
If Value <> '' then
Value := Value + CountriesSeparator;
Value := Value + copy(Line, BeginPos, EndPos - BeginPos);
LineNr := LineNr + 1;
until FindLine('<a href="/country', Page, LineNr) < 1;
Value := UTF8Decode(Value);
HTMLDecode(Value);
SetField(fieldCountry, Value);
end;
// Categories
LineNr := FindLine('Genres:', Page, 0);
if LineNr > -1 then
begin
LineNr := FindLine('<a href="/genre', Page, LineNr);
Line := Page.GetString(LineNr);
BeginPos := pos('">', Line) + 2;
EndPos := pos('</a>', Line);
Value := copy(Line, BeginPos, EndPos - BeginPos);
repeat
Delete(Line, 1, EndPos);
BeginPos := pos('">', Line) + 2;
if BeginPos > 2 then
begin
EndPos := pos('</a>', Line);
Value := Value + CategoriesSeparator + copy(Line, BeginPos, EndPos - BeginPos);
end;
until (Line = '') or (BeginPos = 2);
Value := UTF8Decode(Value);
HTMLDecode(Value);
SetField(fieldCategory, Value);
end;
//AspectRatio
if GetOption('AspectRatio') > 0 then
begin
LineNr := FindLine('Aspect Ratio:', Page, 0);
if LineNr > -1 then
begin
Line := Page.GetString(LineNr);
BeginPos := pos('Aspect Ratio:', Line) + 19;
Line := copy(Line, BeginPos , Length(Line) - BeginPos + 2);
if (CanSetField(fieldResolution)) and (GetOption('AspectRatio') = 1) then
SetField(fieldResolution, Line);
if (CanSetField(fieldVideoFormat)) and (GetOption('AspectRatio') = 2) then
SetField(fieldVideoFormat, Line);
end;
end;
//Audio
if GetOption('Audio') > 0 then
begin
Value := '';
LineNr := FindLine('Sound Mix:', Page, 0);
if LineNr > -1 then
begin
Line := Page.GetString(LineNr);
repeat
Delete(Line, 1, pos('<a href="/search', Line));
BeginPos := pos('">', Line) + 2;
if BeginPos > 2 then
begin
EndPos := pos('</a>', Line);
if Value <> '' then
Value := Value + AudioFormatSeparator;
Value := Value + copy(Line, BeginPos, EndPos - BeginPos);
end;
until pos('<a href="/search', Line) < 1;
if CanSetField(fieldAudioFormat) then
SetField(fieldAudioFormat, Value);
end;
end;
// Comments
Value := '';
if CanSetField(fieldComments) then
begin
LineNr := FindLine('href="usercomments"', Page, 0);
if LineNr > -1 then
begin
Page.Text := GetPage(IMDbURL + 'usercomments');
LineNr := FindLine('<a href="/user/', Page, 0);
if LineNr > -1 then
begin
LineNr := FindLine('<p>', Page, LineNr);
if LineNr > -1 then
begin
LineNr := LineNr + 1;
repeat
Line := Page.GetString(LineNr);
Value := Value + Line + ' ';
LineNr := LineNr + 1;
until pos('</p>', Line) > 0;
LineNr := FindLine('<a href="/user/', Page, 0);
Line := Page.GetString(LineNr);
BeginPos := pos('/comments">', Line) + 11;
EndPos := pos('</a>', Line);
Value := Value + ' by ' + copy(Line, BeginPos, EndPos - BeginPos);
end;
end;
Value := UTF8Decode(Value);
HTMLDecode(Value);
HTMLRemoveTags(Value);
SetField(fieldComments, Value);
end;
end;
if GetOption('DescriptionContent') = 0 then
begin
if GetField(fieldDescription) = '' then
begin
LineNr := FindLine('<a href="plotsummary">', Page, 0);
if LineNr > -1 then
begin
Page.Text := GetPage(IMDbURL + 'plotsummary');
LineNr := FindLine('<p class="plotpar">', Page, 0);
if LineNr > -1 then
begin
LineNr := LineNr -1;
Value := '';
repeat
LineNr := FindLine('<p class="plotpar">', Page, LineNr);
LineNr := LineNr + 1;
Line := Page.GetString(LineNr + 3);
BeginPos := pos('">', Line) + 2;
EndPos := pos('</a>', Line);
Value2 := copy(Line, BeginPos, EndPos - BeginPos);
Value := Value + Page.GetString(LineNr) + ' - Written by ' + Value2 + #13#10 + #13#10;
until FindLine('<p class="plotpar">', Page, LineNr) < 1;
end;
Value := UTF8Decode(Value);
HTMLDecode(Value);
HTMLRemoveTags(Value);
SetField(fieldComments, Value);
end;
end;
end;
//FSK
if GetOption('FSK') > 0 then
begin
Page.Text := GetPage(IMDbURL + 'parentalguide#certification');
LineNr := FindLine('Certification:', Page, 0) + 2;
Line := Page.GetString(LineNr);
BeginPos := pos('Certification:', Line);
Line := copy(Line, BeginPos, Length(Line));
BeginPos := pos('Germany:', Line) + 8;
if BeginPos = 8 then
begin
BeginPos := pos('West Germany:', Line) + 13;
if BeginPos = 13 then
BeginPos := 0;
end;
if BeginPos > 0 then
begin
Line := copy(Line, BeginPos, Length(Line));
EndPos := pos('</a>', Line) - 1;
Value := copy(Line, 1, EndPos);
If Value = 'o.Al.' then
Value := 'Ohne Altersbeschränkung';
if (CanSetField(fieldDescription)) and (GetOption('FSK') = 1) then
begin
Value := 'FSK: ' + (Value + #13#10 + GetField(fieldDescription));
SetField(fieldDescription, Value);
end;
if (CanSetField(fieldComments)) and (GetOption('FSK') = 2) then
begin
Value := 'FSK: ' + Value;
SetField(fieldComments, Value);
end;
end;
end;
end;
// this procedure only, if no IMDB-Nr. is found or AllFromOFDB-Option is set to 1
procedure AnalyseOFDBPageMore(Page: TStringList);
var
Line, Temp, Value: string;
LineNr, BeginPos, EndPos: Integer;
begin
// Country
LineNr := FindLine('Herstellungsland:', Page, 0);
if LineNr > -1 then
begin
LineNr := LineNr + 2;
Line := Page.GetString(LineNr);
Delete(Line, 1, pos('<a href="', Line));
BeginPos := pos('">', Line) + 2;
EndPos := pos('</a>', Line);
Value := copy(Line, BeginPos, EndPos - BeginPos);
Value := UTF8Decode(Value);
if Value <> '' then
SetField(fieldCountry, Value);
end;
// Year
LineNr := FindLine('Erscheinungsjahr:', Page, 0);
if LineNr > -1 then
begin
LineNr := LineNr + 2;
Line := Page.GetString(LineNr);
Delete(Line, 1, pos('<a href="', Line));
BeginPos := pos('">', Line) + 2;
EndPos := pos('</a>', Line);
Value := copy(Line, BeginPos, EndPos - BeginPos);
Value := UTF8Decode(Value);
if Value <> '' then
SetField(fieldYear, Value);
end;
// Directors
LineNr := FindLine('Regie:', Page, 0);
if LineNr > -1 then
begin
Value := '';
LineNr := LineNr + 2;
Line := Page.GetString(LineNr);
repeat
Delete(Line, 1, pos('<a href="', Line));
BeginPos := pos('">', Line) + 2;
if BeginPos > 2 then
begin
EndPos := pos('</a>', Line);
if Value <> '' then
Value := Value + DirectorsSeparator;
Value := Value + copy(Line, BeginPos, EndPos - BeginPos);
end;
until pos('<a href="', Line) < 1;
Value := UTF8Decode(Value);
if Value <> '' then
SetField(fieldDirector, Value);
end;
// Actors
LineNr := FindLine('Darsteller:', Page, 0);
if LineNr > -1 then
begin
Value := '';
LineNr := LineNr + 2;
Line := Page.GetString(LineNr);
repeat
Delete(Line, 1, pos('<a href="', Line));
BeginPos := pos('">', Line) + 2;
if BeginPos > 2 then
begin
EndPos := pos('</a>', Line);
Temp := copy(Line, BeginPos, EndPos - BeginPos);
if temp <> '[mehr]' then
begin
if Value <> '' then
Value := Value + ActorsSeparator;
Value := Value + Temp;
end;
end;
until pos('<a href="', Line) < 1;
Value := UTF8Decode(Value);
if Value <> '' then
SetField(fieldActors, Value);
end;
// Categories
LineNr := FindLine('Genre(s):', Page, 0);
if LineNr > -1 then
begin
Value := '';
LineNr := LineNr + 2;
Line := Page.GetString(LineNr);
repeat
Delete(Line, 1, pos('<a href="', Line));
BeginPos := pos('">', Line) + 2;
if BeginPos > 2 then
begin
EndPos := pos('</a>', Line);
if Value <> '' then
Value := Value + CategoriesSeparator;
Value := Value + copy(Line, BeginPos, EndPos - BeginPos);
end;
until pos('<a href="', Line) < 1;
Value := UTF8Decode(Value);
if Value <> '' then
SetField(fieldCategory, Value);
end;
// Rating
LineNr := FindLine('Note:', Page, 0);
if LineNr > -1 then
begin
Line := Page.GetString(LineNr);
BeginPos := pos('Note: ', Line) + 6;
EndPos := pos(' ', Line);
Value := copy(Line, BeginPos, EndPos - BeginPos);
Value := UTF8Decode(Value);
if Value <> '' then
SetField(fieldRating, Value);
end;
end;
begin
if CheckVersion(3,5,0) then
begin
MovieName := GetField(fieldTranslatedTitle);
if MovieName = '' then
MovieName := GetField(fieldOriginalTitle);
if MovieName = '' then
Input('OFDb', 'Bitte Titel eingeben :', MovieName);
SetSeparators;
AnalysePage('http://www.ofdb.de/view.php?page=sucher ... ingReplace(UrlEncode(UTF8Encode(MovieName)),'&%','%26%'));
end
else
ShowMessage('Dieses Script benötigt eine neuere Version von Ant Movie Catalog (mindestens Version 3.5.0)');
end.
-
- Posts: 17
- Joined: 2011-12-22 21:42:40
Hello,
i updated the Script to Version 1.8.7
Here are the changes :
- improve OFDb query
- delete the german imdb section
cause the website no longer exist
- repaired the TMDb picture query
[/code]
i updated the Script to Version 1.8.7
Here are the changes :
- improve OFDb query
- delete the german imdb section
cause the website no longer exist
- repaired the TMDb picture query
Code: Select all
(***************************************************
Ant Movie Catalog importation script
www.antp.be/software/moviecatalog/
[Infos]
Authors=Fabian Filipczyk<FFJaro@gmx.de>, Bad Joker<badjoker@gmx.de>, VisualMAx<visualmax@gmail.com>, U. Pollaehne<u.pollaehne@web.de>, gerol, Crap_Inhuman<crap_inhuman@hotmail.com>
Title=OFDb - IMDb - TMDb - mod
Description=Combined OFDb / IMDb / TMDb Picture from TMDb or OFDb | German Title and Description from OFDb|All other from IMDb
Site=www.ofdb.de
Language=DE,EN
Version=1.8.7
Requires=3.5.0
Comments=Import from Online-Filmdatenbank (OFDb) http://www.ofdb.de|and Internet Movie Database (IMDb) http:www.imdb.com||Import Picture from TMDb (Need api Key from www.themoviedb.org)
License=This program is free software; you can redistribute it and/or modify it under the|terms of the GNU General Public License as published by the Free Software Foundation;|either version 2 of the License, or (at your option) any later version.
GetInfo=1
RequiresMovies=1
[Options]
AllFromOFDB=1|0|0=Import most Values from IMDB (default)|1=Import all Values from OFDB
CommentContent=0|0|0=Import from OFDb/IMDb User Reviews (default)|1=Import from IMDb User Review only
ActorsLayout=0|0|0=Separate actors by comma (default)|1=Separate actors by slash|2=Separate actors by linebreak
DirectorsLayout=0|0|0=Separate directors by comma (default)|1=Separate directors by slash
ProducersLayout=0|0|0=Separate producers by comma (default)|1=Separate producers by slash
LanguageLayout=0|0|0=Separate languages by comma (default)|1=Separate languages by slash
CountryLayout=0|0|0=Separate countries by comma (default)|1=Separate countries by slash
CategoryLayout=0|0|0=Separate categories by comma (default)|1=Separate categories by slash
AudioFormatLayout=0|0|0=Separate Audio-Format by comma (default)|1=Separate Audio-Format by slash
AspectRatio=0|0|0=don't import Aspect Ratio (default)|1=Import Aspect Ratio to resolution field|2=Import Aspect Ratio to video format field
DescriptionContent=0|0|0=Import from OFDb/IMDb Description (default)|1=Import only from OFDb Description
PictureImport=0|0|0=Get Picture from OFDb (default)|1=Get Picture from TMDb - if not found get it from OFDb
[Parameters]
***************************************************)
(***************************************************
* *
* (c) 2002 Fabian Filipczyk FFJaro@gmx.de *
* *
* @2003 *
* Overworked by Bad Joker badjoker@gmx.de *
* *
* @16.10.2004 *
* Modified by VisualMAx (at)gmail.com *
* *
* @19.12.2004 *
* Modified by u.pollaehne (at)web.de *
* *
* @08.01.2006 *
* Modified by Bad Joker badjoker@gmx.de *
* *
* @2008 *
* Modified by bad4u and gerol *
* *
* @2009, 2010, 2011, 2012 *
* Modified by gerol *
* *
* @2012 *
* Modified by crap_inhuman: *
* User-Review can be imported from OFDb *
* into the Comment-Field *
* Some improvements *
* Import Pictures from TheMovieDB.org *
* !! Need api key for the import !! *
* *
* @2013/14 *
* Modified by crap_inhuman: *
* improve OFDb query *
* delete the german imdb section *
* cause the website no longer exist *
* repaired the TMDb picture query *
* *
***************************************************)
var
IMDb, MovieName, IMDbURL: string;
ActorsSeparator, DirectorsSeparator, ProducersSeparator, CountriesSeparator, LanguagesSeparator, CategoriesSeparator, AudioFormatSeparator: string;
ImdbFound: boolean;
procedure SetSeparators;
begin
case GetOption('ActorsLayout') of
0: ActorsSeparator := ', ';
1: ActorsSeparator := ' / ';
end;
case GetOption('DirectorsLayout') of
0: DirectorsSeparator := ', ';
1: DirectorsSeparator := ' / ';
end;
case GetOption('ProducersLayout') of
0: ProducersSeparator := ', ';
1: ProducersSeparator := ' / ';
end;
case GetOption('CountryLayout') of
0: CountriesSeparator := ', ';
1: CountriesSeparator := ' / ';
end;
case GetOption('LanguageLayout') of
0: LanguagesSeparator := ', ';
1: LanguagesSeparator := ' / ';
end;
case GetOption('CategoryLayout') of
0: CategoriesSeparator := ', ';
1: CategoriesSeparator := ' / ';
end;
case GetOption('AudioFormatLayout') of
0: AudioFormatSeparator := ', ';
1: AudioFormatSeparator := ' / ';
end;
end;
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 AnalysePicPage(Address: string);
var
URL, APIKey, NewURL, Line: string;
StartPos, EndPos: Integer;
begin
if GetOption('PictureImport') = 1 then
begin
APIKey := GetStatic('APIKey');
if APIKey = '' then
begin
if Input('API Key', 'Please enter your API key for TMDb', APIKey) then
begin
SetStatic('APIKey', APIKey);
end else
begin
Exit;
end;
end;
URL := 'http://api.themoviedb.org/3/movie/tt' + IMDb + '/images?api_key=' + APIKey;
Line := GetPage(URL);
StartPos := pos('"posters":[', Line);
StartPos := AnsiPosEx2('"file_path":"',Line, false, false, StartPos);
EndPos := AnsiPosEx2('.jpg"',Line, false, false, StartPos);
NewURL := copy(Line, StartPos + 13, EndPos - StartPos - 9);
GetPicture('http://image.tmdb.org/t/p/original' + NewURL);
end;
end;
procedure AnalysePage(Address: string);
var
Page: TStringList;
LineNr: Integer;
begin
Page := TStringList.Create;
Page.Text := GetPage(Address);
if pos('<title>OFDb - Suchergebnis', Page.Text) = 0 then
begin
AnalyseOFDBPage(Page);
if not ImdbFound then
ShowMessage('Keine IMDB-Nr. gefunden' + #13#10 + 'Hole Daten von OFDB');
if ImdbFound and (GetOption('AllFromOFDB') = 0) then
begin
AnalyseIMDBPage(Page);
AnalysePicPage(IMDb);
end else
begin
AnalyseOFDBPageMore(Page);
end;
SetField(fieldURL, Address);
end else
begin
if FindLine('<b>Titel:</b><br><br><b>•</b> <i>Keine Ergebnisse', Page, 0) > 0 then
begin
if (Pos('das', AnsiLowerCase(MovieName)) = 1) or
(Pos('der', AnsiLowerCase(MovieName)) = 1) or
(Pos('die', AnsiLowerCase(MovieName)) = 1) or
(Pos('ein', AnsiLowerCase(MovieName)) = 1) or
(Pos('eine', AnsiLowerCase(MovieName)) = 1) then
begin
MovieName := Trim(Copy(MovieName, 5, Length(MovieName)));
AnalysePage('http://www.ofdb.de/view.php?page=suchergebnis&SText='+UrlEncode(UTF8Encode(MovieName))+'&Kat=All');
end else
begin
ShowMessage('Die Suche nach "' + MovieName +'" ergab kein Ergebnis, bitte den Titel ändern.');
if (Input('OFDb IMDb (DE)', 'Bitte einen anderen Titel eingeben :', MovieName)) and (MovieName <> '') then
AnalysePage('http://www.ofdb.de/view.php?page=suchergebnis&SText='+UrlEncode(UTF8Encode(MovieName))+'&Kat=All');
end;
end else
begin
PickTreeClear;
LineNr := FindLine('<b>Titel:</b>', Page, 0);
if LineNr > 0 then
begin
PickTreeAdd('Suche nach "' + MovieName + '" ergab:', '');
PickTreeMoreLink('dummy');
Address := AddMoviesTitles(Page, LineNr);
if Address = '' then
begin
if PickTreeExec(Address) then
begin
if Address = 'dummy' then
begin
if (Input('Kein passender Titel dabei?', 'Bitte ändern Sie den Titel ab:', MovieName)) and (MovieName <> '') then
AnalysePage('http://www.ofdb.de/view.php?page=suchergebnis&SText='+UrlEncode(UTF8Encode(MovieName))+'&Kat=All')
end else
AnalysePage(Address);
end;
end else
AnalysePage(Address);
end;
end;
end;
Page.Free;
end;
function AddMoviesTitles(Page: TStringList; var LineNr: Integer) : string;
var
Line: string;
Headline, MovieTitle, MovieTitleCopy, MovieAddress: string;
StartPos, HeadlinePos, EndPos, NumTitles: Integer;
Multi: boolean;
begin
Multi := true;
result := '';
Headline := '';
Line := Page.GetString(LineNr);
NumTitles := 0;
MovieTitleCopy := '';
repeat
StartPos := pos('<a href=''view.php?page=film&fid=', Line);
if StartPos < 1 then
StartPos := Pos('<a href=''film/', Line);
if StartPos < 1 then
begin
StartPos := pos('<a href="view.php?page=film&fid=', Line);
Multi := false;
end;
if StartPos < 1 then
begin
StartPos := Pos('<a href="film/', Line);
Multi := false;
end;
if StartPos > 0 then
begin
HeadlinePos := pos('<br><i>', Line);
if (HeadlinePos > 0) and (HeadlinePos < StartPos) then
begin
Headline := copy(Line, HeadlinePos + 7, Pos('</i><br>', Line) - HeadlinePos - 7);
Headline := UTF8Decode(Headline);
HTMLDecode(Headline);
PickTreeAdd(Headline, '');
end;
Delete(Line, 1, StartPos + 8);
MovieAddress := copy(Line, 1, pos('''>', Line) - 1);
if Multi = false then
MovieAddress := copy(Line, 1, pos('" onmouseover=', Line) - 1);
StartPos := pos('''>', Line) + 2;
if Multi = false then
StartPos := pos('">', Line) + 2;
MovieTitle := copy(Line, StartPos, pos('</a>', Line) - StartPos);
MovieTitle := UTF8Decode(MovieTitle);
HTMLRemoveTags(MovieTitle);
if NumTitles > 0 then
begin
if MovieTitleCopy <> MovieTitle then
begin
PickTreeAdd(MovieTitle, 'http://www.ofdb.de/' + MovieAddress);
NumTitles := NumTitles + 1;
end;
end;
if NumTitles = 0 then
begin
NumTitles := NumTitles + 1;
PickTreeAdd(MovieTitle, 'http://www.ofdb.de/' + MovieAddress);
MovieTitleCopy := MovieTitle;
end;
end;
until (StartPos < 1);
if NumTitles = 1 then
result := 'http://www.ofdb.de/' + MovieAddress;
end;
procedure AnalyseOFDBPage(Page: TStringList);
var
Line, Temp, Value, NewURL: string;
LineNr, BeginPos, EndPos: Integer;
DetailPage: TStringList;
// Get IMDb URL
begin
LineNr :=Findline('http://www.imdb.com/Title?', Page, 0);
Line := Page.GetString(LineNr);
BeginPos := pos('Title?', Line)+6;
EndPos := pos('" target', Line);
Value := copy(Line, BeginPos, EndPos - BeginPos);
Value := StringReplace(Value, 'tt', '');
BeginPos := pos('Title?', Line)+6;
EndPos := pos('" target', Line);
Temp := copy(Line, BeginPos, EndPos - BeginPos);
Temp := StringReplace(Temp, 'tt', '');
if Temp <> '' then
ImdbFound := true
else
ImdbFound := false;
Value := ('http://www.imdb.com/title/tt' + Temp + '/');
IMDbURL := Value;
IMDb := TEMP;
// Original & Translated Title
LineNr := FindLine('Originaltitel:</font>', Page, 0);
if LineNr > -1 then
begin
LineNr:= LineNr+2;
Line := Page.GetString(LineNr);
BeginPos := pos('class="Daten"><b>', Line) + 17;
EndPos := pos('</b></font>', Line);
Value := copy(Line, BeginPos, EndPos - BeginPos);
Value := UTF8Decode(Value);
SetField(fieldOriginalTitle, Value);
LineNr := Findline('sans-serif" size="3"><b>', Page, 0);
if LineNr > -1 then
begin
Line:= Page.GetString(LineNr);
BeginPos := pos('sans-serif" size="3"><b>',Line) +24;
Endpos := pos('</b></font></h1></td>',Line);
Value := copy(Line,BeginPos, Endpos-Beginpos);
Value := UTF8Decode(Value);
SetField(fieldTranslatedTitle,Value);
end;
end;
// Picture
LineNr := FindLine('<img src="http://img.ofdb.de/film', Page, 0);
if LineNr > -1 then
begin
Line := Page.GetString(LineNr);
BeginPos := pos('<img src="', Line) + 10;
if BeginPos > 10 then
begin
EndPos := pos(' alt=', Line)-1;
Value := copy(Line, BeginPos, EndPos - BeginPos);
GetPicture(Value);
end;
end;
// Description
LineNr := Findline('<b>Inhalt:</b>', Page, 0);
if LineNr > -1 then
begin
LineNr := Findline('<a href="view.php?page=inhalt', Page, 0);
if LineNr > -1 then
begin
Line := Page.GetString(LineNr);
BeginPos := pos('<a href="view.php?page=inhalt', Line)+9;
end else
begin
LineNr := Findline ('<a href="plot/', Page, 0);
Line := Page.GetString(LineNr);
BeginPos := pos('<a href="plot/', Line)+9;
end;
EndPos := pos('"><b>[mehr]', Line);
Value := copy(Line, BeginPos, EndPos - BeginPos);
HTMLRemoveTags(Value);
Value := UTF8Decode(Value);
GetDescriptions(Value);
end else
begin
SetField(fieldDescription, '');
end;
// Comments
if CanSetField(fieldComments) then
begin
if GetOption('CommentContent') = 0 then
begin
LineNr := FindLine('Lokale Reviews:', Page, 0);
if LineNr > -1 then
begin
Line := Page.GetString(LineNr);
BeginPos := pos('<a href=', Line)+9;
Line := copy(Line, BeginPos, Length(Line));
EndPos := Pos('">', Line);
Value := copy(Line, 1, EndPos-1);
HTMLRemoveTags(Value);
Value := UTF8Decode(Value);
GetComments(Value);
end else
begin
SetField(fieldComments, '');
end;
end;
end;
end;
procedure GetDescriptions(Address: string);
var
Line, Temp, Value: string;
LineNr, BeginPos, EndPos: Integer;
Page: TStringList;
begin
Temp:= '';
Page := TStringList.Create;
Page.Text := GetPage('http://www.ofdb.de/' + Address);
LineNr := FindLine('Eine Inhaltsangabe von', Page, 0);
if LineNr > -1 then
begin
Line := Page.GetString(LineNr);
BeginPos := pos('</b></b><br><br>', Line)+16;
while (pos('<br />', Line) >0) do
begin
EndPos := pos('<br />', Line);
Temp := Temp + copy(Line, BeginPos, EndPos - BeginPos)+#13#10;
LineNr:=LineNr+1;
Line:=Page.GetString(LineNr);
BeginPos:=1;
end;
EndPos := pos('</font></p>', Line);
Temp:= Temp + copy(Line, BeginPos, EndPos - BeginPos);
Value:= Temp;
Value := UTF8Decode(Value);
SetField(fieldDescription, Value);
end;
Page.Free;
end;
procedure GetComments(Address: string);
var
Line, Temp, Value: string;
LineNr, BeginPos, EndPos: Integer;
Page: TStringList;
begin
Temp:= '';
Page := TStringList.Create;
Page.Text := GetPage('http://www.ofdb.de/' + Address);
LineNr := FindLine('Eine Kritik von <a ', Page, 0);
if LineNr > -1 then
begin
LineNr:=LineNr+1;
Line := Page.GetString(LineNr);
BeginPos :=1;
if pos('<p class="Blocksatz">', Line) > 0 then
begin
BeginPos := pos('<p class="Blocksatz">', Line)+21;
end;
while (pos('<br />', Line) >0) do
begin
EndPos := pos('<br />', Line);
Temp := Temp + copy(Line, BeginPos, EndPos - BeginPos)+#13#10;
LineNr:=LineNr+1;
Line:=Page.GetString(LineNr);
BeginPos:=1;
end;
EndPos := pos('</font></p>', Line);
Temp:= Temp + copy(Line, BeginPos, EndPos - BeginPos);
Value:= Temp;
Value := UTF8Decode(Value);
HTMLDecode(Value);
HTMLRemoveTags(Value);
SetField(fieldComments, Value);
end else
begin
SetField(fieldComments, '');
end;
Page.Free;
end;
procedure AnalyseIMDBPage(Page: TStringList);
var
Line, Value, Value2, FullValue: string;
BeginPos, EndPos, LineNr: Integer;
begin
Page.Text := GetPage(IMDbURL);
// start edit by crap_inhuman
(* Not implemented yet
// Producers
LineNr := FindLine('">Produced by', Page, 0);
if LineNr > -1 then
begin
Value := '';
EndPos := 0;
Line := Page.GetString(LineNr);
BeginPos := Pos('>Produktion<', Line);
EndPos := Pos(' name="music_original"', Line);
if EndPos = 0 then
EndPos := Pos(' name="cinematographers"', Line);
Line := copy(Line, BeginPos, EndPos - BeginPos);
BeginPos := pos('/">', Line) + 2;
Delete(Line, 1, BeginPos);
EndPos := pos('</a>', Line);
Value := copy(Line, 1, EndPos - 1);
repeat
Delete(Line, 1, EndPos);
BeginPos := pos('/">', Line) + 3;
if BeginPos > 3 then
begin
EndPos := pos('</a>', Line);
Value := Value + ProducersSeparator + copy(Line, BeginPos, EndPos - BeginPos);
end;
until (Line = '') or (BeginPos = 3);
Value := StringReplace(Value, ',,', ',');
Value := StringReplace(Value, ', ,', ',');
Value := UTF8Decode(Value);
HTMLDecode(Value);
SetField(fieldProducer, Value);
end;
*)
// end edit by crap_inhuman
// IMDb Rating
LineNr := FindLine('"ratingValue"', Page, 0);
if LineNr > -1 then
begin
Line := Page.GetString(LineNr);
BeginPos := pos('"ratingValue"', Line) + 14;
EndPos := BeginPos + 3;
Value := copy(Line, BeginPos, EndPos - BeginPos);
SetField(fieldRating, Value);
end;
// Year
LineNr := FindLine('<title>', Page, 0);
if LineNr > -1 then
begin
Line := Page.GetString(LineNr);
BeginPos := pos('(', Line) + 1;
if BeginPos > 0 then
begin
EndPos := pos(')', Line);
BeginPos := EndPos - 4;
Value := copy(Line, BeginPos, EndPos - BeginPos);
SetField(fieldYear, Value);
end;
end;
// Directors
LineNr := FindLine('Directors:', Page, 0);
if LineNr = -1 then
LineNr := FindLine('Director:', Page, 0);
if LineNr > -1 then
begin
Value := '';
repeat
LineNr := FindLine('itemprop="director"', Page, LineNr);
LineNr := LineNr + 2;
Line := Page.GetString(LineNr);
BeginPos := pos('"name">', Line) + 7;
EndPos := pos('</span>', Line);
If Value <> '' then
Value := Value + DirectorsSeparator;
Value := Value + copy(Line, BeginPos, EndPos - BeginPos);
until FindLine('itemprop="director"', Page, LineNr) = -1;
Value := UTF8Decode(Value);
HTMLDecode(Value);
SetField(fieldDirector, Value);
end;
// Actors
LineNr := FindLine('Cast overview', Page, 0);
if LineNr = -1 then
LineNr := FindLine('cast overview', Page, 0);
if LineNr = -1 then
LineNr := FindLine('redited cast', Page, 0);
if LineNr = -1 then
LineNr := FindLine('cast summary:', Page, 0);
if LineNr > -1 then
begin
FullValue := '';
repeat
Value2 := '';
LineNr := FindLine('itemprop="actor"', Page, LineNr);
LineNr := LineNr + 1;
Line := Page.GetString(LineNr);
BeginPos := pos('"name">', Line) + 7;
EndPos := pos('</span>', Line);
Value := copy(Line, BeginPos, EndPos - BeginPos);
LineNr := FindLine('<td class="character">', Page, LineNr);
LineNr := LineNr + 2;
Line := Page.GetString(LineNr);
BeginPos := pos('>', Line) + 1;
EndPos := pos('</a>', Line);
If BeginPos > 3 then
Value2 := copy(Line, BeginPos, EndPos - BeginPos)
else
Value2 := Trim(Line);
if (Value2 <> '') and (Value2 <> '</td>') then
begin
if Trim(Page.Getstring(LineNr + 1)) = '(voice)' then
Value2 := Value2 + ' (voice)';
Value := Value + ' (als ' + Value2 + ')';
end;
if FullValue <> '' then
if GetOption('ActorsLayout') < 2 then
FullValue := FullValue + ActorsSeparator
else
FullValue := FullValue + #13#10;
FullValue := FullValue + Value;
until FindLine('itemprop="actor"', Page, LineNr) < 1;
FullValue := UTF8Decode(FullValue);
HTMLRemoveTags(FullValue);
HTMLDecode(FullValue);
SetField(fieldActors, FullValue);
end;
// Length (from imdb.com, if possible)
LineNr := FindLine('Runtime:', Page, 0);
if LineNr > -1 then
begin
Line := Page.GetString(LineNr + 2);
BeginPos := pos('">', Line) + 2;
EndPos := pos(' min', Line);
Line := copy(Line, BeginPos, EndPos - BeginPos);
Line := Trim(Line);
SetField(fieldLength, Line);
end;
// Language
LineNr := FindLine('Language:', Page, 0);
if LineNr > -1 then
begin
Value := '';
repeat
LineNr := FindLine('href="/language/', Page, LineNr);
Line := Page.GetString(LineNr + 1);
BeginPos := pos('>', Line) + 1;
EndPos := pos('</a>', Line);
If Value <> '' then
Value := Value + LanguagesSeparator;
Value := Value + copy(Line, BeginPos, EndPos - BeginPos);
LineNr := LineNr + 1;
until FindLine('href="/language/', Page, LineNr) < 1;
Value := UTF8Decode(Value);
HTMLDecode(Value);
SetField(fieldLanguages, Value);
end;
// Countries
LineNr := FindLine('Country:', Page, 0);
if LineNr > -1 then
begin
Value := '';
repeat
LineNr := FindLine('href="/country/', Page, LineNr);
Line := Page.GetString(LineNr);
BeginPos := pos('>', Line) + 1;
EndPos := pos('</a>', Line);
If Value <> '' then
Value := Value + CountriesSeparator;
Value := Value + copy(Line, BeginPos, EndPos - BeginPos);
LineNr := LineNr + 1;
until FindLine('href="/country/', Page, LineNr) < 1;
Value := UTF8Decode(Value);
HTMLDecode(Value);
SetField(fieldCountry, Value);
end;
// Categories
LineNr := FindLine('Genres:', Page, 0);
if LineNr > -1 then
begin
Value := '';
LineNr := LineNr + 1;
repeat
LineNr := FindLine('href="/genre/', Page, LineNr);
Line := Page.GetString(LineNr);
BeginPos := pos('>', Line) + 2;
EndPos := pos('</a>', Line);
If Value <> '' then
Value := Value + CategoriesSeparator;
Value := Value + copy(Line, BeginPos, EndPos - BeginPos);
LineNr := LineNr + 1;
until FindLine('href="/genre/', Page, LineNr) < 1;
Value := UTF8Decode(Value);
HTMLDecode(Value);
SetField(fieldCategory, Value);
end;
//AspectRatio
if GetOption('AspectRatio') > 0 then
begin
LineNr := FindLine('Aspect Ratio:', Page, 0);
if LineNr > -1 then
begin
Line := Page.GetString(LineNr);
BeginPos := pos('Aspect Ratio:', Line) + 19;
Line := copy(Line, BeginPos , Length(Line) - BeginPos + 2);
if (CanSetField(fieldResolution)) and (GetOption('AspectRatio') = 1) then
SetField(fieldResolution, Line);
if (CanSetField(fieldVideoFormat)) and (GetOption('AspectRatio') = 2) then
SetField(fieldVideoFormat, Line);
end;
end;
// Comments
Value := '';
if CanSetField(fieldComments) then
begin
LineNr := FindLine('href="reviews"', Page, 0);
if LineNr > -1 then
begin
Page.Text := GetPage(IMDbURL + 'reviews');
LineNr := FindLine('<a href="/user/', Page, 0);
if LineNr > -1 then
begin
LineNr := FindLine('<p>', Page, LineNr);
if LineNr > -1 then
begin
LineNr := LineNr + 1;
repeat
Line := Page.GetString(LineNr);
Value := Value + Line + ' ';
LineNr := LineNr + 1;
until pos('</p>', Line) > 0;
LineNr := FindLine('<a href="/user/', Page, 0);
Line := Page.GetString(LineNr);
BeginPos := pos('/comments">', Line) + 11;
EndPos := pos('</a>', Line);
Value := Value + ' by ' + copy(Line, BeginPos, EndPos - BeginPos);
end;
end;
Value := UTF8Decode(Value);
HTMLDecode(Value);
HTMLRemoveTags(Value);
if ((GetOption('CommentContent') = 0) And (GetField(fieldComments) = '')) Or (GetOption('CommentContent') = 1) then
SetField(fieldComments, Value);
end;
end;
if GetOption('DescriptionContent') = 0 then
begin
if GetField(fieldDescription) = '' then
begin
LineNr := FindLine('href="plotsummary"', Page, 0);
if LineNr > -1 then
begin
Page.Text := GetPage(IMDbURL + 'plotsummary');
LineNr := FindLine('<p class="plotpar">', Page, 0);
if LineNr > -1 then
begin
LineNr := LineNr -1;
Value := '';
repeat
LineNr := FindLine('<p class="plotpar">', Page, LineNr);
LineNr := LineNr + 1;
Line := Page.GetString(LineNr + 3);
BeginPos := pos('">', Line) + 2;
EndPos := pos('</a>', Line);
Value2 := copy(Line, BeginPos, EndPos - BeginPos);
Value := Value + Page.GetString(LineNr) + ' - Written by ' + Value2 + #13#10 + #13#10;
until FindLine('<p class="plotpar">', Page, LineNr) < 1;
end;
Value := UTF8Decode(Value);
HTMLDecode(Value);
HTMLRemoveTags(Value);
SetField(fieldDescription, Value);
end;
end;
end;
end;
// this procedure only, if no IMDB-Nr. is found or AllFromOFDB-Option is set to 1
procedure AnalyseOFDBPageMore(Page: TStringList);
var
DetailPage: TStringList;
Line, Temp, Value: string;
LineNr, BeginPos, EndPos: Integer;
begin
// Country
LineNr := FindLine('Herstellungsland:', Page, 0);
if LineNr > -1 then
begin
Value := '';
LineNr := LineNr + 2;
Line := Page.GetString(LineNr);
repeat
Delete(Line, 1, pos('<a href="', Line));
BeginPos := pos('">', Line) + 2;
if BeginPos > 2 then
begin
EndPos := pos('</a>', Line);
if Value <> '' then
Value := Value + CountriesSeparator;
Value := Value + copy(Line, BeginPos, EndPos - BeginPos);
end;
until pos('<a href="', Line) < 1;
Value := UTF8Decode(Value);
SetField(fieldCountry, Value);
end;
// Year
LineNr := FindLine('Erscheinungsjahr:', Page, 0);
if LineNr > -1 then
begin
LineNr := LineNr + 2;
Line := Page.GetString(LineNr);
Delete(Line, 1, pos('<a href="', Line));
BeginPos := pos('">', Line) + 2;
EndPos := pos('</a>', Line);
Value := copy(Line, BeginPos, EndPos - BeginPos);
Value := UTF8Decode(Value);
if Value <> '' then
SetField(fieldYear, Value);
end;
// Directors
LineNr := FindLine('Regie:', Page, 0);
if LineNr > -1 then
begin
Value := '';
LineNr := LineNr + 2;
Line := Page.GetString(LineNr);
// start edit by crap_inhuman
repeat
BeginPos := pos('<span itemprop="name">', Line);
if BeginPos > 2 then
begin
Delete(Line, 1, pos('<span itemprop="name">', Line));
EndPos := pos('</span>', Line);
if Value <> '' then
Value := Value + DirectorsSeparator;
Value := Value + copy(Line, 22, EndPos - 22);
end;
until pos('<span itemprop="name">', Line) < 1;
// end edit by crap_inhuman
Value := UTF8Decode(Value);
if Value <> '' then
SetField(fieldDirector, Value);
end;
// Actors
LineNr := FindLine('Darsteller:', Page, 0);
if LineNr > -1 then
begin
Value := '';
LineNr := LineNr + 2;
Line := Page.GetString(LineNr);
// start edit by crap_inhuman
If pos('[mehr]', Line) > 0 then
begin
BeginPos := AnsiLastPosEx('<a href="', Line, false, false);
EndPos := AnsiPosEx2('">[mehr]', Line, false, false, BeginPos);
DetailPage := TStringList.Create;
DetailPage.Text := GetPage('http://www.ofdb.de/' + copy(Line, BeginPos + 9, EndPos - BeginPos - 9));
LineNr := FindLine('<b><i>Darsteller</i></b>', DetailPage, 0);
if LineNr > -1 then
begin
LineNr := LineNr + 4;
repeat
Temp := '';
Line := DetailPage.GetString(LineNr);
BeginPos := AnsiLastPosEx('">', Line, false, false);
EndPos := AnsiPosEx2('</', Line, false, false, BeginPos);
Temp := copy(Line, BeginPos + 2, EndPos - BeginPos -2);
Temp := StringReplace(Temp, '<b>', '');
LineNr := LineNr + 2;
Line := DetailPage.GetString(LineNr);
if (pos('<td></td>', Line) = 0) and (pos('... ', Line) > 0) then
begin
BeginPos := AnsiPosEx('... ', Line, false, false);
EndPos := AnsiPosEx2('<', Line, false, false, BeginPos);
Temp := Temp + ' (als ' + copy(Line, BeginPos + 4, EndPos - BeginPos -4) + ')';
end;
LineNr := LineNr + 4;
if Value <> '' then
Value := Value + ActorsSeparator;
Value := Value + Temp;
Line := DetailPage.GetString(LineNr);
until pos('class="', Line) < 1;
end;
end else
begin
repeat
Temp := '';
BeginPos := pos('<span itemprop="name">', Line);
if BeginPos > 0 then
begin
EndPos := AnsiPosEx2('</span>', Line, false, false, BeginPos);
Temp := copy(Line, BeginPos + 22, EndPos - BeginPos - 22);
Delete(Line, 1, BeginPos + 22);
if Value <> '' then
Value := Value + ActorsSeparator;
Value := Value + Temp;
end;
until pos('<span itemprop="name">', Line) < 1;
end;
// end edit by crap_inhuman
Value := UTF8Decode(Value);
if Value <> '' then
SetField(fieldActors, Value);
end;
// Categories
LineNr := FindLine('Genre(s):', Page, 0);
if LineNr > -1 then
begin
Value := '';
LineNr := LineNr + 2;
Line := Page.GetString(LineNr);
repeat
Delete(Line, 1, pos('<a href="', Line));
BeginPos := pos('">', Line) + 2;
if BeginPos > 2 then
begin
EndPos := pos('</a>', Line);
if Value <> '' then
Value := Value + CategoriesSeparator;
Value := Value + copy(Line, BeginPos, EndPos - BeginPos);
end;
until pos('<a href="', Line) < 1;
Value := UTF8Decode(Value);
if Value <> '' then
begin
HtmlRemoveTags(Value);
SetField(fieldCategory, Value);
end;
end;
// Rating
LineNr := Findline('Note: <span itemprop="ratingValue">', Page, 0);
if LineNr > -1 then
begin
Line:= Page.GetString(LineNr);
BeginPos := Pos('Note: <span itemprop="ratingValue">',Line) + 35;
// I had to add 0.1 here to make the rounding more precise
Value := IntToStr(Round((StrToInt(Copy(Line, BeginPos+2, 2), 0) + 0.1) / 10));
if StrToInt(Value,0) > 9 then
Value := IntToStr(StrToInt(StrGet(Line, BeginPos),0) + 1) + '.0'
else
Value := StrGet(Line, BeginPos) + '.' + Value;
SetField(fieldRating, Value);
end;
// Producers
// start edit by crap_inhuman
Value := '';
LineNr := FindLine('Produzent(in)', DetailPage, 0);
if LineNr > -1 then
begin
LineNr := LineNr + 4;
Line := DetailPage.GetString(LineNr);
repeat
Temp := '';
Line := DetailPage.GetString(LineNr);
BeginPos := AnsiLastPosEx('">', Line, false, false);
EndPos := AnsiPosEx2('</', Line, false, false, BeginPos);
Temp := copy(Line, BeginPos + 2, EndPos - BeginPos -2);
Temp := StringReplace(Temp, '<b>', '');
LineNr := LineNr + 4;
if Value <> '' then
Value := Value + ProducersSeparator;
Value := Value + Temp;
Line := DetailPage.GetString(LineNr);
until pos('class="', Line) < 1;
end;
// end edit by crap_inhuman
Value := UTF8Decode(Value);
if Value <> '' then
SetField(fieldProducer, Value);
end;
begin
if CheckVersion(3,5,0) then
begin
MovieName := GetField(fieldTranslatedTitle);
if MovieName = '' then
MovieName := GetField(fieldOriginalTitle);
if MovieName = '' then
Input('OFDb', 'Bitte Titel eingeben :', MovieName);
SetSeparators;
AnalysePage('http://www.ofdb.de/view.php?page=suchergebnis&Kat=Titel&SText='+StringReplace(UrlEncode(UTF8Encode(MovieName)),'&%','%26%'));
end
else
ShowMessage('Dieses Script benötigt eine neuere Version von Ant Movie Catalog (mindestens Version 3.5.0)');
end.
-
- Posts: 17
- Joined: 2011-12-22 21:42:40
Here is the Version 1.8.8 with some small bugfixes
Code: Select all
(***************************************************
Ant Movie Catalog importation script
www.antp.be/software/moviecatalog/
[Infos]
Authors=Fabian Filipczyk<FFJaro@gmx.de>, Bad Joker<badjoker@gmx.de>, VisualMAx<visualmax@gmail.com>, U. Pollaehne<u.pollaehne@web.de>, gerol, Crap_Inhuman<crap_inhuman@hotmail.com>
Title=OFDb - IMDb - TMDb - mod
Description=Combined OFDb / IMDb / TMDb Picture from TMDb or OFDb | German Title and Description from OFDb|All other from IMDb
Site=www.ofdb.de
Language=DE,EN
Version=1.8.8
Requires=3.5.0
Comments=Import from Online-Filmdatenbank (OFDb) http://www.ofdb.de|and Internet Movie Database (IMDb) http:www.imdb.com||Import Picture from TMDb (Need api Key from www.themoviedb.org)
License=This program is free software; you can redistribute it and/or modify it under the|terms of the GNU General Public License as published by the Free Software Foundation;|either version 2 of the License, or (at your option) any later version.
GetInfo=1
RequiresMovies=1
[Options]
AllFromOFDB=0|0|0=Import most Values from IMDB (default)|1=Import all Values from OFDB
CommentContent=0|0|0=Import from OFDb/IMDb User Reviews (default)|1=Import from IMDb User Review only
ActorsLayout=0|0|0=Separate actors by comma (default)|1=Separate actors by slash|2=Separate actors by linebreak
DirectorsLayout=0|0|0=Separate directors by comma (default)|1=Separate directors by slash
ProducersLayout=0|0|0=Separate producers by comma (default)|1=Separate producers by slash
LanguageLayout=0|0|0=Separate languages by comma (default)|1=Separate languages by slash
CountryLayout=0|0|0=Separate countries by comma (default)|1=Separate countries by slash
CategoryLayout=0|0|0=Separate categories by comma (default)|1=Separate categories by slash
AudioFormatLayout=0|0|0=Separate Audio-Format by comma (default)|1=Separate Audio-Format by slash
AspectRatio=0|0|0=don't import Aspect Ratio (default)|1=Import Aspect Ratio to resolution field|2=Import Aspect Ratio to video format field
DescriptionContent=1|0|0=Import from OFDb/IMDb Description (default)|1=Import only from OFDb Description
PictureImport=1|0|0=Get Picture from OFDb (default)|1=Get Picture from TMDb - if not found get it from OFDb
[Parameters]
***************************************************)
(***************************************************
* *
* (c) 2002 Fabian Filipczyk FFJaro@gmx.de *
* *
* @2003 *
* Overworked by Bad Joker badjoker@gmx.de *
* *
* @16.10.2004 *
* Modified by VisualMAx (at)gmail.com *
* *
* @19.12.2004 *
* Modified by u.pollaehne (at)web.de *
* *
* @08.01.2006 *
* Modified by Bad Joker badjoker@gmx.de *
* *
* @2008 *
* Modified by bad4u and gerol *
* *
* @2009, 2010, 2011, 2012 *
* Modified by gerol *
* *
* @2012 *
* Modified by crap_inhuman: *
* User-Review can be imported from OFDb *
* into the Comment-Field *
* Some improvements *
* Import Pictures from TheMovieDB.org *
* !! Need api key for the import !! *
* *
* @2013/14 *
* Modified by crap_inhuman: *
* improve OFDb query *
* delete the german imdb section *
* cause the website no longer exist *
* repaired the TMDb picture query *
* *
***************************************************)
var
IMDb, MovieName, IMDbURL: string;
ActorsSeparator, DirectorsSeparator, ProducersSeparator, CountriesSeparator, LanguagesSeparator, CategoriesSeparator, AudioFormatSeparator: string;
ImdbFound: boolean;
procedure SetSeparators;
begin
case GetOption('ActorsLayout') of
0: ActorsSeparator := ', ';
1: ActorsSeparator := ' / ';
2: ActorsSeparator := #13#10;
end;
case GetOption('DirectorsLayout') of
0: DirectorsSeparator := ', ';
1: DirectorsSeparator := ' / ';
end;
case GetOption('ProducersLayout') of
0: ProducersSeparator := ', ';
1: ProducersSeparator := ' / ';
end;
case GetOption('CountryLayout') of
0: CountriesSeparator := ', ';
1: CountriesSeparator := ' / ';
end;
case GetOption('LanguageLayout') of
0: LanguagesSeparator := ', ';
1: LanguagesSeparator := ' / ';
end;
case GetOption('CategoryLayout') of
0: CategoriesSeparator := ', ';
1: CategoriesSeparator := ' / ';
end;
case GetOption('AudioFormatLayout') of
0: AudioFormatSeparator := ', ';
1: AudioFormatSeparator := ' / ';
end;
end;
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 AnalysePicPage(Address: string);
var
URL, APIKey, NewURL, Line: string;
StartPos, EndPos: Integer;
begin
if GetOption('PictureImport') = 1 then
begin
APIKey := GetStatic('APIKey');
if APIKey = '' then
begin
if Input('API Key', 'Please enter your API key for TMDb', APIKey) then
begin
SetStatic('APIKey', APIKey);
end else
begin
Exit;
end;
end;
URL := 'http://api.themoviedb.org/3/movie/tt' + IMDb + '/images?api_key=' + APIKey;
Line := GetPage(URL);
if (pos ('Invalid id', Line) = 0) and (Line <> '') Then
begin
StartPos := pos('"posters":[', Line);
StartPos := AnsiPosEx2('"file_path":"',Line, false, false, StartPos);
EndPos := AnsiPosEx2('.jpg"',Line, false, false, StartPos);
NewURL := copy(Line, StartPos + 13, EndPos - StartPos - 9);
GetPicture('http://image.tmdb.org/t/p/original' + NewURL);
end;
end;
end;
procedure AnalysePage(Address: string);
var
Page: TStringList;
LineNr: Integer;
begin
Page := TStringList.Create;
Page.Text := GetPage(Address);
if pos('<title>OFDb - Suchergebnis', Page.Text) = 0 then
begin
AnalyseOFDBPage(Page);
if not ImdbFound then
ShowMessage('Keine IMDB-Nr. gefunden' + #13#10 + 'Hole Daten von OFDB');
// if ImdbFound and (GetOption('AllFromOFDB') = 0) then
// begin
AnalyseIMDBPage(Page);
AnalysePicPage(IMDb);
// end else
// begin
AnalyseOFDBPageMore(Address);
// end;
SetField(fieldURL, Address);
end else
begin
if FindLine('<b>Titel:</b><br><br><b>•</b> <i>Keine Ergebnisse', Page, 0) > 0 then
begin
if (Pos('das', AnsiLowerCase(MovieName)) = 1) or
(Pos('der', AnsiLowerCase(MovieName)) = 1) or
(Pos('die', AnsiLowerCase(MovieName)) = 1) or
(Pos('ein', AnsiLowerCase(MovieName)) = 1) or
(Pos('eine', AnsiLowerCase(MovieName)) = 1) then
begin
MovieName := Trim(Copy(MovieName, 5, Length(MovieName)));
AnalysePage('http://www.ofdb.de/view.php?page=suchergebnis&SText='+UrlEncode(UTF8Encode(MovieName))+'&Kat=All');
end else
begin
ShowMessage('Die Suche nach "' + MovieName +'" ergab kein Ergebnis, bitte den Titel ändern.');
if (Input('OFDb IMDb (DE)', 'Bitte einen anderen Titel eingeben :', MovieName)) and (MovieName <> '') then
AnalysePage('http://www.ofdb.de/view.php?page=suchergebnis&SText='+UrlEncode(UTF8Encode(MovieName))+'&Kat=All');
end;
end else
begin
PickTreeClear;
LineNr := FindLine('<b>Titel:</b>', Page, 0);
if LineNr > 0 then
begin
PickTreeAdd('Suche nach "' + MovieName + '" ergab:', '');
PickTreeMoreLink('dummy');
Address := AddMoviesTitles(Page, LineNr);
if Address = '' then
begin
if PickTreeExec(Address) then
begin
if Address = 'dummy' then
begin
if (Input('Kein passender Titel dabei?', 'Bitte ändern Sie den Titel ab:', MovieName)) and (MovieName <> '') then
AnalysePage('http://www.ofdb.de/view.php?page=suchergebnis&SText='+UrlEncode(UTF8Encode(MovieName))+'&Kat=All')
end else
AnalysePage(Address);
end;
end else
AnalysePage(Address);
end;
end;
end;
Page.Free;
end;
function AddMoviesTitles(Page: TStringList; var LineNr: Integer) : string;
var
Line: string;
Headline, MovieTitle, MovieTitleCopy, MovieAddress: string;
StartPos, HeadlinePos, EndPos, NumTitles: Integer;
Multi: boolean;
begin
Multi := true;
result := '';
Headline := '';
Line := Page.GetString(LineNr);
NumTitles := 0;
MovieTitleCopy := '';
repeat
StartPos := pos('<a href=''view.php?page=film&fid=', Line);
if StartPos < 1 then
StartPos := Pos('<a href=''film/', Line);
if StartPos < 1 then
begin
StartPos := pos('<a href="view.php?page=film&fid=', Line);
Multi := false;
end;
if StartPos < 1 then
begin
StartPos := Pos('<a href="film/', Line);
Multi := false;
end;
if StartPos > 0 then
begin
HeadlinePos := pos('<br><i>', Line);
if (HeadlinePos > 0) and (HeadlinePos < StartPos) then
begin
Headline := copy(Line, HeadlinePos + 7, Pos('</i><br>', Line) - HeadlinePos - 7);
Headline := UTF8Decode(Headline);
HTMLDecode(Headline);
PickTreeAdd(Headline, '');
end;
Delete(Line, 1, StartPos + 8);
MovieAddress := copy(Line, 1, pos('''>', Line) - 1);
if Multi = false then
MovieAddress := copy(Line, 1, pos('" onmouseover=', Line) - 1);
StartPos := pos('''>', Line) + 2;
if Multi = false then
StartPos := pos('">', Line) + 2;
MovieTitle := copy(Line, StartPos, pos('</a>', Line) - StartPos);
MovieTitle := UTF8Decode(MovieTitle);
HTMLRemoveTags(MovieTitle);
if NumTitles > 0 then
begin
if MovieTitleCopy <> MovieTitle then
begin
PickTreeAdd(MovieTitle, 'http://www.ofdb.de/' + MovieAddress);
NumTitles := NumTitles + 1;
end;
end;
if NumTitles = 0 then
begin
NumTitles := NumTitles + 1;
PickTreeAdd(MovieTitle, 'http://www.ofdb.de/' + MovieAddress);
MovieTitleCopy := MovieTitle;
end;
end;
until (StartPos < 1);
if NumTitles = 1 then
result := 'http://www.ofdb.de/' + MovieAddress;
end;
procedure AnalyseOFDBPage(Page: TStringList);
var
Line, Temp, Value, NewURL: string;
LineNr, BeginPos, EndPos: Integer;
DetailPage: TStringList;
// Get IMDb URL
begin
LineNr :=Findline('http://www.imdb.com/Title?', Page, 0);
Line := Page.GetString(LineNr);
BeginPos := pos('Title?', Line)+6;
EndPos := pos('" target', Line);
Value := copy(Line, BeginPos, EndPos - BeginPos);
Value := StringReplace(Value, 'tt', '');
BeginPos := pos('Title?', Line)+6;
EndPos := pos('" target', Line);
Temp := copy(Line, BeginPos, EndPos - BeginPos);
Temp := StringReplace(Temp, 'tt', '');
if Temp <> '' then
ImdbFound := true
else
ImdbFound := false;
Value := ('http://www.imdb.com/title/tt' + Temp + '/');
IMDbURL := Value;
IMDb := TEMP;
// Original & Translated Title
LineNr := FindLine('Originaltitel:</font>', Page, 0);
if LineNr > -1 then
begin
LineNr:= LineNr+2;
Line := Page.GetString(LineNr);
BeginPos := pos('class="Daten"><b>', Line) + 17;
EndPos := pos('</b></font>', Line);
Value := copy(Line, BeginPos, EndPos - BeginPos);
Value := UTF8Decode(Value);
SetField(fieldOriginalTitle, Value);
LineNr := Findline('sans-serif" size="3"><b>', Page, 0);
if LineNr > -1 then
begin
Line:= Page.GetString(LineNr);
BeginPos := pos('sans-serif" size="3"><b>',Line) +24;
Endpos := pos('</b></font></h1></td>',Line);
Value := copy(Line,BeginPos, Endpos-Beginpos);
Value := UTF8Decode(Value);
SetField(fieldTranslatedTitle,Value);
end;
end;
// Picture
LineNr := FindLine('<img src="http://img.ofdb.de/film', Page, 0);
if LineNr > -1 then
begin
Line := Page.GetString(LineNr);
BeginPos := pos('<img src="', Line) + 10;
if BeginPos > 10 then
begin
EndPos := pos(' alt=', Line)-1;
Value := copy(Line, BeginPos, EndPos - BeginPos);
GetPicture(Value);
end;
end;
// Description
if CanSetField(fieldDescription) then
begin
LineNr := Findline('<b>Inhalt:</b>', Page, 0);
if LineNr > -1 then
begin
LineNr := Findline('<a href="view.php?page=inhalt', Page, 0);
if LineNr > -1 then
begin
Line := Page.GetString(LineNr);
BeginPos := pos('<a href="view.php?page=inhalt', Line)+9;
end else
begin
LineNr := Findline ('<a href="plot/', Page, 0);
Line := Page.GetString(LineNr);
BeginPos := pos('<a href="plot/', Line)+9;
end;
EndPos := pos('"><b>[mehr]', Line);
Value := copy(Line, BeginPos, EndPos - BeginPos);
HTMLRemoveTags(Value);
Value := UTF8Decode(Value);
GetDescriptions(Value);
end else
begin
SetField(fieldDescription, '');
end;
end;
// Comments
if CanSetField(fieldComments) then
begin
if GetOption('CommentContent') = 0 then
begin
LineNr := FindLine('Lokale Reviews:', Page, 0);
if LineNr > -1 then
begin
Line := Page.GetString(LineNr);
BeginPos := pos('<a href=', Line)+9;
Line := copy(Line, BeginPos, Length(Line));
EndPos := Pos('">', Line);
Value := copy(Line, 1, EndPos-1);
HTMLRemoveTags(Value);
Value := UTF8Decode(Value);
GetComments(Value);
end else
begin
SetField(fieldComments, '');
end;
end;
end;
end;
procedure GetDescriptions(Address: string);
var
Line, Temp, Value: string;
LineNr, BeginPos, EndPos: Integer;
Page: TStringList;
begin
Temp:= '';
Page := TStringList.Create;
Page.Text := GetPage('http://www.ofdb.de/' + Address);
LineNr := FindLine('Eine Inhaltsangabe von', Page, 0);
if LineNr > -1 then
begin
Line := Page.GetString(LineNr);
BeginPos := pos('</b></b><br><br>', Line)+16;
while (pos('<br />', Line) >0) do
begin
EndPos := pos('<br />', Line);
Temp := Temp + copy(Line, BeginPos, EndPos - BeginPos)+#13#10;
LineNr:=LineNr+1;
Line:=Page.GetString(LineNr);
BeginPos:=1;
end;
EndPos := pos('</font></p>', Line);
Temp:= Temp + copy(Line, BeginPos, EndPos - BeginPos);
Value:= Temp;
Value := UTF8Decode(Value);
BeginPos := pos('<b>Quelle:</b>', Value);
if BeginPos > 0 then
begin
BeginPos := pos('<br><br>', Value);
Delete(Value, 1, BeginPos+7);
end;
SetField(fieldDescription, Value);
end;
Page.Free;
end;
procedure GetComments(Address: string);
var
Line, Temp, Value: string;
LineNr, BeginPos, EndPos: Integer;
Page: TStringList;
begin
Temp := '';
Page := TStringList.Create;
Page.Text := GetPage('http://www.ofdb.de/' + Address);
LineNr := FindLine('Eine Kritik von <a ', Page, 0);
if LineNr > 0 then
begin
LineNr := LineNr+1;
Line := Page.GetString(LineNr);
BeginPos := 1;
if pos('class="Blocksatz"', Line) > 0 then
begin
BeginPos := pos('class="Blocksatz"', Line)+39;
Delete(Line, 1, BeginPos);
Temp := Temp + Line;
LineNr := LineNr+1;
Line := Page.GetString(LineNr);
end;
while (pos('</font></p>', Line) = 0) do
begin
Temp := Temp + Line;
LineNr := LineNr+1;
Line := Page.GetString(LineNr);
end;
EndPos := pos('</font></p>', Line);
Temp := Temp + copy(Line, 1, EndPos);
Temp := StringReplace(Temp, '<br />', #13#10);
Temp := StringReplace(Temp, '…', '...');
Temp := StringReplace(Temp, '–', '-');
Value := Temp;
Value := UTF8Decode(Value);
HTMLDecode(Value);
HTMLRemoveTags(Value);
SetField(fieldComments, Value);
end else
begin
SetField(fieldComments, '');
end;
Page.Free;
end;
procedure AnalyseIMDBPage(Page: TStringList);
var
Line, Value, Value2, FullValue: string;
BeginPos, EndPos, LineNr: Integer;
begin
Page.Text := GetPage(IMDbURL);
// start edit by crap_inhuman
(* Not implemented yet
// Producers
LineNr := FindLine('">Produced by', Page, 0);
if LineNr > -1 then
begin
Value := '';
EndPos := 0;
Line := Page.GetString(LineNr);
BeginPos := Pos('>Produktion<', Line);
EndPos := Pos(' name="music_original"', Line);
if EndPos = 0 then
EndPos := Pos(' name="cinematographers"', Line);
Line := copy(Line, BeginPos, EndPos - BeginPos);
BeginPos := pos('/">', Line) + 2;
Delete(Line, 1, BeginPos);
EndPos := pos('</a>', Line);
Value := copy(Line, 1, EndPos - 1);
repeat
Delete(Line, 1, EndPos);
BeginPos := pos('/">', Line) + 3;
if BeginPos > 3 then
begin
EndPos := pos('</a>', Line);
Value := Value + ProducersSeparator + copy(Line, BeginPos, EndPos - BeginPos);
end;
until (Line = '') or (BeginPos = 3);
Value := StringReplace(Value, ',,', ',');
Value := StringReplace(Value, ', ,', ',');
Value := UTF8Decode(Value);
HTMLDecode(Value);
SetField(fieldProducer, Value);
end;
*)
// end edit by crap_inhuman
// IMDb Rating
if CanSetField(fieldRating) then
begin
LineNr := FindLine('"ratingValue"', Page, 0);
if LineNr > -1 then
begin
Line := Page.GetString(LineNr);
BeginPos := pos('"ratingValue"', Line) + 14;
EndPos := BeginPos + 3;
Value := copy(Line, BeginPos, EndPos - BeginPos);
SetField(fieldRating, Value);
end;
end;
// Year
if CanSetField(fieldYear) then
begin
LineNr := FindLine('<title>', Page, 0);
if LineNr > -1 then
begin
Line := Page.GetString(LineNr);
BeginPos := pos('(', Line) + 1;
if BeginPos > 0 then
begin
EndPos := pos(')', Line);
BeginPos := EndPos - 4;
Value := copy(Line, BeginPos, EndPos - BeginPos);
SetField(fieldYear, Value);
end;
end;
end;
// Directors
if CanSetField(fieldDirector) then
begin
LineNr := FindLine('Directors:', Page, 0);
if LineNr = -1 then
LineNr := FindLine('Director:', Page, 0);
if LineNr > -1 then
begin
Value := '';
repeat
LineNr := FindLine('itemprop="director"', Page, LineNr);
LineNr := LineNr + 2;
Line := Page.GetString(LineNr);
BeginPos := pos('"name">', Line) + 7;
EndPos := pos('</span>', Line);
If Value <> '' then
Value := Value + DirectorsSeparator;
Value := Value + copy(Line, BeginPos, EndPos - BeginPos);
until FindLine('itemprop="director"', Page, LineNr) = -1;
Value := UTF8Decode(Value);
HTMLDecode(Value);
SetField(fieldDirector, Value);
end;
end;
// Actors
if CanSetField(fieldActors) then
begin
LineNr := FindLine('Cast overview', Page, 0);
if LineNr = -1 then
LineNr := FindLine('cast overview', Page, 0);
if LineNr = -1 then
LineNr := FindLine('redited cast', Page, 0);
if LineNr = -1 then
LineNr := FindLine('cast summary:', Page, 0);
if LineNr > -1 then
begin
FullValue := '';
repeat
Value2 := '';
LineNr := FindLine('itemprop="actor"', Page, LineNr);
LineNr := LineNr + 1;
Line := Page.GetString(LineNr);
BeginPos := pos('"name">', Line) + 7;
EndPos := pos('</span>', Line);
Value := copy(Line, BeginPos, EndPos - BeginPos);
LineNr := FindLine('<td class="character">', Page, LineNr);
LineNr := LineNr + 2;
Line := Page.GetString(LineNr);
BeginPos := pos('>', Line) + 1;
EndPos := pos('</a>', Line);
If BeginPos > 3 then
Value2 := copy(Line, BeginPos, EndPos - BeginPos)
else
Value2 := Trim(Line);
if (Value2 <> '') and (Value2 <> '</td>') then
begin
if Trim(Page.Getstring(LineNr + 1)) = '(voice)' then
Value2 := Value2 + ' (voice)';
Value := Value + ' (als ' + Value2 + ')';
end;
if FullValue <> '' then
if GetOption('ActorsLayout') < 2 then
FullValue := FullValue + ActorsSeparator
else
FullValue := FullValue + #13#10;
FullValue := FullValue + Value;
until FindLine('itemprop="actor"', Page, LineNr) < 1;
FullValue := UTF8Decode(FullValue);
HTMLRemoveTags(FullValue);
HTMLDecode(FullValue);
SetField(fieldActors, FullValue);
end;
end;
// Length (from imdb.com, if possible)
if CanSetField(fieldLength) then
begin
LineNr := FindLine('Runtime:', Page, 0);
if LineNr > -1 then
begin
Line := Page.GetString(LineNr + 2);
BeginPos := pos('">', Line) + 2;
EndPos := pos(' min', Line);
Line := copy(Line, BeginPos, EndPos - BeginPos);
Line := Trim(Line);
SetField(fieldLength, Line);
end;
end;
// Language
if CanSetField(fieldLanguages) then
begin
LineNr := FindLine('Language:', Page, 0);
if LineNr > -1 then
begin
Value := '';
repeat
LineNr := FindLine('href="/language/', Page, LineNr);
Line := Page.GetString(LineNr + 1);
BeginPos := pos('>', Line) + 1;
EndPos := pos('</a>', Line);
If Value <> '' then
Value := Value + LanguagesSeparator;
Value := Value + copy(Line, BeginPos, EndPos - BeginPos);
LineNr := LineNr + 1;
until FindLine('href="/language/', Page, LineNr) < 1;
Value := UTF8Decode(Value);
HTMLDecode(Value);
SetField(fieldLanguages, Value);
end;
end;
// Countries
if CanSetField(fieldCountry) then
begin
LineNr := FindLine('Country:', Page, 0);
if LineNr > -1 then
begin
Value := '';
repeat
LineNr := FindLine('href="/country/', Page, LineNr);
Line := Page.GetString(LineNr);
BeginPos := pos('>', Line) + 1;
EndPos := pos('</a>', Line);
If Value <> '' then
Value := Value + CountriesSeparator;
Value := Value + copy(Line, BeginPos, EndPos - BeginPos);
LineNr := LineNr + 1;
until FindLine('href="/country/', Page, LineNr) < 1;
Value := UTF8Decode(Value);
HTMLDecode(Value);
SetField(fieldCountry, Value);
end;
end;
// Categories
if CanSetField(fieldCategory) then
begin
LineNr := FindLine('Genres:', Page, 0);
if LineNr > -1 then
begin
Value := '';
LineNr := LineNr + 1;
repeat
LineNr := FindLine('href="/genre/', Page, LineNr);
Line := Page.GetString(LineNr);
BeginPos := pos('>', Line) + 2;
EndPos := pos('</a>', Line);
If Value <> '' then
Value := Value + CategoriesSeparator;
Value := Value + copy(Line, BeginPos, EndPos - BeginPos);
LineNr := LineNr + 1;
until FindLine('href="/genre/', Page, LineNr) < 1;
Value := UTF8Decode(Value);
HTMLDecode(Value);
SetField(fieldCategory, Value);
end;
end;
//AspectRatio
if GetOption('AspectRatio') > 0 then
begin
LineNr := FindLine('Aspect Ratio:', Page, 0);
if LineNr > -1 then
begin
Line := Page.GetString(LineNr);
BeginPos := pos('Aspect Ratio:', Line) + 19;
Line := copy(Line, BeginPos , Length(Line) - BeginPos + 2);
if (CanSetField(fieldResolution)) and (GetOption('AspectRatio') = 1) then
SetField(fieldResolution, Line);
if (CanSetField(fieldVideoFormat)) and (GetOption('AspectRatio') = 2) then
SetField(fieldVideoFormat, Line);
end;
end;
// Comments
Value := '';
if CanSetField(fieldComments) then
begin
LineNr := FindLine('href="reviews"', Page, 0);
if LineNr > -1 then
begin
Page.Text := GetPage(IMDbURL + 'reviews');
LineNr := FindLine('<a href="/user/', Page, 0);
if LineNr > -1 then
begin
LineNr := FindLine('<p>', Page, LineNr);
if LineNr > -1 then
begin
LineNr := LineNr + 1;
repeat
Line := Page.GetString(LineNr);
Value := Value + Line + ' ';
LineNr := LineNr + 1;
until pos('</p>', Line) > 0;
LineNr := FindLine('<a href="/user/', Page, 0);
Line := Page.GetString(LineNr);
BeginPos := pos('/comments">', Line) + 11;
EndPos := pos('</a>', Line);
Value := Value + ' by ' + copy(Line, BeginPos, EndPos - BeginPos);
end;
end;
Value := UTF8Decode(Value);
HTMLDecode(Value);
HTMLRemoveTags(Value);
if ((GetOption('CommentContent') = 0) And (GetField(fieldComments) = '')) Or (GetOption('CommentContent') = 1) then
SetField(fieldComments, Value);
end;
end;
if GetOption('DescriptionContent') = 0 then
begin
if GetField(fieldDescription) = '' then
begin
LineNr := FindLine('href="plotsummary"', Page, 0);
if LineNr > -1 then
begin
Page.Text := GetPage(IMDbURL + 'plotsummary');
LineNr := FindLine('<p class="plotpar">', Page, 0);
if LineNr > -1 then
begin
LineNr := LineNr -1;
Value := '';
repeat
LineNr := FindLine('<p class="plotpar">', Page, LineNr);
LineNr := LineNr + 1;
Line := Page.GetString(LineNr + 3);
BeginPos := pos('">', Line) + 2;
EndPos := pos('</a>', Line);
Value2 := copy(Line, BeginPos, EndPos - BeginPos);
Value := Value + Page.GetString(LineNr) + ' - Written by ' + Value2 + #13#10 + #13#10;
until FindLine('<p class="plotpar">', Page, LineNr) < 1;
end;
Value := UTF8Decode(Value);
HTMLDecode(Value);
HTMLRemoveTags(Value);
SetField(fieldDescription, Value);
end;
end;
end;
end;
// this procedure only, if no IMDB-Nr. is found or AllFromOFDB-Option is set to 1
// or info not found at IMDB
procedure AnalyseOFDBPageMore(Address: String);
var
DetailPage, Page: TStringList;
Line, Temp, Value: string;
LineNr, BeginPos, EndPos: Integer;
DetailFound: boolean;
begin
DetailFound := false;
Page := TStringList.Create;
Page.Text := GetPage(Address);
// Country
LineNr := FindLine('Herstellungsland:', Page, 0);
if LineNr > -1 then
begin
Value := '';
LineNr := LineNr + 2;
Line := Page.GetString(LineNr);
repeat
Delete(Line, 1, pos('<a href="', Line));
BeginPos := pos('">', Line) + 2;
if BeginPos > 2 then
begin
EndPos := pos('</a>', Line);
if Value <> '' then
Value := Value + CountriesSeparator;
Value := Value + copy(Line, BeginPos, EndPos - BeginPos);
end;
until pos('<a href="', Line) < 1;
Value := UTF8Decode(Value);
if (GetOption('AllFromOFDB') = 1) Or (GetField(fieldCountry) = '') then
SetField(fieldCountry, Value);
end;
// Year
LineNr := FindLine('Erscheinungsjahr:', Page, 0);
if LineNr > -1 then
begin
LineNr := LineNr + 2;
Line := Page.GetString(LineNr);
Delete(Line, 1, pos('<a href="', Line));
BeginPos := pos('">', Line) + 2;
EndPos := pos('</a>', Line);
Value := copy(Line, BeginPos, EndPos - BeginPos);
Value := UTF8Decode(Value);
if ((GetOption('AllFromOFDB') = 1) Or (GetField(fieldYear) = '')) and (Value <> '') then
SetField(fieldYear, Value);
end;
// Directors
LineNr := FindLine('Regie:', Page, 0);
if LineNr > -1 then
begin
Value := '';
LineNr := LineNr + 2;
Line := Page.GetString(LineNr);
// start edit by crap_inhuman
repeat
BeginPos := pos('<span itemprop="name">', Line);
if BeginPos > 2 then
begin
Delete(Line, 1, pos('<span itemprop="name">', Line));
EndPos := pos('</span>', Line);
if Value <> '' then
Value := Value + DirectorsSeparator;
Value := Value + copy(Line, 22, EndPos - 22);
end;
until pos('<span itemprop="name">', Line) < 1;
// end edit by crap_inhuman
Value := UTF8Decode(Value);
if ((GetOption('AllFromOFDB') = 1) Or (GetField(fieldDirector) = '')) and (Value <> '') then
SetField(fieldDirector, Value);
end;
// Actors
LineNr := FindLine('Darsteller:', Page, 0);
if LineNr > -1 then
begin
Value := '';
LineNr := LineNr + 2;
Line := Page.GetString(LineNr);
// start edit by crap_inhuman
If pos('[mehr]', Line) > 0 then
begin
DetailFound := true;
BeginPos := AnsiLastPosEx('<a href="', Line, false, false);
EndPos := AnsiPosEx2('">[mehr]', Line, false, false, BeginPos);
DetailPage := TStringList.Create;
DetailPage.Text := GetPage('http://www.ofdb.de/' + copy(Line, BeginPos + 9, EndPos - BeginPos - 9));
LineNr := FindLine('<b><i>Darsteller</i></b>', DetailPage, 0);
if LineNr > -1 then
begin
LineNr := LineNr + 4;
repeat
Temp := '';
Line := DetailPage.GetString(LineNr);
BeginPos := AnsiLastPosEx('">', Line, false, false);
EndPos := AnsiPosEx2('</', Line, false, false, BeginPos);
Temp := copy(Line, BeginPos + 2, EndPos - BeginPos -2);
Temp := StringReplace(Temp, '<b>', '');
LineNr := LineNr + 2;
Line := DetailPage.GetString(LineNr);
if (pos('<td></td>', Line) = 0) and (pos('... ', Line) > 0) then
begin
BeginPos := AnsiPosEx('... ', Line, false, false);
EndPos := AnsiPosEx2('<', Line, false, false, BeginPos);
Temp := Temp + ' (als ' + copy(Line, BeginPos + 4, EndPos - BeginPos -4) + ')';
end;
LineNr := LineNr + 4;
if Value <> '' then
Value := Value + ActorsSeparator;
Value := Value + Temp;
Line := DetailPage.GetString(LineNr);
until pos('class="', Line) < 1;
end;
end else
begin
repeat
Temp := '';
BeginPos := pos('<span itemprop="name">', Line);
if BeginPos > 0 then
begin
EndPos := AnsiPosEx2('</span>', Line, false, false, BeginPos);
Temp := copy(Line, BeginPos + 22, EndPos - BeginPos - 22);
Delete(Line, 1, BeginPos + 22);
if Value <> '' then
Value := Value + ActorsSeparator;
Value := Value + Temp;
end;
until pos('<span itemprop="name">', Line) < 1;
end;
// end edit by crap_inhuman
Value := UTF8Decode(Value);
if ((GetOption('AllFromOFDB') = 1) Or (GetField(fieldActors) = '')) and (Value <> '') then
SetField(fieldActors, Value);
end;
// Categories
LineNr := FindLine('Genre(s):', Page, 0);
if LineNr > -1 then
begin
Value := '';
LineNr := LineNr + 2;
Line := Page.GetString(LineNr);
repeat
Delete(Line, 1, pos('<a href="', Line));
BeginPos := pos('">', Line) + 2;
if BeginPos > 2 then
begin
EndPos := pos('</a>', Line);
if Value <> '' then
Value := Value + CategoriesSeparator;
Value := Value + copy(Line, BeginPos, EndPos - BeginPos);
end;
until pos('<a href="', Line) < 1;
Value := UTF8Decode(Value);
if Value <> '' then
begin
HtmlRemoveTags(Value);
if ((GetOption('AllFromOFDB') = 1) Or (GetField(fieldCategory) = '')) and (Value <> '') then
SetField(fieldCategory, Value);
end;
end;
// Rating
LineNr := Findline('Note: <span itemprop="ratingValue">', Page, 0);
if LineNr > -1 then
begin
Line:= Page.GetString(LineNr);
BeginPos := Pos('Note: <span itemprop="ratingValue">',Line) + 35;
// I had to add 0.1 here to make the rounding more precise
Value := IntToStr(Round((StrToInt(Copy(Line, BeginPos+2, 2), 0) + 0.1) / 10));
if StrToInt(Value,0) > 9 then
Value := IntToStr(StrToInt(StrGet(Line, BeginPos),0) + 1) + '.0'
else
Value := StrGet(Line, BeginPos) + '.' + Value;
if ((GetOption('AllFromOFDB') = 1) Or (GetField(fieldRating) = '')) and (Value <> '') then
SetField(fieldRating, Value);
end;
// Producers
// start edit by crap_inhuman
if DetailFound = true then
begin
Value := '';
LineNr := FindLine('Produzent(in)', DetailPage, 0);
if LineNr > -1 then
begin
LineNr := LineNr + 4;
Line := DetailPage.GetString(LineNr);
repeat
Temp := '';
Line := DetailPage.GetString(LineNr);
BeginPos := AnsiLastPosEx('">', Line, false, false);
EndPos := AnsiPosEx2('</', Line, false, false, BeginPos);
Temp := copy(Line, BeginPos + 2, EndPos - BeginPos -2);
Temp := StringReplace(Temp, '<b>', '');
LineNr := LineNr + 6;
if Value <> '' then
Value := Value + ProducersSeparator;
Value := Value + Temp;
Line := DetailPage.GetString(LineNr);
until pos('class="', Line) < 1;
end;
// end edit by crap_inhuman
Value := UTF8Decode(Value);
if ((GetOption('AllFromOFDB') = 1) Or (GetField(fieldProducer) = '')) and (Value <> '') then
SetField(fieldProducer, Value);
end;
end;
begin
if CheckVersion(3,5,0) then
begin
MovieName := GetField(fieldTranslatedTitle);
if MovieName = '' then
MovieName := GetField(fieldOriginalTitle);
if MovieName = '' then
Input('OFDb', 'Bitte Titel eingeben :', MovieName);
SetSeparators;
AnalysePage('http://www.ofdb.de/view.php?page=suchergebnis&Kat=Titel&SText='+StringReplace(UrlEncode(UTF8Encode(MovieName)),'&%','%26%'));
end
else
ShowMessage('Dieses Script benötigt eine neuere Version von Ant Movie Catalog (mindestens Version 3.5.0)');
end.
-
- Posts: 863
- Joined: 2006-08-31 23:58:18
Hi,
The "checkversion" of this 1.8.8 version is bad, because the ansilastposex function appeared only since 4.1.2 AMC version.
So upgrading to 4.1.2 version is the only solution. You can find this stable version here.
Don't forget to save your(s) database(s) in a save place before any upgrade.
The "checkversion" of this 1.8.8 version is bad, because the ansilastposex function appeared only since 4.1.2 AMC version.
So upgrading to 4.1.2 version is the only solution. You can find this stable version here.
Don't forget to save your(s) database(s) in a save place before any upgrade.
-
- Posts: 17
- Joined: 2011-12-22 21:42:40
Hi,
thanks for the hint with checkversion. I forgot to adjust it.
I have a new version 1.8.9 of this script. I add the import of the Writer and Producer from IMDb.
Download it from here : http://www.germanc64.de/OFDb - IMDb (DE).ifs
thanks for the hint with checkversion. I forgot to adjust it.
I have a new version 1.8.9 of this script. I add the import of the Writer and Producer from IMDb.
Download it from here : http://www.germanc64.de/OFDb - IMDb (DE).ifs
-
- Posts: 17
- Joined: 2011-12-22 21:42:40
Hi,
There is a new version 1.9.0 of this script. I repaired the IMDB query.
Please download it from here : http://www.germanc64.de/OFDb - IMDb (DE).ifs
There is a new version 1.9.0 of this script. I repaired the IMDB query.
Please download it from here : http://www.germanc64.de/OFDb - IMDb (DE).ifs
-
- Posts: 17
- Joined: 2011-12-22 21:42:40
New Version
Hi,
i improved/repaired the title search in the script.
Version 1.9.1
http://www.germanc64.de/OFDb - IMDb (DE).ifs
Greets
i improved/repaired the title search in the script.
Version 1.9.1
http://www.germanc64.de/OFDb - IMDb (DE).ifs
Greets
-
- Posts: 17
- Joined: 2011-12-22 21:42:40
-
- Posts: 17
- Joined: 2011-12-22 21:42:40
New Version
Hi,
i updated the script to 1.9.4, fixing 2 small bugs.
http://www.germanc64.de/OFDb - IMDb (DE).ifs
Greetings
Sven
i updated the script to 1.9.4, fixing 2 small bugs.
http://www.germanc64.de/OFDb - IMDb (DE).ifs
Greetings
Sven
Re: New Version
Thanks for the update; I'm not sure why your message does not appear except when trying quoting it (or is it just for me that there is an empty post here above?)
And if I quote it in my message, mine does not appear either.
And if I quote it in my message, mine does not appear either.
-
- Posts: 17
- Joined: 2011-12-22 21:42:40
That's weird. :-) If i enable BBCode my message disappear.
I updated the script to Version 1.9.4.
[url]http://www.germanc64.de/OFDb - IMDb (DE).ifs[/url]
Greetings
Sven
I updated the script to Version 1.9.4.
[url]http://www.germanc64.de/OFDb - IMDb (DE).ifs[/url]
Greetings
Sven