Script for -- Movie Poster Awards (http://www.impawards)

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
bro

Script for -- Movie Poster Awards (http://www.impawards)

Post by bro »

http://www.impawards.com/

This is a great site for movie posters... It would be great if someone made a script for AMC... Can't do it myself though...

anyone?
micmic

Post by micmic »

I hope it works for you (spanish messages sorry)

Code: Select all

// GETINFO SCRIPTING
// IMP Awards v1.0 by micmic.ifs

program micmic;
var
  MovieName: string;
const
  BaseURL = 'http://www.impawards.com/cgi-bin/htsearch?method=or&words=';

function FindLine(Pattern: string; List: TStringList; StartAt: Integer): Integer;
var
  i: Integer;
begin
  result := -1;
  if StartAt < 0 then
    StartAt := 0;
  for i := StartAt to List.Count-1 do
    if Pos(Pattern, List.GetString(i)) <> 0 then
    begin
      result := i;
      Break;
    end;
end;

procedure AnalyzePage(Address: string);
var
  Page: TStringList;
  LineNr: Integer;
  PosIni, PosFin: Integer;
  Line, SubLine: string;
  Title, DirURL: string;
  txtTemp: string;
begin
  Page := TStringList.Create;
  Page.Text := GetPage(Address);
  if Pos('IMP could not find any matches for', Page.Text) > 0 then
  begin
    ShowMessage('No se ha encontrado ningún artículo por título.');
  end else
  begin
    PickTreeClear;
    PickTreeAdd('Resultados de la búsqueda para "' + MovieName + '":', '');
    
    // buscamos los resultados
    LineNr := 0;

    while LineNr < Page.Count do
    begin
      SubLine := Page.GetString(LineNr);
      txtTemp := '<dl><dt><strong><a href="';
      PosIni := pos(txtTemp, SubLine);
      if PosIni > 0 then
      begin
        //ShowMessage(IntToStr(PosIni));
        SubLine := Copy(SubLine, PosIni + Length(txtTemp), Length(SubLine));
        
        txtTemp := '">';
        PosFin := pos(txtTemp, SubLine);
        DirURL := Copy(SubLine, 1, PosFin - 1);
        
        SubLine := Copy(SubLine, PosFin + Length(txtTemp), Length(SubLine));
        txtTemp := '</a>';
        PosFin := pos(txtTemp, SubLine);
        Title := Copy(SubLine, 1, PosFin - 1);

        //ShowMessage(Title + '-->' + DirURL);
        PickTreeAdd(Title, DirURL);
      end;
      LineNr := LineNr + 1;
    end;

    Page.Free;
    if PickTreeExec(Address) then
      AnalyzeMoviePage(Address);
  end;
end;


procedure AnalyzeMoviePage(Address: string);
var
  Page: TStringList;
  PosIni, PosFin: Integer;
  dirBase: string;
  txtTemp: string;
  ImgTMP: string;
begin
  Page := TStringList.Create;
  Page.Text := StringReplace(GetPage(Address), '<br>', #13#10);
  
  //obtenemos directorio base
  PosFin := 0;
  dirBase := Address;
  PosIni := pos('/', dirBase);
  while PosIni > 0 do
  begin
    PosFin := PosFin + PosIni;
    dirBase := Copy(dirBase, PosIni + 1, Length(DirBase));
    PosIni := pos('/', dirBase);
  end;
  dirBase := Copy(Address, 1, PosFin);

  //buscamos la imagen
  txtTemp := '<img SRC="posters/';
  PosIni := pos(txtTemp, Page.Text);
  if PosIni > 0 then
  begin
    txtTemp := Copy(Page.Text, PosIni + Length(txtTemp), Length(txtTemp));
    PosFin := pos('"', txtTemp);
    ImgTMP := Copy(txtTemp, 1, PosFin - 1);

    GetPicture(dirBase + 'posters/' + ImgTMP, False);
  end;

  Page.Free;
  DisplayResults;
end;

// bmicmic: Bucle Principal
begin
  if CheckVersion(3,4,0) then
  begin
    MovieName := GetField(fieldOriginalTitle);
    if MovieName = '' then
      MovieName := GetField(fieldTranslatedTitle);
    Input('Importar de IMP Awards', 'Introduce el Titulo de la Pelicula:', MovieName);
    AnalyzePage(BaseURL + UrlEncode(MovieName));
   
  end else
       ShowMessage('Este script necesita una versión superior de Ant Movie Catalog (al menos la version 3.4.0)');
end.
antp
Site Admin
Posts: 9639
Joined: 2002-05-30 10:13:07
Location: Brussels
Contact:

Post by antp »

I will include an "englishized" version of your script in AMC ;)
micmic

Post by micmic »

ups... thanks... it's a pleasure ;)

I try an english version with the next one :grinking:
HoeroArg

403 Forbiden

Post by HoeroArg »

I get a 403 Forbiden error every time i try to get a poster from this site. :cry:
It worked once, the first time i used it and never worked again. Any ideas ?!?
This site is the BEST !!! :grinking:
kolia
Posts: 56
Joined: 2003-02-19 16:02:46

Post by kolia »

It does produce 403 errors with some titles (e.g. The Singing Detective) but it does work again...

probably some script error...
Guest

Post by Guest »

replace

Code: Select all

txtTemp := Copy(Page.Text, PosIni + Length(txtTemp), Length(txtTemp));
with

Code: Select all

txtTemp := Copy(Page.Text, PosIni + Length(txtTemp), 100);
with only 18 characters, the text wasn't enough to cover movies longer than 13 characters... now it should be O.K. ;)
kolia
Posts: 56
Joined: 2003-02-19 16:02:46

Post by kolia »

that was me up there... I guess it took me long enough to figure this out for the system to log me out :lol:
Post Reply