BETA FIX - Imdb Large Pics

If you made a script you can offer it to the others here, or ask help to improve it. You can also report here bugs & problems with existing scripts.
Post Reply
lboregard

BETA FIX - Imdb Large Pics

Post by lboregard »

antp

the solution below has worked with all of the movies i've tried. i hope you could test it, to have it "certified" :)

// Picture
LineNr := FindLine('title="DVD available at Amazon.com"', Page, 0);
if LineNr > -1 then
begin
Line := Page.GetString(LineNr);
BeginPos := Pos('href="', Line) + 5;
Delete(Line, 1, BeginPos);
EndPos := Pos('"', Line);
Value := Copy(Line, 1, EndPos - 1);

AmazonPage := TStringList.Create;
AmazonPage.Text := GetPage('http://us.imdb.com' + Value);

LineNr := FindLine('<title>Amazon.com: DVD Search', AmazonPage, 0);
if LineNr < 1 then
begin
LineNr := FindLine('img src="http://images.amazon.com/images/P/', AmazonPage, 0);
if LineNr > -1 then
begin
Line := AmazonPage.GetString(LineNr);
BeginPos := Pos('img src="http://images.amazon.com/images/P/', Line) + 8;
Delete(Line, 1, BeginPos);
EndPos := Pos('"', Line);
Value := Copy(Line, 1, EndPos - 1);
Value := StringReplace(Value, 'TZZZZZZZ', 'LZZZZZZZ');
GetPicture(Value, False); // False = do not store picture externally ; store it in the catalog file
end
end else
begin
Line := AmazonPage.GetString(LineNr);
BeginPos := Pos('<title>Amazon.com: DVD Search Results: ', Line) + 38;
Delete(Line, 1, BeginPos);
EndPos := Pos('|', Line);
Value2 := Copy(Line, 1, EndPos - 1);
Value := 'http://images.amazon.com/images/P/' + Value2 + '.01.LZZZZZZZ.jpg';
GetPicture(Value, False);
end;

AmazonPage.Free;
end else
begin
LineNr := FindLine('<img alt="cover" align="left" src="http://ia.imdb.com/media/imdb/', Page, 0);
if LineNr < 0 then
LineNr := FindLine('<img alt="cover" align="left" src="http://posters.imdb.com/', Page, 0);
if LineNr < 0 then
LineNr := FindLine('<img alt="cover" align="left" src="http://images.amazon.com/', 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);
Value := StringReplace(Value, 'MZZZZZZZ', 'LZZZZZZZ'); // change URL to get the Large instead of Small image
GetPicture(Value, False); // False = do not store picture externally ; store it in the catalog file
end;
end;
antp
Site Admin
Posts: 9630
Joined: 2002-05-30 10:13:07
Location: Brussels
Contact:

Post by antp »

Thanks, I will try that ;)
Dr Greenthumb
Posts: 2
Joined: 2002-12-18 12:25:26
Location: Darkest Africa

Post by Dr Greenthumb »

Thx for the code but I can't seem to get it working.
I get the following error message:

Script error : IMDB at postion 4298 (unknown identifier : AMAZONPAGE)

:cry:
lboregard

BETA FIX - Imdb Large Pics

Post by lboregard »

sorry ... u need to declare the variable at the top of the script :

before

procedure AnalyzeMoviePage(Page: TStringList);
var
Line, Value, Value2, FullValue: string;
LineNr: Integer;
BeginPos, EndPos: Integer;

after

procedure AnalyzeMoviePage(Page: TStringList);
var
Line, Value, Value2, FullValue: string;
LineNr: Integer;
BeginPos, EndPos: Integer;
AmazonPage: TStringList;
Dr Greenthumb
Posts: 2
Joined: 2002-12-18 12:25:26
Location: Darkest Africa

Post by Dr Greenthumb »

Excellent, its works like a dream now. Thx a million Dude!!!!!!!

:grinking: :grinking: :grinking:
Flash

Post by Flash »

good work !
but in "harry potter 2 and the chamber of secrets" i 'only' get a small picture ... dont know if that's a bug or if there just isnt any bigger pic available

but anyway, thanks for coding :D
antp
Site Admin
Posts: 9630
Joined: 2002-05-30 10:13:07
Location: Brussels
Contact:

Post by antp »

Since the DVD is not available yet I guess that Amazon.com does not have it yet on its site, and so it is not possible to get the large image from Amazon :D
lboregard

BETA FIX UPDATE - Imdb Large Pics

Post by lboregard »

i changed the parsing of the amazon page, to make the script more accurate ....

// Picture
LineNr := FindLine('title="DVD available at Amazon.com"', Page, 0);
if LineNr > -1 then
begin
Line := Page.GetString(LineNr);
BeginPos := Pos('href="', Line) + 5;
Delete(Line, 1, BeginPos);
EndPos := Pos('"', Line);
Value := Copy(Line, 1, EndPos - 1);

AmazonPage := TStringList.Create;
AmazonPage.Text := GetPage('http://us.imdb.com' + Value);

// if Pos('<TITLE>Amazon.com: DVD Search', AmazonPage.Text) = 0 then
LineNr := FindLine('<b>1.', AmazonPage, 0);
if LineNr < 1 then
begin
LineNr := FindLine('img src="http://images.amazon.com/images/P/', AmazonPage, 0);
if LineNr > -1 then
begin
Line := AmazonPage.GetString(LineNr);
BeginPos := Pos('img src="http://images.amazon.com/images/P/', Line) + 8;
Delete(Line, 1, BeginPos);
EndPos := Pos('"', Line);
Value := Copy(Line, 1, EndPos - 1);
Value := StringReplace(Value, 'TZZZZZZZ', 'LZZZZZZZ');
GetPicture(Value, False); // False = do not store picture externally ; store it in the catalog file
end
end else
begin
LineNr := FindLine('http://images.amazon.com/images/P/', AmazonPage, LineNr);
Line := AmazonPage.GetString(LineNr);
BeginPos := Pos('src="', Line) + 4;
Delete(Line, 1, BeginPos);
EndPos := Pos('"', Line);
Value := Copy(Line, 1, EndPos - 1);
Value := StringReplace(Value, 'THUMBZZZ', 'LZZZZZZZ');
GetPicture(Value, False);
end;

AmazonPage.Free;
end else
begin
LineNr := FindLine('<img alt="cover" align="left" src="http://ia.imdb.com/media/imdb/', Page, 0);
if LineNr < 0 then
LineNr := FindLine('<img alt="cover" align="left" src="http://posters.imdb.com/', Page, 0);
if LineNr < 0 then
LineNr := FindLine('<img alt="cover" align="left" src="http://images.amazon.com/', 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);
Value := StringReplace(Value, 'MZZZZZZZ', 'LZZZZZZZ'); // change URL to get the Large instead of Small image
GetPicture(Value, False); // False = do not store picture externally ; store it in the catalog file
end;
end;
antp
Site Admin
Posts: 9630
Joined: 2002-05-30 10:13:07
Location: Brussels
Contact:

Post by antp »

You should use [code] tags to get a better formatting of your code :
[code]
place here the code
[/code]
lboregard

BETA FIX UPDATE - Imdb Large Pics

Post by lboregard »

ok .. here it goes :)

Code: Select all

  // Picture
  LineNr := FindLine('title="DVD available at Amazon.com"', Page, 0);
  if LineNr > -1 then
  begin
    Line := Page.GetString(LineNr);
    BeginPos := Pos('href="', Line) + 5;
    Delete(Line, 1, BeginPos);
    EndPos := Pos('"', Line);
    Value := Copy(Line, 1, EndPos - 1);

    AmazonPage := TStringList.Create;
    AmazonPage.Text := GetPage('http://us.imdb.com' + Value);

//    if Pos('<TITLE>Amazon.com: DVD Search', AmazonPage.Text) = 0 then
    LineNr := FindLine('<b>1.', AmazonPage, 0);
    if LineNr < 1 then
    begin
      LineNr := FindLine('img src="http://images.amazon.com/images/P/', AmazonPage, 0);
      if LineNr > -1 then
      begin
        Line := AmazonPage.GetString(LineNr);
        BeginPos := Pos('img src="http://images.amazon.com/images/P/', Line) + 8;
        Delete(Line, 1, BeginPos);
        EndPos := Pos('"', Line);
        Value := Copy(Line, 1, EndPos - 1);
        Value := StringReplace(Value, 'TZZZZZZZ', 'LZZZZZZZ');
        GetPicture(Value, False); // False = do not store picture externally ; store it in the catalog file
      end
    end else
    begin
      LineNr := FindLine('http://images.amazon.com/images/P/', AmazonPage, LineNr);
      Line := AmazonPage.GetString(LineNr);
      BeginPos := Pos('src="', Line) + 4;
      Delete(Line, 1, BeginPos);
      EndPos := Pos('"', Line);
      Value := Copy(Line, 1, EndPos - 1);
      Value := StringReplace(Value, 'THUMBZZZ', 'LZZZZZZZ');
      GetPicture(Value, False);
    end;
    
    AmazonPage.Free;
  end else
  begin
    LineNr := FindLine('<img alt="cover" align="left" src="http://ia.imdb.com/media/imdb/', Page, 0);
    if LineNr < 0 then
      LineNr := FindLine('<img alt="cover" align="left" src="http://posters.imdb.com/', Page, 0);
    if LineNr < 0 then
      LineNr := FindLine('<img alt="cover" align="left" src="http://images.amazon.com/', 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);
      Value := StringReplace(Value, 'MZZZZZZZ', 'LZZZZZZZ'); // change URL to get the Large instead of Small image
      GetPicture(Value, False); // False = do not store picture externally ; store it in the catalog file
    end;
  end;
Guest

Post by Guest »

The Nutty Professor 1963 comes out as a blank white picture with this code..
Guest

Post by Guest »

Man Who Knew Too Much, The (1956) brings the wrong photo from amazon.com, the set dvd, instead of the actual movie...
Guest

Post by Guest »

same problem with "Stalag 17" brings collection, instead of actual film..
antp
Site Admin
Posts: 9630
Joined: 2002-05-30 10:13:07
Location: Brussels
Contact:

Post by antp »

I'll check that
luckybigpack
Posts: 10
Joined: 2002-12-20 22:47:05

Post by luckybigpack »

Same thing for several other movies like Aliens 1-4 or MiB1+2 and so on...but I tried it with my whole Database (500 Movies) and maybe 20 got a wrong picture. The right movie but the collections pictures.
antp
Site Admin
Posts: 9630
Joined: 2002-05-30 10:13:07
Location: Brussels
Contact:

Post by antp »

For this collection problem I am not sure that it is possible to do better, it is probably because the first item on amazon is a collection thing.
Well I will see that later, within few days I think ;)
Post Reply