How to get only the first description?

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
Mguel
Posts: 39
Joined: 2003-01-28 10:48:14

How to get only the first description?

Post 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
antp
Site Admin
Posts: 9651
Joined: 2002-05-30 10:13:07
Location: Brussels
Contact:

Post 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)
Mguel
Posts: 39
Joined: 2003-01-28 10:48:14

Post by Mguel »

Thanks a lot!

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

Mguel
Post Reply