Although I have
Code: Select all
OutToFile.Append(UTF8Encode(FormatedData + MovieDirector + MovieGenre + '</movie>'));
Full Script
Code: Select all
program XBMC2Nfo;
uses StringUtils1;
var
MovieGenre: string;
MovieDirector: string;
SavefileName: string;
DirSelected: string;
FormatedData: string;
OutToFile: TStringList;
function GenreToXML(genre: string): string;
var
lstGenre: TStringList;
iGenre: Integer;
sGenre: string;
begin
lstGenre := TStringList.Create;
lstGenre.Text := StringReplace(genre, ', ', #13#10);
for iGenre := 0 to lstGenre.Count -iGenre do
begin
sGenre := ' <genre>' + lstGenre.GetString(iGenre) + '</genre>';
lstGenre.SetString(iGenre, sGenre);
end
Result := lstGenre.Text;
lstGenre.Free;
end;
function DirectorToXML(director: string): string;
var
lstDirector: TStringList;
iDirector: Integer;
sDirector: string;
begin
lstDirector := TStringList.Create;
lstDirector.Text := StringReplace(director, ', ', #13#10);
for iDirector := 0 to lstDirector.Count -iDirector do
begin
sDirector := ' <director>' + lstDirector.GetString(iDirector) + '</director>';
lstDirector.SetString(iDirector, sDirector);
end
Result := lstDirector.Text;
lstDirector.Free;
end;
function ChooseTitle(Original: string; Translated: string): string;
begin
if Translated <> '' then Result := Translated else Result := Original
end;
begin
if DirSelected ='' then
begin
Input('Folder Select','Select Folder to save NFO files',DirSelected)
end;
begin
OutToFile := TStringList.Create;
SaveFileName := IncludeTrailingPathDelimiter(DirSelected) + GetField(fieldOriginalTitle) + '.NFO';
FormatedData := FormatedData +'<movie>'+#13#10;
FormatedData := FormatedData +' <title>'+ ChooseTitle(GetField(fieldOriginalTitle), GetField(fieldTranslatedTitle)) + '</title>'+#13#10;
FormatedData := FormatedData +' <originaltitle>'+GetField(fieldOriginalTitle)+'</originaltitle>'+#13#10;
FormatedData := FormatedData +' <rating></rating>'+#13#10;
FormatedData := FormatedData +' <year>'+GetField(fieldYear)+'</year>'+#13#10;
FormatedData := FormatedData +' <top250></top250>'+#13#10;
FormatedData := FormatedData +' <votes></votes>'+#13#10;
FormatedData := FormatedData +' <outline></outline>'+#13#10;
FormatedData := FormatedData +' <plot>'+GetField(fieldDescription)+'</plot>'+#13#10;
FormatedData := FormatedData +' <tagline></tagline>'+#13#10;
FormatedData := FormatedData +' <runtime></runtime>'+#13#10;
FormatedData := FormatedData +' <thumb></thumb>'+#13#10;
FormatedData := FormatedData +' <mpaa></mpaa>'+#13#10;
FormatedData := FormatedData +' <certification>UK:'+GetField(fieldMediaType)+'</certification>'+#13#10;
FormatedData := FormatedData +' <playcount></playcount>'+#13#10;
FormatedData := FormatedData +' <watched>'+GetField(fieldSource)+'</watched>'+#13#10;
FormatedData := FormatedData +' <id>' + TextAfter(GetField(fieldURL), '/title/') + '</id>'+#13#10;
FormatedData := FormatedData +' <id moviedb="allocine"></id>'+#13#10;
FormatedData := FormatedData +' <sets>'+#13#10;
FormatedData := FormatedData +' <set>'+GetField(fieldBorrower)+'</set>'+#13#10;
FormatedData := FormatedData +' </sets>'+#13#10;
FormatedData := FormatedData +' <id moviedb="filmweb"></id>'+#13#10;
FormatedData := FormatedData +' <filenameandpath></filenameandpath>'+#13#10;
FormatedData := FormatedData +' <trailer></trailer>'+#13#10;
FormatedData := FormatedData +' <studio></studio>' + #13#10;
FormatedData := FormatedData +' <actor>' + #13#10;
FormatedData := FormatedData +' <name></name>' + #13#10;
FormatedData := FormatedData +' <role></role>' + #13#10;
FormatedData := FormatedData +' </actor>' + #13#10;
(* Run Actor Script here*)
MovieGenre := GenreToXML(GetField(fieldCategory));
MovieDirector := DirectorToXML(GetField(fieldDirector));
OutToFile.Append(UTF8Encode(FormatedData + MovieDirector + MovieGenre + '</movie>'));
OutToFile.SaveToFile(SaveFileName);
OutToFile.Free;
FormatedData := ''
end;
end.