(***************************************************
Ant Movie Catalog importation script
www.antp.be/software/moviecatalog/
[Infos]
Authors=HappyTalk (Modified version of original script by Antoine Potten & KaraGarga)
Title=Auto.IMDB.com
Description=Import data & picture from IMDB (optional large image from Amazon.com)
Site=us.imdb.com
Language=EN
Version=2.05
Requires=3.5.0
Comments=Based on the script made for version 3.x by Antoine Potten, Danny Falkov, Kai Blankenhorn, lboregard, Ork, Trekkie, Youri Heijnen||Modified by HappyTalk to fix large amazon pic import, and a few other things
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]
ImageKind=0|1|0=No image|1=Import from Amazon.com. Prompt with movie selector|2=Import from Amazon.com. No prompts, use first movie cover
BatchMode=0|0|0=Normal working mode, prompts user when needed|1=Does not display any window, takes the first movie found|2=Same as 1, but it uses the URL field if available to update movie information|3=Only updates using current URL field
PopularSearches=1|1|0=Do not use the popular searches page, directly show full search results|1=Show popular searches first, I'll click on "Find more" if needed (much faster)
ActorsLayout=0|2|0=Only actor names, separated by commas|1=Only actor names, separated by linebreaks|2=Actors names with character names between parenthesis separated by commas|3=Actors names with character names between parenthesis separated by linebreaks|4=Actor names like on IMDB page, with "...." and separated by linebreaks
MultipleValuesCountry=0|0|0=Only take first value for Country|1=Take full list, separated by commas|2=Take full list, separated by slashes
MultipleValuesCategory=1|0|0=Only take first value for Category|1=Take full list, separated by commas|2=Take full list, separated by slashes
MultipleValuesLanguages=0|0|0=Only take first value for Languages|1=Take full list, separated by commas|2=Take full list, separated by slashes
DescriptionSelection=2|1|0=Take the short summary, from main page (faster)|1=Show a list of available summaries|2=Take the longest summary|3=Take the shortest summary
GetTagline=0|0|0=Do not get tagline|1=Put it in Description field, before the summary|2=Put it in the Comment field, before the comments
Trivia=0|0|0=Do not import trivia|1=Import trivia to Description field, after the summary|2=Import trivia to Comments field, after the comments
AmazonReview=0|0|0=Do not get Amazon Review|1=Get Amazon Review
CommentType=2|0|0=Standard Type (Only one comment from main page)|1=Detailed Type (10 most useful comments from comments page)|2=No user comment
Awards=0|0|0=Do not import awards|1=Import awards to Description field, after the summary|2=Import awards to Comments field, after comments
***************************************************)
program Auto_IMDB_com;
uses
StringUtils1, AutoUtils;
const
// IMDB_URL = 'http://us.imdb.com';
IMDB_URL = 'http://former.imdb.com';
var
MovieName: string;
MovieURL: string;
MovieNumber: string;
// ***** analyzes the results page that asks to select a movie from a list *****
procedure AnalyzeResultsPage(Address: string);
var
PageText: string;
Value: string;
begin
PageText := GetPage(Address);
if pos('
');
List := RemainingText;
end;
end;
// ***** analyzes the page containing movie information *****
procedure AnalyzeMoviePage(PageText: string);
var
Value, Value2, Value3, FullValue, sMovieTitle: string;
p: Integer;
begin
MovieNumber := TextBetween(PageText, '', '');
Value2 := TextBefore(Value, ' (', '');
Value := RemainingText;
HTMLDecode(Value2);
sMovieTitle := value2;
if CanSetField(fieldOriginalTitle) then SetField(fieldOriginalTitle, sMovieTitle);
// fieldYear
if Pos('/', Value) > 0 then
Value2 := TextBefore(Value, '/', '')
else
Value2 := TextBefore(Value, ')', '');
if CanSetField(fieldYear) then SetField(fieldYear, Value2);
// Rating
if CanSetField(fieldRating) then
begin
Value := TextBetween(PageText, '/rating-stars/', '/rating-vote/');
SetField(fieldRating, TextBetween(Value, '', '/'));
end;
// Picture
if CanSetPicture then
begin
case GetOption('ImageKind') of
1: ImportAmazonPicture(sMovieTitle, true);
2: ImportAmazonPicture(sMovieTitle, false);
end;
end;
// Director
if CanSetField(fieldDirector) then
begin
Value := TextBetween(PageText, 'Directed by ', ' ' + #13);
Value := StringReplace(TextAfter(Value, '">'), ' ', ', ');
HTMLRemoveTags(Value);
HTMLDecode(Value);
SetField(fieldDirector, Value);
end;
// Actors
if CanSetField(fieldActors) then
begin
Value := TextBetween(PageText, 'ast overview', '');
if Value = '' then
Value := TextBetween(PageText, 'redited cast', '');
if Value = '' then
Value := TextBetween(PageText, 'Cast:', '');
if Value = '' then
Value := TextBetween(PageText, 'ast Summary:', '');
if Value <> '' then
begin
Value := Trim(TextAfter(Value, ''));
FullValue := '';
case GetOption('ActorsLayout') of
0, 1:
while Pos('
', Value) > 0 do
begin
Value2 := TextBetween(Value, '
');
Value := RemainingText;
if Pos('rest of cast', Value2) > 0 then
Continue;
if Pos('(more)', Value2) > 0 then
Break;
if FullValue <> '' then
FullValue := FullValue + #13#10;
TextBefore(Value2, '', '');
Value2 := TextBetween(RemainingText, '/">', '');
if Value2 <> '' then
FullValue := FullValue + Value2;
end;
(*
0, 1:
while Pos('
', Value) > 0 do
begin
Value2 := TextBetween(Value, '
', '
');
Value := RemainingText;
if Pos('rest of cast', Value2) > 0 then
Continue;
if Pos('(more)', Value2) > 0 then
Break;
if FullValue <> '' then
FullValue := FullValue + #13#10;
FullValue := FullValue + TextBefore(Value2, '', '');
end;
*)
2, 3:
while Pos('
', Value) > 0 do
begin
Value2 := TextBetween(Value, '
');
Value := RemainingText;
if Pos('rest of cast', Value2) > 0 then
Continue;
if Pos('(more)', Value2) > 0 then
Break;
if FullValue <> '' then
FullValue := FullValue + #13#10;
TextBefore(Value2, '', '');
Value2 := TextBetween(RemainingText, '/">', '');
if Value2 <> '' then
begin
FullValue := FullValue + Value2;
Value2 := TextBetween(RemainingText, 'e">', '');
if Value2 <> '' then
FullValue := FullValue + ' (as ' + Value2 + ')';
end;
end;
(*
2, 3:
while Pos('
', Value) > 0 do
begin
Value2 := TextBetween(Value, '
', '
');
Value := RemainingText;
if Pos('rest of cast', Value2) > 0 then
Continue;
if Pos('(more)', Value2) > 0 then
Break;
if FullValue <> '' then
FullValue := FullValue + #13#10;
FullValue := FullValue + TextBefore(Value2, '', '');
Value2 := TextBetween(RemainingText, '
', '
');
if Value2 <> '' then
FullValue := FullValue + ' (as ' + Value2 + ')';
end;
*)
4:
begin
FullValue := TextBefore(Value, '
', '');
if FullValue = '' then
FullValue := Value;
FullValue := StringReplace(FullValue, '
rest of cast listed alphabetically:
', '');
FullValue := StringReplace(FullValue, '', #13#10);
end;
end;
HTMLRemoveTags(FullValue);
HTMLDecode(FullValue);
case GetOption('ActorsLayout') of
0, 2:
FullValue := StringReplace(FullValue, #13#10, ', ');
end;
// SetField(fieldActors, FullValue);
SetField(fieldActors, FixActors(FullValue)); //xxx Run through FixActors to leave just comma sep'd actors
end;
end;
//Country
if CanSetField(fieldCountry) then
begin
SetField(fieldCountry, ImportList(PageText, GetOption('MultipleValuesCountry'), '/Countries/'));
end;
//Category only set for _M.ovies
if CanSetField(fieldCategory) then
begin
//value := GetField(fieldCategory); //xxx If blank or _M.ovie ensure _Movie is appended, else leave alone
//if (value = '') or (pos('_M.ovie',value) > 0) then
SetField(fieldCategory, ImportList(PageText, GetOption('MultipleValuesCategory'), '/Genres/')); // + ',_M.ovie');
end;
// Language
if CanSetField(fieldLanguages) then
begin
SetField(fieldLanguages, ImportList(PageText, GetOption('MultipleValuesLanguages'), '/Languages/'));
end;
// Description
if CanSetField(fieldDescription) then
begin
Value := TextBetween(PageText, 'Plot Outline:', '
');
if Value = '' then
Value := TextBetween(PageText, 'Plot Summary:', '