i think imdb script is broken
i think imdb script is broken
when there is two movies of the same name, there is a dialog for you to choose, before there is the year of movie is make now it is gone.
IMDB script change...
Ok.. I've been adding about 4 movies a day for months now. Now that it's broke, I realize how much I need this program. Time to get out the card and send $25 or so. Darn Micro$oft would leave us hanging on a problem like this, or blame IMDB. Thanks Antp!
Indeed... (unless u had travelled back in time )antp wrote:If it was working yesterday, a script corrected two weeks ago cannot fix something that changed today
I only looked at the date of your last post (where u explained the changes u made) and did not notice the date for the post with the 3 files was different.
My bad
I think i've fixed it
IMDB seems to change everything in search module. Therefore I have add new procedures from All Movie script, because their background became similar.
I'm not professional. There might be better solutions
Anyway this one works... Hope it'll help...
IMDB (Small Picture)
IMDB seems to change everything in search module. Therefore I have add new procedures from All Movie script, because their background became similar.
I'm not professional. There might be better solutions
Anyway this one works... Hope it'll help...
IMDB (Small Picture)
Code: Select all
// GETINFO SCRIPTING
// IMDB (US) import with small picture
(***************************************************
* Movie importation script for: *
* IMDB (US), http://us.imdb.com *
* *
* (c) 2002-2004 Antoine Potten *
* software@antp.be *
* Contributors : *
* Danny Falkov *
* Kai Blankenhorn *
* *
* For use with Ant Movie Catalog 3.4.0 *
* www.antp.be/software/moviecatalog *
* *
* 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. *
***************************************************)
program IMDb;
const
DescriptionToImport = 2;
{
2 = import longest
1 = import short (from main page, faster)
0 = display list to select a description
}
var
MovieName: string;
MovieURL: string;
function FindLine(Pattern: string; List: TStringList; StartAt: Integer): Integer;
var
i: Integer;
begin
result := -1;
if StartAt < 0 then
StartAt := 0;
for i := StartAt to List.Count-1 do
if Pos(Pattern, List.GetString(i)) <> 0 then
begin
result := i;
Break;
end;
end;
procedure CutAfter(var Str: string; Pattern: string);
begin
Str := Copy(str, Pos(Pattern, Str) + Length(Pattern), Length(Str));
end;
procedure CutBefore(var Str: string; Pattern: string);
begin
Str := Copy(Str, Pos(Pattern, Str), Length(Str));
end;
// Extracts single movie detail (like director, genre) from page
function GetStringFromHTML(Page, StartTag, CutTag, EndTag: string): string;
begin
Result := '';
// recognition tag - if present, extract detail from page, otherwise assume detail is not present
if Pos(StartTag, Page) > 0 then begin
CutBefore(Page, StartTag);
// optional cut tag helps finding right string in html page
if Length(CutTag) > 0 then
CutAfter(Page, CutTag);
// movie detail copied with html tags up to end string
Result := Copy(Page, 0, Pos(EndTag, Page) - 1);
// remove html tags and decode html string
HTMLRemoveTags(Result);
HTMLDecode(Result);
// ShowMessage('DEBUG: GetStringFromHTML - StartTag "'+StartTag+'", CutTag "'+CutTag+'", EndTag "'+EndTag+'", Result "'+Result+'" ___ '+Page);
end;
end;
procedure AnalyzePage(Address: string);
var
Page: TStringList;
begin
Page := TStringList.Create;
Page.Text := GetPage(Address);
if pos('<title>IMDb', Page.Text) = 0 then
begin
AnalyzeMoviePage(Page)
end else
begin
PickTreeClear;
PickTreeAdd('Search results', '');
AddMoviesTitles(Page);
if PickTreeExec(Address) then
AnalyzePage(Address);
end;
Page.Free;
end;
procedure AnalyzeMoviePage(Page: TStringList);
var
Line, Value, Value2, FullValue: string;
LineNr: Integer;
BeginPos, EndPos, DescrImport: Integer;
begin
DescrImport := DescriptionToImport;
if (DescrImport <> 1) and (Pos('<a href="plotsummary">', Page.Text) = 0) then
DescrImport := 1;
MovieURL := 'http://imdb.com/title/tt' + Copy(Page.Text, Pos('<option>Your Vote</option>', Page.Text) - 9, 7);
// URL
SetField(fieldURL, MovieURL);
// Original Title & Year
LineNr := FindLine('<title>', Page, 0);
Line := Page.GetString(LineNr);
if LineNr > -1 then
begin
BeginPos := pos('<title>', Line);
if BeginPos > 0 then
BeginPos := BeginPos + 7;
EndPos := pos('(', Line);
if EndPos = 0 then
EndPos := Length(Line);
Value := copy(Line, BeginPos, EndPos - BeginPos - 1);
HTMLDecode(Value);
SetField(fieldOriginalTitle, Value);
BeginPos := pos('(', Line) + 1;
if BeginPos > 0 then
begin
EndPos := Pos('/I', Line);
if EndPos < BeginPos then
EndPos := Pos(')', Line);
Value := copy(Line, BeginPos, EndPos - BeginPos);
SetField(fieldYear, Value);
end;
end;
// Rating
LineNr := FindLine('User Rating:', Page, 0);
if LineNr > -1 then
begin
Line := Page.GetString(LineNr + 4);
if Pos('/10', Line) > 0 then
begin
BeginPos := pos('<b>', Line) + 3;
Value := IntToStr(Round(StrToInt(StrGet(Line, BeginPos), 0) + (StrToInt(StrGet(Line, BeginPos + 2), 0) / 10)));
SetField(fieldRating, Value);
end;
end;
// Picture
LineNr := FindLine('<img border="0"', Page, 0);
if LineNr > -1 then
begin
Line := Page.GetString(LineNr);
BeginPos := pos('src="', Line) + 4;
Delete(Line, 1, BeginPos);
EndPos := pos('"', Line);
Value := copy(Line, 1, EndPos - 1);
GetPicture(Value, False); // False = do not store picture externally ; store it in the catalog file
end;
// Director
LineNr := FindLine('Directed by', Page, 0);
if LineNr > -1 then
begin
FullValue := '';
Line := Page.GetString(LineNr + 1);
repeat
BeginPos := pos('">', Line) + 2;
EndPos := pos('</a>', Line);
Value := copy(Line, BeginPos, EndPos - BeginPos);
if (Value <> '(more)') and (Value <> '') then
begin
if FullValue <> '' then
FullValue := FullValue + ', ';
FullValue := FullValue + Value;
end;
Delete(Line, 1, EndPos);
until Pos('</a>', Line) = 0;
HTMLDecode(FullValue);
SetField(fieldDirector, FullValue);
end;
// Actors
LineNr := FindLine('ast overview', Page, 0);
if LineNr = -1 then
LineNr := FindLine('redited cast', Page, 0);
if LineNr > -1 then
begin
FullValue := '';
Line := Page.GetString(LineNr);
repeat
BeginPos := Pos('<td valign="top">', Line);
if BeginPos > 0 then
begin
Delete(Line, 1, BeginPos);
Line := copy(Line, 25, Length(Line));
BeginPos := pos('">', Line) + 2;
EndPos := pos('</a>', Line);
if EndPos = 0 then
EndPos := Pos('</td>', Line);
Value := copy(Line, BeginPos, EndPos - BeginPos);
if (Value <> '(more)') and (Value <> '') then
begin
BeginPos := pos('.... </td><td valign="top">', Line);
if BeginPos > 0 then
begin
EndPos := pos('</td></tr>', Line);
BeginPos := BeginPos + 27;
Value2 := copy(Line, BeginPos, EndPos - BeginPos);
if Value2 <> '' then
begin
Value := Value + ' (as ' + Value2 + ')';
end;
end;
if FullValue <> '' then
FullValue := FullValue + ', ';
FullValue := FullValue + Value;
end;
EndPos := Pos('</td></tr>', Line);
Delete(Line, 1, EndPos);
end else
begin
Line := '';
end;
until Line = '';
HTMLDecode(FullValue);
SetField(fieldActors, FullValue);
end;
//Country
LineNr := FindLine('Country:', Page, 0);
if LineNr > -1 then
begin
Line := Page.GetString(LineNr + 1);
BeginPos := pos('/">', Line) + 3;
EndPos := pos('</a>', Line);
Value := copy(Line, BeginPos, EndPos - BeginPos);
HTMLDecode(Value);
SetField(fieldCountry, Value);
end;
//Category
LineNr := FindLine('Genre:', Page, 0);
if LineNr > -1 then
begin
Line := Page.GetString(LineNr + 1);
BeginPos := pos('/">', Line) + 3;
EndPos := pos('</a>', Line);
Value := copy(Line, BeginPos, EndPos - BeginPos);
HTMLDecode(Value);
SetField(fieldCategory, Value);
end;
//Description
LineNr := FindLine('Plot Summary:', Page, 0);
if LineNr < 1 then
LineNr := FindLine('Plot Outline:', Page, 0);
if LineNr > -1 then
begin
Line := Page.GetString(LineNr);
BeginPos := pos('</b>', Line) + 5;
EndPos := pos('<a href', Line);
if EndPos < 1 then
begin
Line := Line + Page.GetString(LineNr+1);
EndPos := pos('<br><br>', Line);
if EndPos < 1 then
EndPos := Length(Line);
end;
Value := copy(Line, BeginPos, EndPos - BeginPos);
HTMLDecode(Value);
case DescrImport of
0:
begin
PickListClear;
PickListAdd(Value);
GetDescriptions(GetField(fieldURL) + 'plotsummary');
if PickListExec('Select a description for "' + MovieName + '"', Value) then
SetField(fieldDescription, Value);
end;
1:
SetField(fieldDescription, Value);
2:
SetField(fieldDescription, GetDescriptions(MovieURL + 'plotsummary'));
end;
end;
// Comments
LineNr := FindLine('<b>Summary:</b>', Page, 0);
if LineNr > -1 then
begin
Value := '';
repeat
LineNr := LineNr + 1;
Line := Page.GetString(LineNr);
EndPos := Pos('</blockquote>', Line);
if EndPos = 0 then
EndPos := Length(Line)
else
EndPos := EndPos - 1;
Value := Value + Copy(Line, 1, EndPos) + ' ';
until Pos('</blockquote>', Line) > 0;
HTMLDecode(Value);
Value := StringReplace(Value, '<br>', #13#10);
Value := StringReplace(Value, #13#10+' ', #13#10);
SetField(fieldComments, Value);
end;
// Length
LineNr := FindLine('Runtime:', Page, 0);
if LineNr > -1 then
begin
Line := Page.GetString(LineNr + 1);
EndPos := pos(' min', Line);
if EndPos = 0 then
EndPos := pos(' /', Line);
if EndPos = 0 then
EndPos := Length(Line);
if Pos(':', Line) < EndPos then
BeginPos := Pos(':', Line) + 1
else
BeginPos := 1;
Value := copy(Line, BeginPos, EndPos - BeginPos);
SetField(fieldLength, Value);
end;
// Language
LineNr := FindLine('Language:', Page, 0);
if LineNr > -1 then
begin
Line := Page.GetString(LineNr + 1);
BeginPos := pos('/">', Line) + 3;
EndPos := pos('</a>', Line);
if EndPos = 0 then
EndPos := Length(Line);
Value := copy(Line, BeginPos, EndPos - BeginPos);
SetField(fieldLanguages, Value);
end;
DisplayResults;
end;
function GetDescriptions(Address: string): string;
var
Line, Value: string;
LineNr: Integer;
BeginPos, EndPos,Longest: Integer;
Page: TStringList;
begin
Result := '';
Longest := 0;
Page := TStringList.Create;
Page.Text := GetPage(Address);
LineNr := FindLine('<p class="plotpar">', Page, 0);
while LineNr > -1 do
begin
Value := '';
repeat
Line := Page.GetString(LineNr);
BeginPos := pos('"plotpar">', Line);
if BeginPos > 0 then
BeginPos := BeginPos + 10
else
BeginPos := 1;
EndPos := pos('</p>', Line);
if EndPos < 1 then
EndPos := Length(Line) + 1;
if Value <> '' then
Value := Value + ' ';
Value := Value + copy(Line, BeginPos, EndPos - BeginPos);
LineNr := LineNr + 1;
until (pos('</p>', Line) > 0) or (LineNr = Page.Count);
HTMLDecode(Value);
PickListAdd(Value);
if Length(Value) > Longest then
begin
Result := Value;
Longest := Length(Value);
end;
LineNr := FindLine('<p class="plotpar">', Page, LineNr);
end;
Page.Free;
end;
procedure AddMoviesTitles(ResultsPage: TStringList);
var
Page: string;
MovieTitle, MovieAddress: string;
begin
Page := ResultsPage.Text;
while Pos('<a href="/title/tt', Page) > 0 do
begin
CutBefore(Page, '<ol><li><a href="/title/');
MovieAddress := 'http://imdb.com' + GetStringFromHTML(Page, '<li><a href="', '"', '?fr=');
MovieTitle := GetStringFromHTML(Page, 'fm=1">', '">', '</li>');
CutAfter(Page, '</li>');
PickTreeAdd(MovieTitle, MovieAddress);
end;
end;
begin
if CheckVersion(3,4,0) then
begin
MovieName := GetField(fieldOriginalTitle);
if MovieName = '' then
MovieName := GetField(fieldTranslatedTitle);
if Input('IMDb Import', 'Enter the title of the movie:', MovieName) then
begin
AnalyzePage('http://imdb.com/find?more=tt;q='+UrlEncode(MovieName));
end;
end
else
ShowMessage('This script requires a newer version of Ant Movie Catalog (at least the version 3.4.0)');
end.
Last edited by KaraGarga on 2004-12-22 23:50:09, edited 1 time in total.
Just for information:
I've added these procedures:
completely changed:
and small changes:
I've added these procedures:
Code: Select all
procedure CutAfter(var Str: string; Pattern: string);
begin
Str := Copy(str, Pos(Pattern, Str) + Length(Pattern), Length(Str));
end;
procedure CutBefore(var Str: string; Pattern: string);
begin
Str := Copy(Str, Pos(Pattern, Str), Length(Str));
end;
// Extracts single movie detail (like director, genre) from page
function GetStringFromHTML(Page, StartTag, CutTag, EndTag: string): string;
begin
Result := '';
// recognition tag - if present, extract detail from page, otherwise assume detail is not present
if Pos(StartTag, Page) > 0 then begin
CutBefore(Page, StartTag);
// optional cut tag helps finding right string in html page
if Length(CutTag) > 0 then
CutAfter(Page, CutTag);
// movie detail copied with html tags up to end string
Result := Copy(Page, 0, Pos(EndTag, Page) - 1);
// remove html tags and decode html string
HTMLRemoveTags(Result);
HTMLDecode(Result);
// ShowMessage('DEBUG: GetStringFromHTML - StartTag "'+StartTag+'", CutTag "'+CutTag+'", EndTag "'+EndTag+'", Result "'+Result+'" ___ '+Page);
end;
end;
Code: Select all
procedure AddMoviesTitles(ResultsPage: TStringList);
var
Page: string;
MovieTitle, MovieAddress: string;
begin
Page := ResultsPage.Text;
while Pos('<a href="/title/tt', Page) > 0 do
begin
CutBefore(Page, '<ol><li><a href="/title/');
MovieAddress := 'http://imdb.com' + GetStringFromHTML(Page, '<li><a href="', '"', '?fr=');
MovieTitle := GetStringFromHTML(Page, 'fm=1">', '">', '</li>');
CutAfter(Page, '</li>');
PickTreeAdd(MovieTitle, MovieAddress);
end;
end;
Code: Select all
AnalyzePage('http://imdb.com/find?more=tt;q='+UrlEncode(MovieName));
Code: Select all
PickTreeClear;
PickTreeAdd('Search results', '');
AddMoviesTitles(Page);
With your script, I updated the other IMDB versions and uploaded all of them:
http://antp.be/temp/scripts/IMDB%20(batch).ifs
http://antp.be/temp/scripts/IMDB%20(large%20pic).ifs
http://antp.be/temp/scripts/IMDB%20(pic).ifs
http://antp.be/temp/scripts/IMDB.ifs
http://antp.be/temp/scripts/IMDB%20(batch).ifs
http://antp.be/temp/scripts/IMDB%20(large%20pic).ifs
http://antp.be/temp/scripts/IMDB%20(pic).ifs
http://antp.be/temp/scripts/IMDB.ifs
When i fixed it yesterday, there were no problem with comments. Today they changed something and make new addition on "Main Details" page.
I think i fixed. This one seems to work well Just change above script old "Comments" part with this one...
Ant, you're real programmer (not like me ) So there would be mistake in my corrections. Please free to change any bugs or mis-coded part, my purpose is just to offer solutions. Maybe there would be better solutions that i don't know
Thanks for this scripting utility by the way. It makes developing and correction scripts easily (even by me )
I think i fixed. This one seems to work well Just change above script old "Comments" part with this one...
Code: Select all
// Comments
LineNr := FindLine('/comments">', Page, 0);
if LineNr > -1 then
begin
Value := '';
repeat
LineNr := LineNr + 1;
Line := Page.GetString(LineNr);
EndPos := Pos('"', Line);
if EndPos = 0 then
EndPos := Length(Line)
else
EndPos := EndPos - 1;
Value := Value + Copy(Line, 1, EndPos) + ' ';
until Pos('"hidden"', Line) > 0;
HTMLDecode(Value);
Value := StringReplace(Value, '"', '"');
Value := StringReplace(Value, '&', '&');
Value := StringReplace(Value, '<br>', #13#10);
Value := StringReplace(Value, #13#10+' ', #13#10);
HTMLRemoveTags (Value);
Value := StringReplace(Value, ' ', '');
SetField(fieldComments, Value);
end;
Thanks for this scripting utility by the way. It makes developing and correction scripts easily (even by me )