Page 1 of 1

BETA FIX - Imdb Large Pics

Posted: 2002-12-17 23:37:45
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;

Posted: 2002-12-18 09:04:33
by antp
Thanks, I will try that ;)

Posted: 2002-12-18 12:27:25
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:

BETA FIX - Imdb Large Pics

Posted: 2002-12-18 12:55:38
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;

Posted: 2002-12-18 13:16:45
by Dr Greenthumb
Excellent, its works like a dream now. Thx a million Dude!!!!!!!

:grinking: :grinking: :grinking:

Posted: 2002-12-18 18:24:04
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

Posted: 2002-12-18 21:07:21
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

BETA FIX UPDATE - Imdb Large Pics

Posted: 2002-12-19 15:56:55
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;

Posted: 2002-12-19 16:35:25
by antp
You should use [code] tags to get a better formatting of your code :
[code]
place here the code
[/code]

BETA FIX UPDATE - Imdb Large Pics

Posted: 2002-12-19 16:38:07
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;

Posted: 2002-12-23 07:27:13
by Guest
The Nutty Professor 1963 comes out as a blank white picture with this code..

Posted: 2002-12-23 08:03:51
by Guest
Man Who Knew Too Much, The (1956) brings the wrong photo from amazon.com, the set dvd, instead of the actual movie...

Posted: 2002-12-23 08:07:36
by Guest
same problem with "Stalag 17" brings collection, instead of actual film..

Posted: 2002-12-23 09:47:15
by antp
I'll check that

Posted: 2002-12-23 16:41:37
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.

Posted: 2002-12-23 16:56:24
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 ;)