[REQ] Imdb script Awards info - accented chars

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
sirgentx
Posts: 4
Joined: 2014-01-29 18:01:53

[REQ] Imdb script Awards info - accented chars

Post by sirgentx »

I was making some modifications to the Imdb script to add award filters (importing only major awards) and to reincorporate the indentations of Imdb script 3.79 in awards info. I came to notice that the accented characters are not being correctly imported for Awards. For example, Y Tu Mamá También (2001) (http://www.imdb.com/title/tt0245574) - the director's field correctly imports 'Alfonso Cuarón' but Awards info shows 'Alfonso Cuarón'.
In debugging, I saw that --
For Director - TextBetween returns 'Alfonso Cuarón' which becomes 'Alfonso Cuarón' after using HTMLDecode.
For Awards - TextBetween returns 'Alfonso Cuarón' and it stays that way.
Any ideas why this is happening?
Raoul_Volfoni
Posts: 863
Joined: 2006-08-31 23:58:18

Post by Raoul_Volfoni »

Hi,

The charset of the awards page must be in UTF8.
So, you have to UTF8Decode all the values from this page.

Code: Select all

program NewScript;
Var
Value :String;
begin
Value := 'Alfonso Cuarón';
Value := UTF8Decode(Value);
ShowMessage(Value);
end.
sirgentx
Posts: 4
Joined: 2014-01-29 18:01:53

Post by sirgentx »

Works perfectly now. Thanks Raoul!
lsstan
Posts: 10
Joined: 2009-03-23 09:36:55

IMDB Awards indentations

Post by lsstan »

Hi sirgentx,
Were you able create a version of the IMDB script to "reincorporate the indentations of Imdb script 3.79 in awards info"?

I'd like to do the same. I tried just copying the 3.79 ImportAwards, and replacing the ImportAwards section in the 3.86 script.

I didn't get any errors, but no awards were imported. I do have Script Options, Awards = 2 (Import awards to Comments field, after comments)

Thanks for any help.
sirgentx
Posts: 4
Joined: 2014-01-29 18:01:53

IMDB Awards indentations

Post by sirgentx »

Hi Isstan,
Sorry for the delayed response.
I did manage to incorporate the indentations in the latter imdb scripts. However I haven't tested it yet with 3.86 version. I was using 3.85 till now. I will get back to you once I make the same changes with 3.86.
sirgentx
Posts: 4
Joined: 2014-01-29 18:01:53

Post by sirgentx »

I use the following code in the Import Awards section. It worked for 3.86 as well. If you don't want to pick only Selected awards as per the code, delete the If clause after " // Only Pick Selected Awards".

Code: Select all

// Import awards
procedure ImportAwards;
var
  IndexPage: TStringList;
  PageText, FullValue, Block, Value, Row, Outcome, Details, AwardShow, PageText1: string;
  Year, Result, Award, Category: string;
begin
  sleep(50);
  Value := MovieUrl;
  PageText := ConvertToASCII(GetPage(Value+'/awards'));
 
  repeat

    AwardShow := TextBetween(PageText, '<h3>', '</h3>');

    if Pos('User Lists', AwardShow) > 0 then             
      break;
      HTMLRemoveTags(AwardShow);
 //     HTMLDecode(AwardShow);
      AwardShow := UTF8Decode(AwardShow);
      AwardShow := FullTrim(AwardShow);
      AwardShow := StringReplace(AwardShow, #13, '');
      AwardShow := StringReplace(AwardShow, #10, '');

      PageText1 := TextBetween(PageText, '<table class="awards"', '</table>');
      PageText := RemainingText;
      Block := PageText1;
 // Begin of Mod Oscar+
 // Only Pick Selected Awards
    if (AnsiPosEx('Academy Awards, USA', AwardShow, true, true) > 0) or
      (AnsiPosEx('BAFTA Awards', AwardShow, true, true) > 0) or
      (AnsiPosEx('Cannes Film Festival', AwardShow, true, true) > 0) or
      (AnsiPosEx('César Awards, France', AwardShow, true, true) > 0) or
      (AnsiPosEx('Golden Globes, USA', AwardShow, true, true) > 0) or
      (AnsiPosEx('Razzie Awards', AwardShow, true, true) > 0) then
     begin
 // End of Mod Oscar+
 // Begin of Mod Oscar+++
  //    FullValue := FullValue + #32 + AwardShow + #13#10;
      FullValue := FullValue + #13#10 + '- ' + AwardShow;
 // End of Mod Oscar+++
 
      repeat
         
        Row := TextBetween(Block, '<tr>', '</tr>');
        Block := RemainingText;
        Row := UTF8Decode(Row);
        
        Outcome := TextBetween(Row, '<b>', '</b>');
        Category := TextBetween(Row, '<span class="award_category">', '</span>');
        Award := TextBetween(Row, '<td class="award_description">', '</td>');
        Details := TextBetween(Row, '<div class="award_detail_notes">', '</div>');
           
        If Outcome <> '' then
 // Begin of Mod Oscar+++
 //          FullValue := FullValue + #32 + Outcome + #13#10;
 // End of Mod Oscar+++
        If Category <> '' then
 // Begin of Mod Oscar+++
    //      FullValue := FullValue + #32 + Category;
          FullValue := FullValue + #13#10 + '   ' + Year + '' + Outcome + ' "' + Category + '"';
 // End of Mod Oscar+++
           
        If Award <> '' then
         begin
 // Begin of Mod Oscar++++
    //      Award := StringReplace(Award, '<br />', #32);
          Award := StringReplace2(Award, '<br />', ': ', true, false);
          Award := StringReplace(Award, '</a>', '</a>, ');
 // End of Mod Oscar++++
          HTMLRemoveTags(Award);
          HTMLDecode(Award);
          Award := StringReplace(Award, #13, '');
          Award := StringReplace(Award, #10, '');                         
          Award := FullTrim(Award);       
          Award := StringReplace(Award, '  ', '');
  // Begin of Mod Oscar+++
     //     FullValue := FullValue + #32 + Award;
          if Award <> '' then
           begin
            if StrGet(Award, Length(Award)) = ':' then
            begin
              Delete(Award, Length(Award), 1);
              Award := FullTrim(Award);
            end;
           end;
          if Award <> '' then
           begin
            if StrGet(Award, Length(Award)) = ',' then
            begin
              Delete(Award, Length(Award), 1);
              Award := FullTrim(Award);
            end;
           end;
          FullValue := FullValue + #13#10 + '      ' + Award;
          FullValue := StringReplace(FullValue, ', :', ':');
          FullValue := StringReplace(FullValue, ', (', ' (');
          FullValue := StringReplace(FullValue, ',(', '(');
  // End of Mod Oscar+++
         end;
         
  //      If Details <> '' then
  //       begin
  //        HTMLRemoveTags(Details);
  //        HTMLDecode(Details);
  //        Award := StringReplace(Details, #13, '');
  //        Award := StringReplace(Details, #10, '');
  //        Award := FullTrim(Details);
  //        FullValue := FullValue + #32 + Details + #13#10;
  //       end;
     until (Row = ''); 
    end;
  until (PageText1 = '');

 // ShowInformation(FullValue);
  
  if FullValue <> '' then
    case GetOption('Awards') of
      1:
        begin
          if GetField(fieldDescription) <> '' then
            Value := GetField(fieldDescription) + #13#10 + #13#10 + 'AWARDS: ' + #13#10 + FullValue
          else
            Value := 'AWARDS: ' + FullValue;
          SetField(fieldDescription, Value);
        end;
      2:
        begin
          if GetField(fieldComments) <> '' then
            Value := GetField(fieldComments) + #13#10 + #13#10 + 'AWARDS: ' + #13#10 + FullValue
          else
            Value := 'AWARDS: ' + FullValue;
          SetField(fieldComments, Value);
        end;
    end;
end;
lsstan
Posts: 10
Joined: 2009-03-23 09:36:55

Post by lsstan »

Hi sirgentx,
Thanks so much. I just tried it and it's working great.
I appreciate your work on this. And thank you for the instructions for "Only Selected".
Post Reply