Page 1 of 2

Culturalia spanish script modified to correct some problems

Posted: 2003-06-22 11:32:39
by folgui
Hi!

Culturalia spanish script that comes with AMC has the next problems:

1. Always asks for Title of movie, i doesn't get it from fields (TranslatedTitle or OriginalTitle) if it exists.

2. If "Sinopsis" (description) has more than one paragraph, then script fails to obtain URL and PICTURE, because they aren't in the next secuencially line. For example: "60 segundos (Gone in Sixty Seconds)" or "Wasabi (Wasabi)". Corrected using function "FindLine".

3. For translated title always gets a . at final of it when original title hasn't it. I don't like that.

4. It didn't get more than one paragraph for "Sinopsis" (description). Thanks 'RedDwarf' and 'antp' ;)

The corrected script :

Code: Select all

// GETINFO SCRIPTING
// Culturalia  (Con Portada)

(***************************************************
*  Movie importation script for:                  *
*    Culturalia, http://www.culturalianet.com     *
*                                                 *
*  Original version made by David Arenillas       *
*  New version made by Antoine Potten             *
*  Modified by Jose Miguel Folgueira                  *
*  Modified by RedDwarf                                  *
*  Thanks to Culturalia's webmaster for his help  *
*  and for providing more direct access to his    *
*  database                                       *
*                                                 *
*  For use with Ant Movie Catalog 3.4.0           *
*  www.ant.be.tf/moviecatalog ··· www.buypin.com  *
*                                                 *
*  The source code of the script can be used in   *
*  another program only if full credits to        *
*  script author and a link to Ant Movie Catalog  *
*  website are given in the About box or in       *
*  the documentation of the program               *
***************************************************)

program Culturalia;
var
  MovieName: string;
const
  BaseURL = 'http://www.culturalianet.com/bus/catalogo.php';

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;
  Code, Title, TitleOri, Year: string;
begin
  Page := TStringList.Create;
  Page.Text := GetPage(Address);
  if Pos('No se ha encontrado ningún artículo por título', Page.Text) > 0 then
  begin
    ShowMessage('No se ha encontrado ningún artículo por título');
  end else
  begin
    PickTreeClear;
    LineNr := 1;
    Page.Text := StringReplace(Page.Text, '<br>', #13#10);
    PickTreeAdd('Search results:', '');
    while LineNr + 3 < Page.Count do
    begin
      Code := GetValueAfter(Page.GetString(LineNr), 'Codigo = ');
      Title := GetValueAfter(Page.GetString(LineNr+1), 'Titulo = ');
      TitleOri := GetValueAfter(Page.GetString(LineNr+2), 'Titulo original = ');
      Year := GetValueAfter(Page.GetString(LineNr+3), 'Año = ');
      PickTreeAdd(Title + ' (' + TitleOri + '), ' + Year, BaseURL + '?catalogo=1&codigo=' + Code);
      LineNr := LineNr + 5;
    end;
    Page.Free;
    if PickTreeExec(Address) then
      AnalyzeMoviePage(Address);
  end;
end;

procedure AnalyzeMoviePage(Address: string);
var
  Page: TStringList;
  Comments: string;
  strTitle: string;
  strSinopsis: string;
  Line: string;
  LineNr: Integer;
  EndPos: Integer;
  EndSinopsis: Integer;
  long: Integer;
begin
  Page := TStringList.Create;
  Page.Text := StringReplace(GetPage(Address), '<br><br>', #13#10);
  Page.Text := StringReplace(Page.Text, '<br>', #13#10);
  strTitle := GetValueAfter(Page.GetString(1), 'Titulo = '); 
  if copy(strTitle, Length(strTitle), Length(strTitle)) = '.' then 
  begin 
    SetField(fieldTranslatedTitle, copy(strTitle, 1, Length(strTitle) -1 )); 
  end else 
  begin 
    SetField(fieldTranslatedTitle, strTitle); 
  end; 
  SetField(fieldOriginalTitle, GetValueAfter(Page.GetString(2), 'Titulo original = '));
  SetField(fieldYear, GetValueAfter(Page.GetString(3), 'Año = '));
  SetField(fieldCategory, GetValueAfter(Page.GetString(4), 'Genero = '));
  SetField(fieldCountry, GetValueAfter(Page.GetString(5), 'Nacion = '));
  SetField(fieldDirector, GetValueAfter(Page.GetString(6), 'Director = '));
  SetField(fieldActors, GetValueAfter(Page.GetString(7), 'Actores = '));
  SetField(fieldProducer, GetValueAfter(Page.GetString(8), 'Productor = '));
  Comments := 'Guión: ' + GetValueAfter(Page.GetString(9), 'Guion = ');
  Comments := Comments + #13#10 + 'Fotografía: ' + GetValueAfter(Page.GetString(10), 'Fotografia = ');
  Comments := Comments + #13#10 + 'Música: ' + GetValueAfter(Page.GetString(11), 'Musica = ');
  SetField(fieldComments, Comments);
  LineNr := FindLine('Sinopsis = ', Page, 0);
  Line := Page.GetString(LineNr);
  strSinopsis := GetValueAfter(Line, 'Sinopsis = ');
  LineNr := LineNr + 1;
  Line := Page.GetString(LineNr);
  while pos('URL = ', Line) = 0 do
  begin
    strSinopsis := strSinopsis + #13#10 + Line;
    LineNr := LineNr + 1;
    Line := Page.GetString(LineNr);
  end
  HTMLRemoveTags(strSinopsis);
  SetField(fieldDescription, StringReplace(StringReplace(strSinopsis, '“', '"'), '”', '"'));
  LineNr := FindLine('URL = ', Page, 0);
  if LineNr <> -1 then
    SetField(fieldURL, GetValueAfter(Page.GetString(LineNr), 'URL = '));
  LineNr := FindLine('Imagen = ', Page, 0);
  if LineNr <> -1 then
    GetPicture(GetValueAfter(Page.GetString(LineNr), 'Imagen = '), False);
  Page.Free;
  DisplayResults;
end;

function GetValueAfter(Line, Identifier: string): string;
begin
  if Pos(Identifier, Line) = 1 then
    Result := Copy(Line, Length(Identifier)+1, Length(Line))
  else
    Result := '';
end;

begin
  if CheckVersion(3,4,0) then
  begin
     MovieName := GetField(fieldTranslatedTitle);
   if MovieName = '' then
      MovieName := GetField (fieldOriginalTitle);
     if Input('Importar de Culturalia', 'Introduce el Titulo de la Pelicula:', MovieName) then
           AnalyzePage(BaseURL + '?catalogo=1&texto=' + UrlEncode(MovieName) + '&donde=3');
  end else
     ShowMessage('This script requires a newer version of Ant Movie Catalog (at least the version 3.4.0)');
end.

Posted: 2003-06-22 12:31:33
by antp
Thanks ;)

Posted: 2003-06-24 06:52:28
by RedDwarf
Hey, thanks!!
I was starting to get tired of download the images at hand.
But seems that there is still a problem and I don't know nothing about this scripting language.
With the movie "El Caso Bourne", the sinopsis has more than one paragraph. Now the URL and image are loaded correctly, but the sinopsis isn't loaded fully, only the first paragraph is loaded

Posted: 2003-06-24 07:01:20
by RedDwarf
Ok, seems that the problem is with "SetField(fieldDescription, GetValueAfter(Page.GetString(12), 'Sinopsis = '));"

There isn't anything like GetParagraph?

Posted: 2003-06-24 07:15:59
by antp
A way to make it is to add each next row to the description, until the line starts with "URL" or the line is the last.

Posted: 2003-06-24 12:01:40
by folgui
Hi!

ENG: I have modified above script to get now full description correctly. The only problem is that is doesn't distinguish between paragraphs. All in one only paragraph.

ESP: He modificado el script de arriba para obtener la sinopsis correctamente. El unico problema es que no distingue los párrafos. Todo está en un mismo párrafo.

Regards, folgui.

Posted: 2003-06-24 15:51:08
by antp
You can seimply replace
strSinopsis := strSinopsis + Line;
by
strSinopsis := strSinopsis + #13#10 + Line;
and it will keep line breaks ;)

Posted: 2003-06-24 16:01:55
by folgui
antp wrote:strSinopsis := strSinopsis + #13#10 + Line;
and it will keep line breaks ;)
That's it. Already modified. Thanks ;)

Posted: 2003-06-24 16:33:59
by RedDwarf
Wow, that has been fast.
Then I will say you the last error I know. i don't know if is a problem with the script or with the program, but in the description field the caracter ” (las comillas, como se diga en ingles..) are showed like a |.

Note that the caracter ” is different that the caracter ": " ”
I obtanined it with a copy & paste.

Posted: 2003-06-24 16:44:12
by folgui
Hi!

It occurs with other scripts too. Don't know why. Perhaps 'antp' could help you in this question.

Otherwise, in the program you see | but if you export to html you'll see " correctlly.

folgui.

Posted: 2003-06-24 17:06:40
by antp
That's because the program uses MS Sans Serif (Windows 95/98/NT4 default font), and this characters does not exist in this font.
In next version I'll use Arial Unicode and other true type fonts, so it will work better, but the problem will then be with the "Large fonts" option that some people use :/

Posted: 2003-07-27 14:39:25
by RedDwarf
Do you really think I can't complain about anything more? I'm back!!! ;)

With a title of a movie like "Titulo = Otra terapia peligrosa. ¡Recaída total!." the fact that there is a period before the end of the title makes the script truncate it, at the end we have only "Otra terapia peligrosa"

Posted: 2003-07-27 14:51:29
by RedDwarf
There isn't something like pos ('.', strTitle) that gives the "pos" of the last '.'?

I suppose it can be archieved by making a bucle until "pos" returns NULL, but I really don't know about this language or Pascal.

Posted: 2003-07-27 15:04:45
by antp
Pos returns 0 if not found

Posted: 2003-07-28 07:02:54
by RedDwarf
strTitle := GetValueAfter(Page.GetString(1), 'Titulo = ');
if pos ('.', strTitle) = 0 then
begin
SetField(fieldTranslatedTitle, strTitle);
end else
begin
SetField(fieldTranslatedTitle, copy(strTitle, 1, Length(strTitle) -1 ));
end;
I think this is the best solution ;)

Posted: 2003-07-28 07:25:54
by RedDwarf

Code: Select all

  strTitle := GetValueAfter(Page.GetString(1), 'Titulo = ');
  if copy(strTitle, Length(strTitle), Length(strTitle)) = '.' then
  begin
    SetField(fieldTranslatedTitle, copy(strTitle, 1, Length(strTitle) -1 ));
  end else
  begin
    SetField(fieldTranslatedTitle, strTitle);
  end;
Uhm, before would be a problem if the title had a period somewhere in the middle and hadn't a period at the end (in theory there is a period at the end of all the titles, but....)

This should be fine for all possible cases

Posted: 2003-09-02 19:29:17
by Guest
Hi RedDwarf!

First, sorry for all this time away, but i've been on holidays.

The fix to the title problem is simple. Original culturalia worked ok, but as i say in point 3 i tried to fix the annoying last . (point) at title, and i used a simple movie with only one point in title, and this introduced a bug in the way a did it.

Solution:

strTitle := GetValueAfter(Page.GetString(1), 'Titulo = ');
strTitle := Copy(strTitle, 1, Length(strTitle)-1);
SetField(fieldTranslatedTitle, strTitle);

We get all the title and then assign all except last point.

I've fixed the script in the first message.

antp, take care of it to save it in the pack.

Regards, folgui ;)

Posted: 2003-09-02 19:46:37
by antp
Anonymous wrote: antp, take care of it to save it in the pack.
is this modification for the version currently included in AMC ?
because I see few topics about Culturalia and I am a little lost :/

Posted: 2003-09-02 19:49:13
by folgui
The "Guest" of above is I :-P

I've posted the solution without seeing your's, i think your's is better because it doesn't assume all movies have a point al the final.

I think the best is to close this thread and continue with your enhance with the length of movies (duracion).

Regards, folgui ;)

Posted: 2003-09-02 20:09:39
by folgui
Hi antp! You wrote:
is this modification for the version currently included in AMC ?
because I see few topics about Culturalia and I am a little lost :/
Sorry, i have arrived from holidays and also a little lost like you, and made some mistakes :-(

Yes, NOW, the above script of the first message is a modification to the lastest culturalia script that is in your amc_scripts.zip of 01-09-03 (the last one. at the moment).

It now includes the fix to the title of some movies that RedDwarfexplained some message above and i've included him in credits also.

What it not includes is the "length" (duracion) of movie that the default culturalia doesn't give, and that RedDwarf has added in the thread : viewtopic.php?t=849

So, if webmaster of culturalia says OK and the script of that thread, that enchances this one is OK and works, that one is a better version and should be the one to include in the pack.

Have i explained myself?

Regards, folgui ;)