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.