New Spanish Script for Yahoo!Cinema

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
folgui
Posts: 113
Joined: 2003-02-04 19:15:03
Location: Madrid, Spain

New Spanish Script for Yahoo!Cinema

Post by folgui »

Hi!

This is my first script, not full, but really worked on it :)

Originally script is from Andrea Cristaudo, and comes with AMC pack.

Spanish database pages are a bit different from italian one, so i need not only to change strings, also work on checks, ...

Sure, some bugs, but i tried it with several movies and no problems. If any, tell me. Also, optimizations i can do for it are welcome.

Sorry if my english isn't 100% ok ;)

Here's the script, i named file as: Yahoo Cinema (ES).ifs

Code: Select all

// GETINFO SCRIPTING
// Yahoo!Cinema (Spanish) v1.1

(**************************************************
* Movie importation script for:                   *
* Yahoo!Cinema (ES), http://es.movies.yahoo.com   *
*                                                 *
* (c) 2003 Andrea Cristaudo achris@tiscalinet.it  *
*                                                 *
* Updated for Spanish Database support and more   *
* info importing by folgui (folgui@bigfoot.com)   *
*                                                 *
* For use with Ant Movie Catalog 3.4.3            *
*  www.antp.be/software/moviecatalog              *
*                                                 *
*  This program is free software; you can         *
*  redistribute it and/or modify it under the     *
*  terms of the GNU General Public License as     *
*  published by the Free Software Foundation;     *
*  either version 2 of the License, or (at your   *
*  option) any later version.                     *
***************************************************)

program YahooCinema;
const
LargePic = True; // Import Large Picture
var
MovieName: string;
TheMovieAddress: string;

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;

function TextBetween(var S: string; StartTag: string; EndTag: string): string;
var
  InitialPos: Integer;
begin
  InitialPos := Pos(StartTag, S);
  Delete(S, 1, InitialPos + Length(StartTag) - 1);
  InitialPos := Pos(EndTag, S);
  result := copy(S, 1, InitialPos - 1);
  Delete(S, 1, InitialPos + 1);
end;

procedure AnalyseLargePicPage(Address: string);
var
Page: TStringList;
LineNr: integer;
Line: string;
ImageURL: string;
begin
Page := TStringList.Create;
Page.Text := GetPage(Address);
LineNr := FindLine('<img src="http://eur.news1.yimg.com/eur.yimg.com/', Page, 0);
If LineNr <> -1 then
 begin
  Line := Page.GetString(LineNr);
  ImageURL := TextBetween (Line, '<img src="', '"');
  GetPicture (ImageURL, False);
 end
Page.Free;
end;

procedure AnalyzePage(Address: string);
var
Page: TStringList;
LineNr: integer;
BeginPos: integer;
begin
Page := TStringList.Create;
Page.Text := GetPage(Address);
LineNr := FindLine('<font face=arial,helvetica size=+1><b>Resultados de búsqueda</b></font>', Page, 0);
if LineNr = -1 then
begin
  SetField(fieldURL, Address);
  AnalyzeMoviePage(Page);
end
else
begin
  PickTreeClear;
  AddMoviesTitles(Page);
  if TheMovieAddress='' then
  begin
   if PickTreeExec(Address) then
   begin
    SetField(fieldURL, Address);
    Page.Text := GetPage(Address);
    AnalyzeMoviePage(Page);
   end;
  end
  else
  begin
   SetField(fieldURL, TheMovieAddress);
   Page.Text := GetPage(TheMovieAddress);
   AnalyzeMoviePage(Page);
  end;
end;
Page.Free;
end;

procedure AnalyzeMoviePage(Page: TStringList);
var
 Fine: Integer;
 EndActors: Integer;
 EndProducers: Integer;
 EndMusics: Integer;
 EndDirectors: Integer;
 EndPhotographers: Integer;
 EndWriters: Integer;
 EndRating: Integer;
 strActors: string;
 strComments: string;
 strProducers: string;
 strMusics: string;
 strDirectors: string;
 strPhotographers: string;
 strWriters: string;
 strTemp: string;
 Line: string;
 ImageURL: string;
 LineNr: Integer;
 BeginPos, EndPos: Integer;
 Field: integer;
 irate: integer;
begin
Page.Text := StringReplace(Page.Text, ' ', '');
Fine := 0;
  LineNr := FindLine('<FONT color=white face="arial, helvetica"><b>', Page, 0);
if LineNr > -1 then
begin
  //Translated Title
  Line := Page.GetString(LineNr);
  HTMLRemoveTags(Line);
  Line := StringReplace(Line,'"','');
  SetField(fieldTranslatedTitle,Line);

  repeat
   LineNr := LineNr + 1;
   Line := Page.GetString(LineNr);
   //GetPicture of Movie
   if Not LargePic then
    // Import Small Picture
    begin
      if pos('html"><img src="http:', Line) <> 0 then
       begin
        Delete(Line, 1, pos('<img ', Line) + 9);
        Delete(Line, pos('" border=', Line), pos('</a>', Line) + 1);
        GetPicture(Line, False);
       end
    end
   // Import Large Picture
   else
    begin
      if pos('Agrandar la imagen</a>', Line) <> 0 then
       begin
        ImageURL := TextBetween(Line, '<a href="', '">Agrandar la imagen</a>');
        AnalyseLargePicPage('http://es.movies.yahoo.com' + ImageURL);
      end
    end
   //Original Title
   if pos('<b>Título original:</b>', Line) <> 0 then
    begin
     HTMLRemoveTags(Line);
     Delete(Line, 1, 16);
     Line := StringReplace(Line,'"','');
     SetField(fieldOriginalTitle, Line);
    end
   //Country and Year
   else if pos('<b>País y año:</b>',Line) <> 0 then
    begin
     LineNr := LineNr + 1;
     Line := Page.GetString(LineNr);
     SetField(fieldCountry, Line);
     LineNr := LineNr + 1;
     Line := Page.GetString(LineNr);
     SetField(fieldYear, copy(Line, 2, 4));
    end
   //Category and Length
   else if pos('<b>Género:</b>', Line) <> 0 then
    begin
     HTMLRemoveTags(Line);
     Delete(Line, 1, 7);
     SetField(fieldCategory, Line);
     LineNr := LineNr + 1;
     Line := Page.GetString(LineNr);
     HTMLRemoveTags(Line);
     Delete(Line, 1, 9);
     SetField(fieldLength, copy(Line, 1, 3));
     If GetField(fieldLength) = '' then
      SetField(fieldLength, copy(Line, 1, 2));
    end
   //Rating
   else if pos('<b>Crítica:</b>', Line) <> 0 then
    begin
     irate := 0;
     LineNr := LineNr + 1;
     Line := Page.GetString(LineNr);
     EndRating := pos('<img src="http://eur.i1.yimg.com/eur.yimg.com/i/de/mo/1sg.gif" width=10 height=9>', Line);
     while EndRating = 0 do
      begin
       irate := irate + 1;
       LineNr := LineNr + 1;
       Line := Page.GetString(LineNr);
       EndRating := pos('<img src="http://eur.i1.yimg.com/eur.yimg.com/i/de/mo/1sg.gif" width=10 height=9>', Line);
      end
     SetField(fieldRating, IntToStr(irate*2));
    end
   //Description
   else if pos('<b>Sinopsis:</b>', Line) <> 0 then
    begin
     LineNr := LineNr + 2;
     Line := Page.GetString(LineNr);
     HtmlRemoveTags(Line);
     SetField(fieldDescription, Line);
    end
   //List of Actors
   else if pos('<b>Actor / Actriz:</b>', Line) <> 0 then
    begin
     strActors := '';
     LineNr := LineNr + 2;
     Line := Page.GetString(LineNr);
     EndActors := pos('</font></td></tr>', Line);
     while EndActors = 0 do
      begin
       HtmlRemoveTags(Line);
       if strActors = '' then
        strActors := Line
       else
        strActors := strActors + ' ' + Line;
       LineNr := LineNr + 1;
       Line := Page.GetString(LineNr);
       EndActors := pos('</font></td></tr>', Line);
      end
     SetField(fieldActors, strActors);
    end
   else if pos('Montador:</b>', Line) <> 0 Then
    begin
     LineNr := LineNr + 2;
     Line := Page.GetString(LineNr);
     HtmlRemoveTags(Line);
     strComments := 'Montaje: ' + Line + #13#10;
    end
   // Music for Comments
   else if pos('<b>Musica:</b>', Line) <> 0 then
    begin
     strMusics := '';
     LineNr := LineNr + 2;
     Line := Page.GetString(LineNr);
     EndMusics := pos('</font></td></tr>', Line);
     while EndMusics = 0 do
      begin
       HtmlRemoveTags(Line);
       if strMusics = '' then
        strMusics := Line
       else
        strMusics := strMusics + ' ' + Line;
       LineNr := LineNr + 1;
       Line := Page.GetString(LineNr);
       EndMusics := pos('</font></td></tr>', Line);
      end
     strComments := strComments + 'Música: ' + strMusics + #13#10;
    end
   // Aditional Music Author for Comments
   else if pos('<b>Compositor (música adicional):</b>', Line) <> 0 then
    begin
     LineNr := LineNr + 2;
     Line := Page.GetString(LineNr);
     HtmlRemoveTags(Line);
     strComments := strComments + 'Compositor: ' + Line + #13#10;
    end
   //Director
   else if pos('<b>Director:</b>', Line) <> 0 then
    begin
     strDirectors := '';
     LineNr := LineNr + 2;
     Line := Page.GetString(LineNr);
     EndDirectors := pos('</font></td></tr>', Line);
     while EndDirectors = 0 do
      begin
       HtmlRemoveTags(Line);
       if strDirectors = '' then
        strDirectors := Line
       else
        strDirectors := strDirectors + ' ' + Line;
       LineNr := LineNr + 1;
       Line := Page.GetString(LineNr);
       EndDirectors := pos('</font></td></tr>', Line);
      end
     SetField(fieldDirector, strDirectors);
    end
   //Photography for Comments
   else if pos('<b>Fotografía:</b>', Line) <> 0 then
    begin
     strPhotographers := '';
     LineNr := LineNr + 2;
     Line := Page.GetString(LineNr);
     EndPhotographers := pos('</font></td></tr>', Line);
     while EndPhotographers = 0 do
      begin
       HtmlRemoveTags(Line);
       if strPhotographers = '' then
        strPhotographers := Line
       else
        strPhotographers := strPhotographers + ' ' + Line;
       LineNr := LineNr + 1;
       Line := Page.GetString(LineNr);
       EndPhotographers := pos('</font></td></tr>', Line);
      end
     strComments := strComments + 'Fotografía: ' + strPhotographers + #13#10;
    end
   //Screenplay Writer for Comments
   else if (pos('<b>Guionista:</b>', Line) <> 0) Or (pos('<b>Guión', Line) <> 0) then
    begin
     strWriters := '';
     LineNr := LineNr + 2;
     Line := Page.GetString(LineNr);
     EndWriters := pos('</font></td></tr>', Line);
     while EndWriters = 0 do
      begin
       HtmlRemoveTags(Line);
       if strWriters = '' then
        strWriters := Line
       else
        strWriters := strWriters + ' ' + Line;
       LineNr := LineNr + 1;
       Line := Page.GetString(LineNr);
       EndWriters := pos('</font></td></tr>', Line);
      end
     strComments := strComments + 'Guionista: ' + strWriters + #13#10;
    end
   //Producer
   else if (pos('<b>Producción:</b>', Line) <> 0) Or (pos('<b>Productor', Line) <> 0) then
    begin
     strProducers := '';
     LineNr := LineNr + 2;
     Line := Page.GetString(LineNr);
     EndProducers := pos('</font></td></tr>', Line);
     while EndProducers = 0 do
      begin
       HtmlRemoveTags(Line);
       if strProducers = '' then
        strProducers := Line
       else
        strProducers := strProducers + ' ' + Line;
       LineNr := LineNr + 1;
       Line := Page.GetString(LineNr);
       EndProducers := pos('</font></td></tr>', Line);
      end
     SetField(fieldProducer, strProducers);
    end
   // More Comments
   else if pos('<b>Notas de Producción</b>', Line) <> 0 then
    begin
     LineNr := LineNr + 2;
     Line := Page.GetString(LineNr);
     strTemp := TextBetween(Line, '<FONT face=arial size=-1>', '<a href="');
     HtmlDecode(strTemp);
     strComments := strComments + '------------------------------'; 
     strComments := strComments + #13#10 + strTemp;
    end
   // More Comments
   else if pos('<b>Crítica</b>', Line) <> 0 then
    begin
     LineNr := LineNr + 2;
     Line := Page.GetString(LineNr);
     strTemp := TextBetween(Line, '<FONT face=arial size=-1>', '<a href="');
     HtmlDecode(strTemp);
     strComments := strComments + '------------------------------'; 
     strComments := strComments + #13#10 + strTemp;
    end
   else if Line = '</html>' then
    Fine := 1;
  until Fine = 1;
  SetField(fieldComments, strComments);
end;
DisplayResults;
end;

procedure AddMoviesTitles(Page: TStringList);
var
LineNr: Integer;
NewLineNr: Integer;
Line: string;
MovieTitle, MovieAddress: string;
BeginPos, EndPos: Integer;
begin
TheMovieAddress := '*';
LineNr := 0;
LineNr := FindLine('<font face=arial,helvetica><b>Resultado de películas</b>',Page,LineNr);
LineNr := LineNr + 3;
PickTreeAdd('Resultados encontrados:','');
while LineNr > 2 do
begin
  Line := Page.GetString(LineNr);
  BeginPos := pos('<li><a href="',Line)+13;
  EndPos := pos('">',Line);
  MovieAddress := copy(Line,BeginPos,EndPos-BeginPos);
  Delete(Line,1,EndPos + 1);
  BeginPos := 1;
  EndPos := -1;
  MovieTitle := Line;
  HTMLRemoveTags(MovieTitle);
  HTMLDecode(Movietitle);
  PickTreeAdd(MovieTitle, MovieAddress);

  NewLineNr := FindLine('<li><a href="',Page,LineNr+1);
  if NewLineNr <> (LineNr + 1) then
   LineNr := 2
  else
   LineNr := NewLineNr;

  if TheMovieAddress='*' then
   TheMovieAddress := MovieAddress
  else
   TheMovieAddress := '';
end;
if TheMovieAddress='*' then TheMovieAddress := '';
end;

begin
if CheckVersion(3,4,0) then
begin
  MovieName := GetField(fieldTranslatedTitle);
  if MovieName = '' then
   MovieName := GetField(fieldOriginalTitle);
  if Input('Yahoo!Cinema España', 'Introduce el título de la película (enter movie title):', MovieName) then
  begin
   AnalyzePage('http://es.search.movies.yahoo.com/search/movies_db_es?mt='+UrlEncode(MovieName));
  end;
end else
  ShowMessage('This script requires a newer version of Ant Movie Catalog (at least the version 3.4.0)');
end.
Last edited by folgui on 2005-01-02 17:15:41, edited 6 times in total.
antp
Site Admin
Posts: 9630
Joined: 2002-05-30 10:13:07
Location: Brussels
Contact:

Post by antp »

Thanks, it will be included in the next update ;)
folgui
Posts: 113
Joined: 2003-02-04 19:15:03
Location: Madrid, Spain

Post by folgui »

Above script modified.

Now, no problems with number of digits in length of movies.

Deleted lines that wasn't neccesary. Now OK i think.

Thanks Antoine for this great program ;)
folgui
Posts: 113
Joined: 2003-02-04 19:15:03
Location: Madrid, Spain

Post by folgui »

Hello!

Here's another spanish script, there isn't only culturalia :)

No reply since time ago. Perhaps, need some update or get more info, if possible. Or some checks to confirmate working successfull.

Available on the last scripts pack from antp, with date 01-09-03.

Only to remember it if someone doesn't know it.

Perhaps, some advantages above culturalia, it that imports "Length" of movie and has some movies culturalia doesn't like "La Bella y la Bella 2".

Regards, folgui.
KaBeCi
Posts: 23
Joined: 2003-08-29 15:28:19

Post by KaBeCi »

just to reply.. the script works fine, may be you havent received any reply because a script for Yahoo Cinema (ES) is useless
why people will get info from a spanish site if it doesnt have any description/summary/quote of the movie? that's why I (and i think most of spanish talkers here) use the Culturalia script, to get the spanish description.
homeroarg

Need Some Help

Post by homeroarg »

Can anyone with skills (that is why i can not do it) modify this script to make it batch and to let me choose what is going to be imported, like in the IMDB batch script ?!? I want to import the translated title, the actors and the description but i don't want to change the pictures....
I think it shouldn't be too hard, i hope someone can give me a hand with this. :wink:
antp
Site Admin
Posts: 9630
Joined: 2002-05-30 10:13:07
Location: Brussels
Contact:

Post by antp »

The easiest way to block some fields from being modified is to edit the script and put a "//" in front of the lines that do not have to be executed.
The lines that modify fields are those that contain a call to "SetField", and the line that sets the picture contains "GetPicture".
homeroarg

Post by homeroarg »

Found that just after hitting "Submit".... :p
Guest

Post by Guest »

Hello!

Script updated (1st message of thread) with a few changes:

- Possibility of importing the large picture that Yahoo!Cinema offers. By default, the script imports it.
- Obtains more info from page than before, like rating, full list of actors, musicians, photographers, writers, producers, ...

Just check it.

Regards, folgui.
folgui
Posts: 113
Joined: 2003-02-04 19:15:03
Location: Madrid, Spain

Post by folgui »

Hello!

One day after previous update, another one ;)

- It gets now more info for comments, from "Notas de Producción" and "Crítica".
- Also fixes some movies where Screen Writer and Producer headings appear in different ways and that info wasn't added.

Regards, folgui
Dinamitic

Me da error (It give me this error)

Post by Dinamitic »

Error de seqüencia: YAHOOCINEMA en posicion 10993 (unknow identifier: STRTEMP)

Corresponde a la sequencia de la linea numero 367 con el texto: "strTemp := TextBetween(Line, '<FONT face=arial size=-1>',...."


Alguna idea?

Error del script? o mio?
micmic
Posts: 24
Joined: 2004-03-21 13:36:45
Location: Mi casa
Contact:

Post by micmic »

Script mistake. Change this:

Code: Select all

procedure AnalyzeMoviePage(Page: TStringList);
var
 Fine: Integer;
 EndActors: Integer;
 EndProducers: Integer;
 EndMusics: Integer;
 EndDirectors: Integer;
 EndPhotographers: Integer;
 EndWriters: Integer;
 EndRating: Integer;
 strActors: string; 
This is correct (new: variable definition):

Code: Select all

procedure AnalyzeMoviePage(Page: TStringList);
var
 Fine: Integer;
 EndActors: Integer;
 EndProducers: Integer;
 EndMusics: Integer;
 EndDirectors: Integer;
 EndPhotographers: Integer;
 EndWriters: Integer;
 EndRating: Integer;
 strTemp: string;
 strActors: string; 
folgui
Posts: 113
Joined: 2003-02-04 19:15:03
Location: Madrid, Spain

Post by folgui »

Hello!

A bug introduced in the latest modifications :/

I've been on christmas holiday's, so thanks micmic :grinking: for answering and fixing the problem.

Script of first message of this thread, already fixed.

Regards, folgui
micmic
Posts: 24
Joined: 2004-03-21 13:36:45
Location: Mi casa
Contact:

Post by micmic »

;) Not at all
Post Reply