When i export my db for myhtpc i have a problem with this script. The format for the fields actors, producer and director they must be formatted as: "Al Pacino" , "Robert De Niro" , "ect...". (note the space after comma)
Instead with this script the format is: Al Pacino, Robert De Niro, ect...
Can anyone help me to correct the script?
Thanks
[ITA] Filmup script modification for myHTPC
why this "[ITA]" in the title ? 
myhtpc is not a script, it is a template. It means that it is simply filled with data, and can't do special processing.
If you want to insert a space before all the commas in the Actor field, select the movies to modify, then go to Tools -> Scripting -> Editor -> New
and enter the following script :

myhtpc is not a script, it is a template. It means that it is simply filled with data, and can't do special processing.
If you want to insert a space before all the commas in the Actor field, select the movies to modify, then go to Tools -> Scripting -> Editor -> New
and enter the following script :
Code: Select all
program AddSpace;
begin
SetField(FieldActors, StringReplace(GetField(FieldActors), ', ', ' , '));
end.
Last edited by antp on 2004-02-04 18:55:21, edited 1 time in total.
You have reason, to the beginning I wanted to write it in Italian, for having more answers I have preferred to write it in English. But is not possible to make change in this script to perform the change?antp wrote:why this "[ITA]" in the title ?
myhtpc is not a script, it is a template. It means that it is simply filled with data, and can't do special processing.
If you want to insert a space before all the commas in the Actor field, select the movies to modify, then go to Tools -> Scripting -> Editor -> New
and enter the following script :Code: Select all
program AddSpace; begin SetField(FieldActors, StringReplace(GetField(FieldActors), ', ', ' , '); end.
Code: Select all
// GETINFO SCRIPTING
// FilmUP (IT) import
(**************************************************
* Movie importation script for: *
* FilmUP (IT), http://www.filmup.com *
* *
* MODIF. DA: PIVELLO (originale di L. Francisco) *
* MODIF. DA: ZANDAL (originale di L. Francisco) *
* Sistemato puntamento a COMMENTS *
* *
* For use with Ant Movie Catalog 3.4.1 *
* www.ant.be.tf/moviecatalog *
* *
* 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 FilmUP;
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;
procedure AnalyzePage(Address: string);
var
Page: TStringList;
LineNr: integer;
BeginPos: integer;
begin
Page := TStringList.Create;
Page.Text := GetPage(Address);
LineNr := FindLine('<title>FilmUP - Cerca: ', 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 AnalyzePage(Address);
end
else
begin
SetField(fieldURL, TheMovieAddress);
Page.Text := GetPage(TheMovieAddress);
AnalyzeMoviePage(Page);
end;
end;
Page.Free;
end;
procedure AnalyzeMoviePage(Page: TStringList);
var
Line: string;
NomeHtml: string;
LineNr,PrevLineNr: Integer;
BeginPos, EndPos: Integer;
Field: integer;
begin
LineNr := FindLine('<font face="arial, helvetica" size="3"><b>', Page, 0);
if LineNr > -1 then
begin
//Translated Title
Line := Page.GetString(LineNr);
HTMLRemoveTags(Line);
SetField(fieldTranslatedTitle, Line);
repeat
//Look for next info
repeat
LineNr := LineNr + 1;
Line := Page.GetString(LineNr);
HTMLRemoveTags(Line);
until Line<>'';
//Look for type of line
if Line = 'Titolo originale: ' then
Field := fieldOriginalTitle
else if Line = 'Regia: ' then
Field := fieldDirector
else if Line = 'Produzione: ' then
Field := fieldProducer
else if Line = 'Nazione: ' then
Field := fieldCountry
else if Line = 'Genere: ' then
Field := fieldCategory
else if Line = 'Anno: ' then
Field := fieldYear
else if Line = 'Durata: ' then
Field := fieldLength //Special case: get number only
else if Line = 'Cast: ' then
Field := fieldActors
else if Line = 'Trama:' then
Field := fieldDescription
else
Field := 0;
// I have to add this test, for sometimes the description
// is on the same line as the tag 'Trama'
if (copy(Line,1,6)='Trama:') and (length(Line)>6) then
begin
Field := fieldDescription;
Delete(Line,1,6);
HTMLDecode(Line);
end
else
begin
//Get values
LineNr := LineNr + 1;
Line := Page.GetString(LineNr);
HTMLRemoveTags(Line);
HTMLDecode(Line);
//Special case: Length
if Field = fieldLength then Line := copy(Line,1,length(Line)-1);
end;
if Field<>0 then SetField(Field,Line);
until Field=fieldDescription;
end;
PrevLineNr := LineNr;
//Comments
LineNr := FindLine('">Recensione</a>', Page, PrevLineNr);
if LineNr > -1 then
begin
Line := Page.GetString(LineNr);
if Pos('DVD', Line) <> 0 then Delete(Line,1,pos('DVD',Line));
if Pos('Scheda', Line) <> 0 then Delete(Line,1,pos('Scheda',Line));
Delete(Line,1,pos('<a href="',Line)+8);
NomeHtml :=Copy(Line,1,pos('"',Line)-1);
if (copy(NomeHtml,1,1)<>'/') then
begin
NomeHtml := '/' + NomeHtml;
end;
GetComments('http://www.filmup.com'+NomeHtml);
PrevLineNr := LineNr;
end;
//Rating
LineNr := FindLine('">Opinioni</a>', Page, PrevLineNr);
if LineNr > -1 then
begin
Line := Page.GetString(LineNr);
Delete(Line,1,pos('Recensione',Line));
Delete(Line,1,pos('<a href="',Line)+8);
// ----------------------
// MODIFICATO DA PIVELLO: dava errore perchè il path ora è esteso.
// ----------------------
// Line := GetLineFromOtherPage('http://www.filmup.com/'+Copy(Line,1,pos('"',Line)-1),'</b> - <img src="/img/star/');
Line := GetLineFromOtherPage(Copy(Line,1,pos('"',Line)-1),'</b> - <img src="/img/star/');
if Line <> '' then
begin
Line := Copy(Line,1,pos('</b> - <img src="/img/star/',Line)-1);
if pos('.',Line)>0 then Line := Copy(Line,1,pos('.',Line)-1);
SetField(fieldRating,Line);
end;
PrevLineNr := LineNr;
end;
//Picture
LineNr := FindLine('<a href="posters/locp/', Page, PrevLineNr);
if LineNr = -1 then
begin
LineNr := FindLine('<img src="locand/', Page, PrevLineNr);
if LineNr > -1 then
begin
Line := Page.GetString(LineNr);
Delete(Line,1,pos('<img src="locand/', Line)+9);
GetPicture('http://www.filmup.com/'+Copy(Line,1,pos('"',Line)-1), False);
end;
end
else
begin
Line := Page.GetString(LineNr);
Delete(Line,1,pos('<a href="posters/locp/',Line)+8);
Line := GetLineFromOtherPage('http://www.filmup.com/'+Copy(Line,1,pos('"',Line)-1),'<img src="../loc/500/');
if Line <> '' then
begin
Delete(Line,1,pos('<img src="../',Line)+12);
GetPicture('http://www.filmup.com/posters/'+Copy(Line,1,pos('"',Line)-1), False);
end;
end;
DisplayResults;
end;
function GetLineFromOtherPage(address: string; hint: string): string;
var
Page: TStringList;
LineNr: integer;
begin
Page := TStringList.Create;
Page.Text := GetPage(Address);
LineNr := FindLine(hint, Page, 0);
if LineNr > -1 then result := Page.GetString(LineNr);
Page.Free;
end;
procedure GetComments(address: string);
var
Page: TStringList;
BeginLine: integer;
EndLine: integer;
i: integer;
Line, Comments: string;
begin
Page := TStringList.Create;
Page.Text := GetPage(Address);
BeginLine := FindLine('RECENSIONI', Page, 0);
BeginLine := FindLine('<font face="arial,helvetica" size="2"><b>', Page, BeginLine);
EndLine := FindLine('<a href="opinioni.htm">Scrivi la tua recensione!</a></font><br><br>', Page, BeginLine);
for i:= BeginLine+1 to EndLine-1 do
begin
Line := Page.GetString(i);
Line := StringReplace(Line, '<br>', #13#10);
Line := StringReplace(Line, #13#10#32, #13#10);
HTMLRemoveTags(Line);
HTMLDecode(Line);
Comments := Comments + Line;
end;
SetField(fieldComments, Comments);
Page.Free;
end;
procedure AddMoviesTitles(Page: TStringList);
var
LineNr: Integer;
Line: string;
MovieTitle, MovieAddress: string;
BeginPos, EndPos: Integer;
begin
LineNr := 0;
LineNr := FindLine('FilmUP - Scheda:',Page,LineNr);
while LineNr > -1 do
begin
Line := Page.GetString(LineNr);
BeginPos := pos('<a href="',Line)+9;
EndPos := pos('" TARGET="_blank"><b>FilmUP - Scheda: ',Line);
MovieAddress := copy(Line,BeginPos,EndPos-BeginPos);
Delete(Line,1,EndPos);
BeginPos := pos('Scheda: ',Line)+8;
EndPos := pos('</a>',Line);
MovieTitle := copy(Line,BeginPos,EndPos-BeginPos);
HTMLRemoveTags(MovieTitle);
HTMLDecode(Movietitle);
LineNr := FindLine('FilmUP - Scheda:',Page,LineNr+1);
PickTreeAdd(MovieTitle, MovieAddress);
if TheMovieAddress='*' then
TheMovieAddress := MovieAddress
else
TheMovieAddress := '';
end;
LineNr := FindLine('Successivo',Page,LineNr);
Line := Page.GetString(LineNr);
BeginPos := pos('HREF',Line);
if BeginPos>0 then
begin
Delete(Line,1,BeginPos + 5);
EndPos := pos('"',Line);
MovieAddress := copy(Line,1,EndPos-1);
PickTreeMoreLink('http://www.filmup.com'+MovieAddress);
end;
if TheMovieAddress='*' then TheMovieAddress := '';
end;
// -----------------------------
// Questo è il main dello script
// -----------------------------
begin
if CheckVersion(3,4,1) then
begin
TheMovieAddress := '*';
MovieName := GetField(fieldOriginalTitle);
if MovieName = '' then
MovieName := GetField(fieldTranslatedTitle);
if Input('FilmUP Import', 'Digita il titolo del film:', MovieName) then
begin
AnalyzePage('http://www.filmup.com/cgi-bin/search.cgi?q='+UrlEncode(MovieName)+'&ul=%25%2Fsc_%25');
end;
end
else
ShowMessage('Questo script richiede una versione più nuova di Ant Movie Catalog (almeno la versione 3.4.1)');
end.
after the line
insert the line
Code: Select all
if Field = fieldLength then Line := copy(Line,1,length(Line)-1);
Code: Select all
if Field = fieldActors then Line := StringReplace(Line, ', ', ' , ');
Very thanks for your fast answer. I have modified your line, and this is the code:antp wrote:after the lineinsert the lineCode: Select all
if Field = fieldLength then Line := copy(Line,1,length(Line)-1);
Code: Select all
if Field = fieldActors then Line := StringReplace(Line, ', ', ' , ');
Code: Select all
//Special case: Length
if Field = fieldLength then Line := copy(Line,1,length(Line)-1);
if Field = fieldDirector then
begin
Line := StringReplace(Line, ', ', '" , "');
Line := StringReplace(Line, '.', '');
Line := '"' + Line + '"';
end
if Field = fieldActors then
begin
Line := StringReplace(Line, ', ', '" , "');
Line := StringReplace(Line, '.', '');
Line := '"' + Line + '"';
end
end;