Page 1 of 1

How to get only the first description?

Posted: 2003-02-26 00:15:45
by Mguel
Hi, I've been trying to modify the imdb to make it get automatically the first description for the movie instead of giving the option to choose since I always pick that one.

I saw a script by joanzito in which he make it to select the last one by adding one line (PickListClear) on the procedure GetDescriptions:

Code: Select all

procedure GetDescriptions(Address: string);
var
 Line, Value: string;
 LineNr: Integer;
 BeginPos, EndPos: Integer;
 Page: TStringList;
begin
 Page := TStringList.Create;
 Page.Text := GetPage('http://us.imdb.com' + 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);
  PickListClear; //(joazito) I'm only interested in 1 description... this will clear all but the last
  PickListAdd(Value);
  LineNr := FindLine('<p class="plotpar">', Page, LineNr);
 end;
 Page.Free;
end;
Is there a way to do it the other way round? picking the first description instead?

Thanks in advance,
Mguel

Posted: 2003-02-26 08:27:33
by antp
Just remove the "while LineNr > -1 do begin " and the matching "end", and it will only take the first description instead of searching for all of them.
If you want you can also in addition of this modification remove the picklist stuff and directly use SetField(fieldComment, Value), so you are sure that it won't display the picklist (here it will maybe display it if there is the short description + long description)

Posted: 2003-02-26 10:56:02
by Mguel
Thanks a lot!

Sorry for my null knowledge on scripting/programming, I'm looking forward to lear some pascal/delphi... ;)

Mguel