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
* 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, Code);
end;
end;
procedure AnalyzeMoviePage(Address: string; Code: string);
var
Page: TStringList;
Comments: string;
strTitle: string;
strSinopsis: string;
strLength: string;
Line: string;
LineNr: Integer;
BeginPos, EndPos: Integer;
EndSinopsis: Integer;
begin
Page := TStringList.Create;
Page.Text := StringReplace(GetPage(Address), '<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
SetField(fieldDescription, 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;
Page := TStringList.Create;
Page.Text := StringReplace(GetPage('http://www.culturalianet.com/art/ver.php?art=' + Code), '<br>', #13#10);
LineNr := FindLine('>Duración:</font> ', Page, 0);
strLength := Page.GetString(LineNr);
EndPos := pos(' minutos.', strLength);
BeginPos := pos('Duración:</font> ', strLength) + 17;
strLength := copy(strLength, BeginPos, EndPos - BeginPos);
SetField(fieldLength, strLength);
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.
"Thanks to Culturalia's webmaster for his help and for providing more direct access to his database."
This direct access to database has no the length information, but it is on normal webpage. Now Retrieves everything from the "direct access to database", and after the length from the normal webpage.
There is still more information than can be retrieved from the normal webpage, but I'm not really interested in it. (Premios, Calificacion Moral, Puntuacion...)