antp wrote:Check the line that contains "if CanSetPicture then"
Depending on the "ImageKind" option, it calls different function.
These functions call "GetPicture".
One of the way to do what you want may be to add an extra boolean parameter to all these functions to specify if they should do a GetPicture or a SetField, and then call them in "if CanSetField(fieldMedia)" with that parameter.
OK, I made great progress (works for most popular movies... I believe those with amazon big pic).
As I don't know how to add the extra boolean parameter you mention, I simply changed the GetPicture with SetField on the functions for big pics (as I have always imported the small pic since I started using AMC).
Then I used the following to call (I believe) the functions:
Code: Select all
// URL of big picture
if CanSetField(fieldMedia) then
begin
ImportLargePicture('http://us.imdb.com/gallery/ss/' + MovieNumber);
if not ImportMerchandisingPicture(PageText) then
if not ImportDvdDetailsPicture(PageText) then
ImportSmallPictureURL(PageText) then
SetField(fieldMedia,PageText);
end;
As ideally if no big pic url is fetched the small pic url would do fine, I used the "ImportSmallPicture", but as I use that by default (import small pic), I created a new function "ImportSmallPictureURL, using the same code for the normal one but replacing the GetPicture with SetField
Code: Select all
function ImportSmallPictureURL(PageText: string): Boolean;
var
Value: string;
begin
Result := False;
Value := TextBetween(PageText, '<img border="0" alt="cover" src="', '"');
if Value <> '' then
begin
SetField(Value);
Result := True;
end;
end;
It worked for most popular/old movies, but for more "rare" movies, it game me errors (Script error in "IMDB": type mismatch at line 547 - that's the SetField of ImportSmallPictureURL function), and "Script error in "IMDB": error in statement at line 154 (ImportSmallPictureURL(PageText) then), so I simply deleted that line (after trying to fix it).
Now I stop receiving those error for the rare movies, but on the media label field it seems that I started having as a result a hole imdb webpage "<html> <head> <meta-http.... etc" what I haven't been able to fix neither.
At least it's working fine for most know movies (tried Matrix, Gladiator, LOR, Harry Potter and worked great... I get the <html> stuff for others like Oldboy, Four Brothers, etc)
I believe I'm making lot's of very basic mistakes in my programming technique, but as I told before I don't know programming so sorry if I produce nausea to someone
Cheers,
Mguel