Script files creation
These script files are plain text files, so you can modify them with any text editor. But using Ant Movie Catalog's build-in editor allows to easily edit script header through the properties window.
The language used here is similar to Pascal and Delphi. If you never used Pascal but know another language (C, C++, PHP, Java or another), it will probably not be too difficult for you to learn it by studying existing scripts.
The script engine used here is the version 2 of Carlo Kok's Innerfuse Pascal Script.
Most of the basic functions are supported. There are also several functions and constants added for exchanging data with Ant Movie Catalog. This page describes them.
The script begins with a comment block, which is not visible when the script is opened with Ant Movie Catalog's editor. This block contains parameters that can be modified with the properties window.
Only scripts files that are in the "Scripts" folder will be displayed automatically in the list. These must have a ".ifs" extensoin. The files with a ".pas" extension are meant to be included by scripts, to provide additional functions. For example, StringUtils1.pas contains a set of functions to help handling and parsing text strings.
To include one of these files un de ces fichiers, a reference to it has to be put after the "uses" keyword in the beginning of the code:
program NewScript;
uses
file1, file2;
In this example, this will allow the script to call functions and variables contained in file1.pas and file2.pas.
Constants
These constants are the identifiers of the movie fields, useful when you want to set or get the value of a movie field:
fieldNumber / fNumber
fieldChecked / fChecked
fieldColorTag / fColorTag
fieldMedia / fMedia
fieldMediaType / fMediaType
fieldSource / fSource
fieldDate / fDate
fieldBorrower / fBorrower
fieldDateWatched / fDateWatched
fieldUserRating / fUserRating
fieldRating / fRating
fieldOriginalTitle / fOriginalTitle
fieldTranslatedTitle / fTranslatedTitle
fieldFormattedTitle / fFormattedTitle
fieldDirector / fDirector
fieldProducer / fProducer
fieldWriter / fWriter
fieldComposer / fComposer
fieldActors / fActors
fieldCountry / fCountry
fieldYear / fYear
fieldLength / fLength
fieldCategory / fCategory
fieldCertification / fCertification
fieldURL / fURL
fieldDescription / fDescription
fieldComments / fComments
fieldFilePath / fFilePath
fieldVideoFormat / fVideoFormat
fieldVideoBitrate / fVideoBitrate
fieldAudioFormat / fAudioFormat
fieldAudioBitrate / fAudioBitrate
fieldResolution / fResolution
fieldFrameRate / fFrameRate
fieldLanguages / fLanguages
fieldSubtitles / fSubtitles
fieldSize / fSize
fieldDisks / fDisks
fieldPictureStatus / fPictureStatus
fieldNbExtras / fNbExtras
These constants are the identifiers of the extra movie fields, useful when you want to set or get the value of an extra movie field:
extraFieldNumber / eNumber
extraFieldChecked / eChecked
extraFieldTag / eTag
extraFieldTitle / eTitle
extraFieldCategory / eCategory
extraFieldURL / eURL
extraFieldDescription / eDescription
extraFieldComments / eComments
extraFieldCreatedBy / eCreatedBy
extraFieldPictureStatus / ePictureStatus
These constants are the identifiers of the media information, useful when you want to get the information of a media:
mediaVolumeLabel
mediaPath
mediaPathName
mediaPathNameExt
mediaName
mediaNameFiltered
mediaNameExt
mediaFolder
mediaFolderFiltered
mediaExt
mediaExtWithoutDot
mediaSize
mediaDisks
mediaPicture
mediaLength
mediaResolution
mediaResHeight
mediaResWidth
mediaFramerate
mediaVideoCodec
mediaVideoBitrate
mediaAudioCodec
mediaAudioChannels
mediaAudioCodecAndChannels
mediaAudioBitrate
mediaLanguages
mediaSubtitles
These constants are the identifiers of possible picture status in catalog, useful when you want to call GetPictureStatus function:
picStatusUndefined
picStatusNone
picStatusStored
picStatusCopiedInCatDir
picStatusCopiedInPicDir
picStatusLinkAbs
picStatusLinkRel
These constants are the identifiers of picture import methods into catalog, useful when you want to call ImportPicture2 function:
picImportStore
picImportCopyInCatDir
picImportCopyInPicDir
picImportLinkAbs
picImportLinkRel
Other constants:
dirApp: string; contains program's path (with '\' to end)
dirData: string; contains program data's path (with '\' to end)
dirScripts: string; contains scripts' path (with '\' to end)
dirTemplates: string; contains templates' path (with '\' to end)
dirCatalogs: string; contains catalogs' path (with '\' to end)
dirCurrentCatalog: string; contains current catalog's path (with '\' to end)
fileCurrentCatalog: string; contains current catalog's file
Functions regarding script
function CheckVersion(Major, Minor, Revision: Integer): Boolean;
Returns True if the current version of the program is at least the version
specified in the parameters.
function AcceptLicense(LicenseVersion: Integer): Boolean;
Displays in a window the contents of the "License" field of the script as defined in the
properties window with "I agree" and "Cancel" buttons. When the
use accepts the license, he does not have to accept it again until the license number given
in parameter changes. This allows to show the window to all users when the license changes,
but not annoy them at each execution of the script.
function GetScriptFilename: string;
Returns the script filename.
function GetScriptFullPath: string;
Returns the script fullpath.
function GetScriptAuthors: string;
Returns the script authors defined in the properties window.
function GetScriptTitle: string;
Returns the script title defined in the properties window.
function GetScriptDescription: string;
Returns the script description defined in the properties window.
function GetScriptSite: string;
Returns the script site defined in the properties window.
function GetScriptVersion: string;
Returns the script version defined in the properties window.
function GetScriptComments: string;
Returns the script comments defined in the properties window.
function GetScriptLicense: string;
Returns the script license defined in the properties window.
function GetOption(OptName: string): Integer;
Returns the value that the user selected for the specified option. The options names and their values
are defined in the properties window.
function SetOption(OptName: string; Value: Integer);
Change the value of the specified option. The options names and their values
are defined in the properties window.
function GetParam(PrmName: string): string;
Returns the value that the user enter for the specified parameter. The parameters names
are defined in the properties window.
function SetParam(PrmName: string; Value: string);
Change the value of the specified parameter. The parameters names
are defined in the properties window.
procedure SetStatic(AName: string; AValue: string);
function GetStatic(AName: string): string;
Allows to read/write a "permanent" variable : the value assigned to this virtual variable
will be kept between each program execution, unlike a global variable that would be lost when
the script execution on select movies is finished.
function GetIteration: Integer;
Returns the current iteration (between 0 and GetIterationCount-1).
function GetIterationCount: Integer;
Returns the iteration count (number of movies to be processed).
function AddNewMovieToQueue: Integer;
Add a new movie to end of queue and return the movie number (unique).
procedure Launch(command: string; parameters: string);
Executes an external file. This can be a program, a file, or a web address. "parameters" can be an empty string: ''.
procedure Sleep(ATime: Integer);
Waits for the number of milliseconds specified in parameter (useful to avoid server connection errors in large imports).
procedure Error;
Stops the script at current line.
Functions to show/get messages
procedure ShowMessage(message: string);
"Neutral" window that simply displays the message.
procedure ShowError(message: string);
Error window ("x" icon on a red circle).
procedure ShowInformation(message: string);
Information window ("i" icon in a balloon).
function ShowWarning(message: string): Boolean;
Warning window ("!" icon on a yellow triangle), with "OK" (returns True) and
"Cancel" (returns False) buttons.
function ShowConfirmation(message: string): Boolean;
Confirmation window ("?" icon in a balloon), with "Yes" (returs True) and
"No" (returns False) buttons.
procedure ShowMemo(message: string);
"Neutral" window that simply displays the message in memo.
function Input(caption, prompt: string; var value: string): Boolean;
Displays an input box, allowing the user to enter a text. Returns True if
user clicks OK, False if user clicks Cancel.
Function to manage PickTree
PickTree is the window displaying a Tree, typically to use to display a list of the available movie pages.
procedure PickTreeTitle(Title: string);
Changes the title of PickTree window.
procedure PickTreeDefaultTitle;
Restores the default title of PickTree window.
procedure PickTreeClear;
Clears the contents of the window - Call this before using the window since
it is never cleared automatically.
procedure PickTreeAdd(Caption, Address: string);
Adds an item in the window. If Address is an empty string or if it the window
is still empty, the item will be added as a root-level item. Else it will
be added as a child item. The Address is the string returned by the window
when the user selects an item.
procedure PickTreeCount: Integer;
Returns the number of items in the window.
procedure PickTreeCountAddresses: Integer;
Returns the number of items with an address associated in the window.
procedure PickTreeMoreLink(Address: string);
Sets the address pointed by the button "Find more" on the PickTree
window. This value is cleared by PickTreeClear, and the button is disabled
if it is not initialized by PickTreeMoreLink.
procedure PickTreeSort;
Sort tree items.
function PickTreeExec(var Address: string): Boolean;
Shows the window. The Address parameter will contain the address string corresponding
to the selected item. The function returns True if the user selected OK button,
False if he selected the Cancel button.
function PickTreeExec2(var Address: string; var AddressId: Integer): Boolean;
Same as PickTreeExec function but add parameter AddressId corresponding to the position (in add order) of the selected item.
SelectedId = -1 if user clicks on Cancel.
SelectedId = -2 if user clicks on Find More.
function PickTreeExec3(Message: string; var Address: string): Boolean;
Same as PickTreeExec function but add parameter Message to display a message on top of PickTree window.
function PickTreeExec4(Message: string; var Address: string; var AddressId: Integer): Boolean;
Same as PickTreeExec3 function but add parameter Message to display a message on top of PickTree window.
Functions to manage PickList
PickList is the window displaying a simple List, typically to use to display a list of values available for one field (such as descriptions or comments). There is a large text area to display the currently selected item.
procedure PickListTitle(Title: string);
Changes the title of PickList window.
procedure PickListDefaultTitle;
Restores the default title of PickList window.
procedure PickListClear;
Clears the contents of the window - Call this before using the window since
it is never cleared automatically.
procedure PickListAdd(Text: string);
Adds an item in the window.
procedure PickListCount: Integer;
Returns the number of items in the window.
function PickListExec(WelcomeText: string; var Selected: string): Boolean;
Shows the window. WelcomeText is the text displayed in the preview area when
no item is selected. The Selected parameter will contain the selected item.
The function returns True if the user selected OK button, False if he selected
the Cancel button.
function PickListExec2(WelcomeText: string; var Selected: string; var SelectedId: Integer): Boolean;
Same as PickListExec function but add parameter SelectedId corresponding to the position of the selected item in the list.
SelectedId = -1 if user clicks on Cancel.
Functions to extract info from media
function LoadMedia(filename: string): Boolean;
Loads media information and return true if loading is a success.
function GetMediaInfo(mediaInfo: Integer): String;
Reads and returns the specified information of the current loaded media.
function GetMediaInfoLS(mediaInfo: Integer): String;
Same as GetMediaInfo but return value with Local Settings (for reals and dates).
Functions to manage cookies
procedure AddCookie(cookie: string; hostOrUrl: string);
Adds a new cookie or change its value and its properties for specified host or url.
Examples:
- AddCookie('cok=1; path=/film', 'http://www.example.com'):
Add cookie 'cok=1' for host 'www.example.com' with propertie 'path=/film'
(this cookie will be only visible for url starting with 'http://www.example.com/film/').
- AddCookie('cok=1; path=/', 'http://www.example.com'):
Add cookie 'cok=1' for host 'www.example.com' with propertie 'path=/'
(this cookie will be visible for url starting with 'http://www.example.com/').
- AddCookie('cok=1', 'http://www.example.com'):
Same as previous example, 'path=/' by default.
- AddCookie('cok=1; max-age=10', 'http://www.example.com'):
Add cookie 'cok=1' for host 'www.example.com' with propertie 'max-age=10' to delete this cookie in 10 seconds.
- AddCookie('cok=1; expires=Sun, 07-Aug-2016 16:43:12 GMT', 'http://www.example.com'):
Add cookie 'cok=1' for host 'www.example.com' with propertie 'expires=Sun, 07-Aug-2016 16:43:12 GMT' to delete this cookie after this date.
- AddCookie('cok=1; max-age=0', 'http://www.example.com'):
Add cookie 'cok=1' for host 'www.example.com' with propertie 'max-age=0' to delete this cookie immedialy.
- AddCookie('cok=1; expires=Thu, 01-Jan-1970 00:00:01 GMT', 'http://www.example.com'):
Add cookie 'cok=1' for host 'www.example.com' with propertie 'expires=Thu, 01-Jan-1970 00:00:01 GMT' to delete this cookie immedialy.
- AddCookie('cok=', 'http://www.example.com'):
Add cookie 'cok=' for host 'www.example.com' to delete this cookie immedialy.
procedure SetCookies(cookies: string; hostOrUrl: string);
Adds new cookies or changes its values for specified host
(e.g. nameCookie1=valueCookieC; nameCookie2=valueCookieD; nameCookie3=valueCookieE).
This function do not support add of properties for cookies (use AddCookie function for this). The 'path' used for cookies is '/'.
Fonctions to extract info from web pages
function GetPage(address: string): string;
Fetches an HTML page (or any other text file) using the GET method, and returns it as a string.
Returns empty if an error occurs.
function GetPage2(address: string; referer: string): string;
Same as GetPage, but allows to specify a "referer" address (page that called the next one). The default value is an empty string.
function GetPage3(address: string; referer: string; cookies: string): string;
Same as GetPage2, but allows to specify cookies as a string: 'uid=120; pwd=FHNHESW' for example (See functions to manage cookies for more options). The default value is an empty string.
function GetPage4(address: string; referer: string; cookies: string; content: string): string;
Same as GetPage3, but allows to specify the content-type as a string; by default for other versions the value is '*/*' for compatibility with old versions; you can pass '' for a more standard call.
function GetPage5(address: string; referer: string; cookies: string; content: string; headers: string): string;
Same as GetPage4, but allows to specify additional headers to provide to the server. They must be encoded using Delphi's TStrings format, i.e. a list of name=value items separated by linebreaks. The default value is an empty string.
function PostPage(address: string; params: string): string;
Fetches an HTML page (or any other text file) using the POST method, and returns it as a string.
The parameters have to be encoded with the URLEncode function.
Returns empty if an error occurs.
function PostPage2(address: string; params: string; content: string; referer: string; forceHTTP11: Boolean; forceEncodeParams: Boolean): string;
Same as PostPage, but allows to specify also the content-type (instead of the default 'application/x-www-form-urlencoded'),
give a "referer" address (default value is an empty string), force the use of HTTP 1.1 (default value is False, for 1.0) and ask to the function to encode the parameters itself (default value is False).
function PostPage3(address: string; params: string; content: string; referer: string; forceHTTP11: Boolean; forceEncodeParams: Boolean; headers: string): string;
Same as PostPage2, but allows to specify additional headers to provide to the server. They must be encoded using Delphi's TStrings format, i.e. a list of name=value items separated by linebreaks. The default value is an empty string.
procedure HTMLDecode(var Value: string);
Decode HTML characters contained in the string "Value" (e.g. "é"
-> "é").
procedure HTMLRemoveTags(var Value: string);
Deletes HTML tags found in the string "Value".
function URLEncode(source: string): string;
function URLDecode(source: string): string;
Converts characters to URL parameters (e.g. " " -> "+") and the other way round.
function GetPicture(address: string): Boolean;
Fetches a picture and assigns it to the current movie.
Returns false if an error occurs.
function GetPicture2(address: string; referer: string): Boolean;
Same as GetPicture, but allows to specify a "referer" address (page that called the next one).
function GetPicture3(address: string; referer: string; content: string): Boolean;
Same as GetPicture2, but allows to specify the content-type as a string; by default for other versions the value is '*/*' for compatibility with old versions; you can pass '' for a more standard call.
function GetExtraPicture(extraIndex: Integer; address: string): Boolean;
Fetches a picture and assigns it to the specified extra of the current movie.
Returns false if an error occurs.
function GetExtraPicture2(extraIndex: Integer; address: string; referer: string): Boolean;
Same as GetExtraPicture, but allows to specify a "referer" address (page that called the next one).
procedure RaiseConnectionErrors(raise: Boolean);
Shows or not an error message when a connection issue occurs during GetPage, PostPage, GetPicture, ...
Functions to manage fields value and picture of a movie
function IsSelected: Boolean;
Returns True if the current movie is selected in the movie list, False otherwise.
procedure SetSelected(selected: Boolean);
Selects or not the current movie in the movie list.
function GetField(field: Integer): string;
Reads and returns the value of the specified field of the current movie.
function GetFieldLS(field: Integer): string;
Same as GetField but return value with Local Settings (for reals and dates).
procedure SetField(field: Integer; value: string);
Stores a value in the specified field of the current movie.
function CanSetField(field: Integer): Boolean;
Informs the script if the specified field is checked or not in the modifiables fields list.
The script does not have to worry about that since a SetField will not do anything if the field
is not checked, but this function allows to prevent for example to download an additionnal page in the
case that some field does not have to by imported anyway.
function GetFieldName(field: Integer): String;
Returns the name of the specified field.
function GetFieldType(field: Integer): String;
Returns the type of the specified field: 'ftString', 'ftInteger', 'ftReal1' (1 decimal), 'ftReal2' (2 decimals), 'ftReal' (3 decimals), 'ftBoolean', 'ftDate', 'ftList', 'ftText', 'ftUrl', 'ftVirtual'.
function GetFieldTag(field: Integer): String;
Returns the tag of the specified field.
function GetFieldCount: Integer;
Returns the number of fields (custom fields not included).
function GetCustomField(fieldTag: string): string;
Reads and returns the value of the specified custom field of the current movie (fieldTag = Tag associed to the custom field).
function GetCustomFieldLS(fieldTag: string): string;
Same as GetCustomField but return value with Local Settings (for reals and dates).
procedure SetCustomField(fieldTag: string; value: string);
Stores a value in the specified custom field of the current movie.
function CanSetCustomField(fieldTag: string): Boolean;
Informs the script if the specified custom field exists and is checked or not in the modifiables fields list.
The script does not have to worry about that since a SetCustomField will not do anything if the field
does not exist or is not checked, but this function allows to prevent for example to download an additionnal page in the
case that some field does not have to by imported anyway.
function CustomFieldExists(fieldTag: string): Boolean;
Informs the script if the specified custom field exists.
The script does not have to worry about that since a SetCustomField will not do anything if the field
does not exist, but this function allows to inform user that field does not exist.
function GetCustomFieldName(fieldTag: string): String;
Returns the name of the specified custom field.
function GetCustomFieldType(fieldTag: string): String;
Returns the type of the specified custom field: 'ftString', 'ftInteger', 'ftReal1' (1 decimal), 'ftReal2' (2 decimals), 'ftReal' (3 decimals), 'ftBoolean', 'ftDate', 'ftList', 'ftText', 'ftUrl', 'ftVirtual'.
function GetCustomFieldTag(customfield: Integer): String;
Returns the tag of the specified custom field (customfield between 0 and GetCustomFieldCount-1).
function GetCustomFieldCount: Integer;
Returns the number of custom fields.
function ExportPicture(filename: string): Boolean;
Exports the picture of current movie in specified directory with specified name.
You can use PictureExt function to know picture extension.
function ImportPicture(filename: string): Boolean;
Imports a picture from specified file and assigns it to the current movie.
function ImportPicture2(filename: string; picImportMethod: integer): Boolean;
Same as ImportPicture but you can specify how to import picture into catalog with parameter picImportMethod.
The parameter picImportMethod can take the following values:
- picImportStore (store picture into catalog)
- picImportCopyInCatDir (copy picture into catalog folder)
- picImportCopyInPicDir (copy picture into pictures folder of catalog)
- picImportLinkAbs (only link picture with absolute link)
- picImportLinkRel (only link picture with relative link if possible)
function RemovePicture: Boolean;
Removes the picture of current movie.
function CanSetPicture: Boolean;
Similar to CanSetField, indicates if the script can get a picture.
function PictureExists: Boolean;
Indicates if current movie has a picture and it really exists (for copied or linked picture).
function GetPictureStatus: Integer;
Returns the status of the picture of the current movie:
- picStatusUndefined (not defined)
- picStatusNone (no picture)
- picStatusStored (picture is stored into catalog)
- picStatusCopiedInCatDir (picture is copied in catalog folder)
- picStatusCopiedInPicDir (picture is copied in pictures folder of catalog)
- picStatusLinkAbs (picture is only linked by absolute link)
- picStatusLinkRel (picture is only linked by relative link)
function GetPictureExt: string;
Returns picture extension if current movie has a picture, '' otherwise.
function GetPicturePath: string;
Returns the file path of picture if it is a copied or linked picture, '' otherwise.
function GetPictureFullPath: string;
Similar to PicturePath but returns absolute path.
function GetPictureSize: Double;
Returns picture size in bytes if current movie has a picture, -1 otherwise.
function GetPictureWidth: Integer;
Returns picture width in pixels if current movie has a picture, 0 otherwise.
function GetPictureHeight: Integer;
Returns picture height in pixels if current movie has a picture, 0 otherwise.
function ConvertPicture(maxWidth: Integer; maxHeight: Integer): Boolean;
Returns True if picture of current movie has been converted to JPG, False otherwise.
Conversion always keep the same picture ratio and only occurs if needed to avoid to lose picture quality.
(e.g. [maxWidth = 200, maxHeight = 0] -> Resize on specified width,
[maxWidth = 0, maxHeight = 300] -> Resize on specified height,
[maxWidth = 200, maxHeight = 300] -> Resize on width or height to fit in the specified rectangle).
Functions to manage extras of a movie
function GetExtraCount: Integer;
Returns the number of extras in extra list for the current movie.
function FindExtra(extraTag: string): Integer;
Returns the extra index (position of extra in extra list) with same specified tag (no case sensitive), -1 otherwise.
function AddExtra: Integer;
Adds a new extra. Returns extra index (position of extra in extra list) if extra has been added, -1 otherwise.
Note 1: Extra field number is always equals to extra index + 1. If you change the position of extra in extra list, you change the number and vice versa.
Note 2: When a new extra is added, the extra field "Created by" is filled automatically with the script title.
Thereby, you will can find later extras created by the script by comparing the field "Created by" with the script title (See GetScriptTitle function).
function CanAddExtras: Boolean;
Informs the script if the special field *Add extras* is checked or not in the modifiables fields list.
The script does not have to worry about that since a AddExtra will not do anything if the special field is not checked.
function DeleteExtra(extraIndex: Integer): Boolean;
Returns True if the specified extra of the current movie has been deleted, False otherwise.
function DeleteExtraCreatedBy(extraIndex: Integer; createdBy: string): Boolean;
Same as DeleteExtra function but deletes specified extra only if it has been created by the specified name (field "Created by" = createdBy).
function DeleteExtraOfScript(extraIndex: Integer): Boolean;
Same as DeleteExtra function but deletes specified extra only if it has been created by the current script (field "Created by" = GetScriptTitle).
procedure ClearExtras;
Clears all extras.
procedure ClearExtrasCreatedBy(createdBy: string);
Same as ClearExtras function but deletes only extras which have been created by the specified name (field "Created by" = createdBy).
procedure ClearExtrasOfScript;
Same as ClearExtras function but deletes only extras which have been created by the current script (field "Created by" = GetScriptTitle).
function CanDeleteExtras: Boolean;
Informs the script if the special field *Delete extras* is checked or not in the modifiables fields list.
The script does not have to worry about that since a DeleteExtra/ClearExtras will not do anything if the special field
is not checked and extra has not been created during script execution.
function IsExtraSelected(extraIndex: Integer): Boolean;
Returns True if the specified extra is selected in the extra list of current movie, False otherwise.
procedure SetExtraSelected(extraIndex: Integer; selected: Boolean);
Selects or not the specified extra in the extra list of current movie.
function GetExtraField(extraIndex: Integer; extraField: Integer): string;
Reads and returns the value of the specified field of the specified extra of the current movie.
procedure SetExtraField(extraIndex: Integer; extraField: Integer; value: string);
Stores a value in the specified field of the specified extra of the current movie.
function CanModifyExtras(extraField: Integer): Boolean;
Informs the script if the special field *Modify extras* is checked or not in the modifiables fields list.
The script does not have to worry about that since a SetExtraField will not do anything if the special field
is not checked and extra has not been created during script execution.
function CanSetExtraField(extraField: Integer): Boolean;
Informs the script if the specified extra field is checked or not in the modifiables fields list.
The script does not have to worry about that since a SetExtraField will not do anything if the field is not checked.
function GetExtraFieldName(extraField: Integer): String;
Returns the name of the specified extra field.
function GetExtraFieldType(extraField: Integer): String;
Returns the type of the specified extra field: 'ftString', 'ftInteger', 'ftReal1' (1 decimal), 'ftReal2' (2 decimals), 'ftReal' (3 decimals), 'ftBoolean', 'ftDate', 'ftList', 'ftText', 'ftUrl', 'ftVirtual'.
function GetExtraFieldTag(extraField: Integer): String;
Returns the tag of the specified extra field.
function GetExtraFieldCount: Integer;
Returns the number of extra fields.
function ExportExtraPicture(extraIndex: Integer; filename: string): Boolean;
Exports the picture of specified extra of current movie in specified directory with specified name.
You can use ExtraPictureExt function to know picture extension.
function ImportExtraPicture(extraIndex: Integer; filename: string): Boolean;
Imports a picture from specified file and assigns it to the specified extra of the current movie.
function ImportExtraPicture2(extraIndex: Integer; filename: string; picImportMethod: integer): Boolean;
Same as ImportExtraPicture but you can specify how to import picture into catalog with parameter picImportMethod.
The parameter picImportMethod can take the following values:
- picImportStore (store picture into catalog)
- picImportCopyInCatDir (copy picture into catalog folder)
- picImportCopyInPicDir (copy picture into pictures folder of catalog)
- picImportLinkAbs (only link picture with absolute link)
- picImportLinkRel (only link picture with relative link if possible)
function RemoveExtraPicture(extraIndex: Integer): Boolean;
Removes the picture of the specified extra of the current movie.
function CanSetExtraPicture: Boolean;
Similar to CanSetExtraField, indicates if the script can get an extra picture.
function ExtraPictureExists(extraIndex: Integer): Boolean;
Indicates if specified extra of the current movie has a picture and it really exists (for copied or linked picture).
function GetExtraPictureStatus(extraIndex: Integer): Integer;
Returns the status of picture of the specified extra of the current movie:
- picStatusUndefined (not defined)
- picStatusNone (no picture)
- picStatusStored (picture is stored into catalog)
- picStatusCopiedInCatDir (picture is copied in catalog folder)
- picStatusCopiedInPicDir (picture is copied in pictures folder of catalog)
- picStatusLinkAbs (picture is only linked by absolute link)
- picStatusLinkRel (picture is only linked by relative link)
function GetExtraPictureExt(extraIndex: Integer): string;
Returns picture extension if specified extra of the current movie has a picture, '' otherwise.
function GetExtraPicturePath(extraIndex: Integer): string;
Returns the file path of picture if specified extra of the current movie has a copied or linked picture, '' otherwise.
function GetExtraPictureFullPath(extraIndex: Integer): string;
Similar to ExtraPicturePath but returns absolute path.
function GetExtraPictureSize(extraIndex: Integer): Double;
Returns picture size in bytes if specified extra of the current movie has a picture, -1 otherwise.
function GetExtraPictureWidth(extraIndex: Integer): Integer;
Returns picture width in pixels if specified extra of the current movie has a picture, 0 otherwise.
function GetExtraPictureHeight(extraIndex: Integer): Integer;
Returns picture height in pixels if specified extra of the current movie has a picture, 0 otherwise.
function ConvertExtraPicture(extraIndex: Integer; maxWidth: Integer; maxHeight: Integer): Boolean;
Returns True if picture of specified extra of the current movie has been converted to JPG, False otherwise.
Conversion always keep the same picture ratio and only occurs if needed to avoid to lose picture quality.
(e.g. [maxWidth = 200, maxHeight = 0] -> Resize on specified width,
[maxWidth = 0, maxHeight = 300] -> Resize on specified height,
[maxWidth = 200, maxHeight = 300] -> Resize on width or height to fit in the specified rectangle).
Functions to manipulate strings
function StringReplace(S, Old, New: string): string;
Replaces Old by New into S (case sensitibe), and returns the result (S is not modified). Use #13#10 (without quotes) if you want to replace the linebreaks.
function StringReplace2(S, Old, New: string; IgnoreCase, ReplaceAll: Boolean): string;
Same as StringReplace but can ignore case or not (false by default) and replace all or not (true by default)
function AnsiCompareStr(S1, S2: string): Integer;
Compares strings S1 and S2. Return 0 if S1 = S2, -1 if s1 < S2, 1 if S1 > S2.
function AnsiCompareText(S1, S2: string): Integer;
Same as AnsiCompareStr but ignore case.
function AnsiCompare(S1, S2: string; IgnoreCase, IgnoreAccents: Boolean): Integer;
Same as AnsiCompareStr but can ignore case or not (false by default) and can ignore accents or not (false by default).
function AnsiNatCompareStr(S1, S2: string): Integer;
Compares strings S1 and S2 in natural way (detects numbers automatically). Return 0 if S1 = S2, -1 if S1 < S2, 1 if S1 > S2.
function AnsiNatCompareText(S1, S2: string): Integer;
Same as AnsiNatCompareStr but ignore case.
function AnsiNatCompare(S1, S2: string; IgnoreCase, IgnoreAccents: Boolean): Integer;
Same as AnsiNatCompareStr but can ignore case or not (false by default) and can ignore accents or not (false by default).
function AnsiPosEx(SubStr, S: string; IgnoreCase, IgnoreAccents: Boolean): Integer;
Return the position of the first occurence of the substring SubStr in the string S or 0 if substring has not been found.
function AnsiPosEx2(SubStr, S: string; IgnoreCase, IgnoreAccents: Boolean; StartPos: Integer): Integer;
Same as AnsiPosEx but can start comparison to a given position (1 by default).
function AnsiLastPosEx(SubStr, S: string; IgnoreCase, IgnoreAccents: Boolean): Integer;
Return the position of the last occurence of the substring SubStr in the string S or 0 if substring has not been found.
Note: Comparison of strings is done in reverse way (from last position to first position).
function AnsiLastPosEx2(SubStr, S: string; IgnoreCase, IgnoreAccents: Boolean; StartPos: Integer): Integer;
Same as AnsiLastPosEx but can start comparison to a given position (Length(S) by default).
function AnsiUpperCase(Value: string): string;
Changes all the letters of a string to uppercase. *
function AnsiLowerCase(Value: string): string;
Changes all the letters of a string to lowercase. *
function AnsiUpFirstLetter(Value: string): string;
Changes the first letter of a string to uppercase. Other letters are unchanged. *
function AnsiMixedCase(Value: string; Delimiters: string): string;
Changes all the letters that follow a letter of "Delimiters" to uppercase (first letter is also changed). Other letters of the string are unchanged. *
The delimiter parameter is a string containing characters that must be followed by an uppercase letter, e.g.: ' -' will make "This Is A Sample-Text".
function AnsiBestFitUS(S: string): string;
Fit input string at best to only have us-ascii characters (remove accents, ...).
* Accentuated letters are also converted, using Windows' current locale settings.
function UTF8Encode(Value: string): string;
function UTF8Decode(Value: string): string;
Converts a standard string to UTF8 (unicode) and the other way round. The unicode is not really supported
(using "string" rather than "WideString"), so the function will only keep the characters
that are available in current charset.
Note that the UTF8Decode function does not support some recent 4-byte characters. As a workaround, if you encounter issues with decoding UTF8 texts
(the function returns then an empty string), you can use instead the function UTF8DecodeCorr from StringUtils1.pas, by referencing this unit:
program MyScript;
uses
StringUtils1;
begin
// ...
// calling the function at some point:
value := UTF8DecodeCorr(value);
// ...
Functions to manipulate strings with regular expressions
function RegExprSet(ExprStr: string): Boolean;
Set a regular expression ExprStr.
Return True if expression is well formed, False otherwise.
function RegExprExec(InputStr: string): Boolean;
Find first match in the input string InputStr with regular expression.
Return True if input string match regular expression, False otherwise.
function RegExprSetExec(ExprStr, InputStr: string): Boolean;
Same as combinaison of RegExprSet and RegExprExec functions.
Return True if expression is well formed and input string match regular expression, False otherwise.
function RegExprExecNext: Boolean;
Find next match in the input string with regular expression.
Return True if a match has been found, False otherwise.
function RegExprExecPos(Pos: integer): Boolean;
Find match in the input string starting from specified position Pos with regular expression.
Return True if a match has been found, False otherwise.
function RegExprSubstitute(TemplateStr: string): string;
Returns string TemplateStr with '$&' or '$0' replaced by whole r.e. occurence and '$n' replaced by occurence of subexpression #n.
function RegExprSetSubstitute(ExprStr, InputStr, TemplateStr: string): string;
Same as combinaison of RegExprSet, RegExprExec and RegExprSubstitute functions.
Returns string TemplateStr with '$&' or '$0' replaced by whole r.e. occurence and '$n' replaced by occurence of subexpression #n.
function RegExprReplace(InputStr, ReplaceStr: string; UseSubstitution: boolean): string;
Returns string InputStr with r.e. occurencies replaced by string ReplaceStr.
If UseSubstitution is True, then string ReplaceStr will be used as template for Substitution methods.
function RegExprSetReplace(ExprStr, InputStr, ReplaceStr: string; useSubstitution: boolean): string;
Same as combinaison of RegExprSet and RegExprReplace functions.
Returns string InputStr with r.e. occurencies replaced by string ReplaceStr.
If UseSubstitution is True, then string ReplaceStr will be used as template for Substitution methods.
function SubExprMatchCount: Integer;
Returns the number of subexpressions has been found in last Exec* call.
If there are no subexpr. but whole expr. was found (Exec* returned True), then SubExprMatchCount=0.
If no subexpressions nor whole r.e. found (Exec* returned False) then SubExprMatchCount=-1.
Note, that some subexpr. may be not found and for such subexpr. RegExprMathPos=RegExprMatchLen=-1 and RegExprMatchStr=''.
function RegExprMatch(SubExprIdx: Integer): string;
Returns the string of subexpr. SubExprIdx in last Exec* call.
(= Copy(InputStr, RegExprMatchPos(SubExprIdx), RegExprMatchLen(SubExprIdx)))
First subexpr. has SubExprIdx=1, last has SubExprIdx=SubExprMatchCount, whole r.e. has SubExprIdx=0.
Returns '' if in r.e. there is no such subexpr. or this subexpr. not found in input string.
function RegExprMatchPos(SubExprIdx: Integer): Integer;
Returns the position of subexpr. SubExprIdx in last Exec* call.
First subexpr. has SubExprIdx=1, last has SubExprIdx=SubExprMatchCount, whole r.e. has SubExprIdx=0.
Returns -1 if in r.e. there is no such subexpr. or this subexpr. not found in input string.
function RegExprMatchLen(SubExprIdx: Integer): Integer;
Returns the length of subexpr. SubExprIdx in last Exec* call.
First subexpr. has SubExprIdx=1, last has SubExprIdx=SubExprMatchCount, whole r.e. has SubExprIdx=0.
Returns -1 if in r.e. there is no such subexpr. or this subexpr. not found in input string.
function RegExprModifiers(Modifiers: string): Boolean;
Set default values of r.e. syntax modifiers.
Add modifier 'i','r','s','g','m','x' before '-' to set it to True and after '-' to set it to False.
For exemple string 'g-xi' set modifier 'g' to True and modifiers 'x', 'i' to False.
Note 1: All modifiers are initialized to True by default.
Note 2: You can replace these default values by adding modifiers in r.e. '(?irsgmx-irsgmx) ...'
procedure RegExprDebug(Debug: Boolean);
If Debug = True (False by default), then a message will be shown when an error occurs.
For more details on regular expressions syntax, see help on website regexpstudio.com
Functions to manipulate files and folders
function GetCurrentDir: string;
Returns the current directory (directory of catalog by default).
function SetCurrentDir(DirName: string): boolean;
Returns True if the given directory has been set as current directory.
function ExpandFileName(FileName: string): string;
Returns the absolute path of FileName according to current directory.
function ExtractRelativePath(BaseName: string; DestName: string): string;
Returns the relative path to go from BaseName to DestName. If DestName is on another drive then the whole DestName is returned.
function FileExists(FileName: string): Boolean;
Returns True if the given file name exists.
function ExtractFileName(AFileName: string): string;
Returns what follows the last "\" of the name.
function ExtractFileExt(AFileName: string): string;
Returns the last "." and what follows it.
function ExtractFilePath(AFileName: string): string;
Returns up to the last "\" of the name (included).
function ChangeFileExt(AFileName: string; AExt: string): string;
Returns the name with a new extension. The extension includes the dot so it can also be used to transform "File.abc" to "FileSomething.def" for example.
function IncludeTrailingPathDelimiter(AFileName: string): string;
Returns the path with a "\" added at the end if there wasn't one yet.
function ExcludeTrailingPathDelimiter(AFileName: string): string;
Returns the path removing the "\" at the end if there was one.
function DeleteFile(AFileName: string): Boolean;
Deletes the specified file.
function CopyFile(ASourceFileName: string; ATargetFileName: string; SkipIfExists: Boolean): Boolean;
Copy a file to a target file name. If last parameter is True it does not overwrite the target file if it already exists.
The function returns True if the file was copied.
function MoveFile(ASourceFileName: string; ATargetFileName: string): Boolean;
Moves/renames a file to a target file name.
The function returns True if the file was well changed.
This function can also be used to move or rename a folder.
function GetFileSize(AFileName: string): Double;
Returns the file size in bytes if exists, -1 otherwise.
function DirectoryExists(DirName: string): Boolean;
Returns True if the given folder name exists.
function DirectoryIsEmpty(DirName: string): Boolean;
Returns True if the folder is empty.
function ListDirectory(ADir: string; AMask: string): string;
Returns the folder contents, with tab-separated colunns (name, size, datetime, "D" if directory). Lines are separated by linebreaks so it can be put
in the ".Text" property of a TStringList.
function CreateFolder(DirName: string): Boolean;
Returns True if the folder has been created successfully.
function DeleteFolder(DirName: string; OnlyIfEmpty: Boolean): Boolean;
If last parameter is True, it delete the folder only if it is empty.
The function return True if the folder has been deleted successfully.
function CopyFolder(ASourceDir: string; ATargetDir: string): Boolean;
Returns True if the folder has been copied successfully.
TStringList class
TStringList is a class that can be used to manage a list of strings. It can be useful to manage the webpages, sinces it allows to easily manage the lines separately.
Declaration: aList: TStringList;
Creation: aList := TStringList.Create;
Destruction: aList.Free;
The following methods and properties are available:
procedure LoadFromFile(FileName: string); loads a text file into the list
procedure SaveToFile(FileName: string); saves the contents to a text file
function Add(Line: string): Integer; adds a line
procedure AddStrings(Strings: TStringList); adds all lines from another TStringList
procedure Insert(LineNr: Integer; Line: string); inserts a line
procedure Move(CurLineNr, NewLineNr: Integer); moves a line to a new position
procedure Exchange(LineNr1, LineNr2: Integer); exchanges two lines
procedure Delete(LineNr: Integer); deletes a line
procedure Clear; clears all lines
function IndexOf(Line: string): Integer; position of a line
function GetString(LineNr: Integer): string; retrieves a line
procedure SetString(LineNr: Integer; Line: string); sets a line
procedure Sort; sort the whole list
function IndexOfName(Name: string): Integer; position of the line associated to the name (name=value)
function GetValue(Name: string): string; retrieves the value of the line associated to the name (name=value)
procedure SetValue(Name: string; Value: string); sets the value of the line associated to the name (name=value)
function GetName(LineNr: Integer): string; retrieves the name of a line (name=value)
property Count: string returns the number of lines of the list
property Sorted: boolean; defines if the whole list is a sorted list
property CaseSensitive: boolean; defines if the sort is case sensitive
property Text: string; property allowing to get or set the whole list as just a simple string (used with function GetPage for example)
property CommaText: string; property allowing to get or set the whole list as just a simple string delimited by commas and quotes
(e.g. line1,line2,"line 3","line 4","line5 A, B","line 6 ""A""")
property DelimitedText: string; property allowing to get or set the whole list as just a simple string delimited by delimiters and quotes
(, and " by default) (e.g. line1,line2,"line 3","line 4","line5 A, B","line 6 ""A""")
property Delimiter: Char; defines the delimiter used by DelimitedText (, by default)
property QuoteChar: Char; defines the quote char used by DelimitedText (" by default)
TStringListEx class
Same as TStringList with additional methods and properties.
Declaration: aList: TStringListEx;
Creation: aList := TStringListEx.Create;
Destruction: aList.Free;
The following methods and properties are available:
procedure NaturalSort; sort the whole list with a natural sort (detects numbers automatically)
property DelimitedCSVText: string; same as DelimitedText but allows strings with spaces without quotes
(e.g. line1,line2,line 3,line 4,"line5 A, B","line 6 ""A""")
property DelimitedAMCText: string; same as DelimitedCSVText but does not use quotes, pass over delimiters between parentheses, trim strings and add a space after each delimiter
(e.g. line1, line2, line 3, line 4, line5 A B, line 6 "A", line 7 (text7 A), line 8 (text8 A, B), line 9 (text9 A, B (C, D)))
This property should help to format/sort easier fields with multiple values such as actors, category, ...
TJvSimpleXml and linked classes
This is a quite complete XML parser, allowing to handle XML documents easily. Not all its functionnalities are accessible through scripts, so the following list may be completed later when some features are added to the script engine.
The creation of the object is similar to the TStringList presented above.
It has the following methods and properties:
procedure LoadFromString(Value: string); loads an XML document from a string
procedure LoadFromFile(FileName: string); loads an XML document from a file
procedure SaveToString: string; stores the current XML document in a string
procedure SaveToFile(FileName: string); stores the current XML document in a file
property Root: TJvSimpleXmlElemClassic; items corresponding to the "root" node of the XML document
The various nodes of the document are TJvSimpleXmlElemClassic, based on TJvSimpleXmlElem.
The latter has the following methods and properties:
property Name: string; node name: <name>
property Value: string; node value: <name>value</name>
property Items: TJvSimpleXmlElems; liste des sous-éléments du nœud
property Properties: TJvSimpleXmlProps; list of the properties (attributes) of the node: <name attr1="val1" attr2="val2">
property Parent: TJvSimpleXmlElem parent node
function GetChildIndex(AChild: TJvSimpleXmlElem): Integer; position in the list (Items) of the specified "child" node
procedure Clear; deletes all the items and properties of the node
The class TJvSimpleXmlElems has the following methods and properties:
property Count: Integer returns the number of items in the list
function GetItem(Index: Integer): TJvSimpleXmlElem; gives access to an item of the list by specifying its position
function GetItemNamed(Name: string): TJvSimpleXmlElem; gives access to an item of the list by specifying its name
procedure Clear; deletes all the items of the list
procedure Delete(Index: Integer); deletes the item at specified position
procedure DeleteNamed(Name: string); deletes the item that has the specified name
function Add(Name: string): TJvSimpleXmlElemClassic; creates and adds an item to the list
The attributes of each node are TJvSimpleXmlProp, that have the following properties:
property Name: string; name of the attribute
property Value: string; value of the attribute
These are stored and managed by the class TJvSimpleXmlProps, that has the following methods and properties:
property Count: Integer; returns the number of properties in the list
function GetItem(Index: Integer): TJvSimpleXmlProp; gives access to a property of the list by specifying its position
function GetItemNamed(Name: string): TJvSimpleXmlProp; gives access to a property of the list by specifying its name
procedure Clear; deletes all the properties of the list
procedure Delete(Index: Integer); deletes the property at specified position
procedure DeleteNamed(Name: string); deletes the property that has the specified name
function Add(Name: string; Value: string): TJvSimpleXmlProp; creates and adds a property to the list
Scripts properties
The title, the description and all other attributes/parameters of the scripts can be defined through this
window. It is accessible by the
"Properties" icon
of the script editor.
The title of the script should be quite short; it is usually the name of the site from which the information are imported. The "Get info from web" field indicates if the script can be used to get information from Internet. The "Requires movies" field indicates if the script requires one or more movies of catalog to work. If the script don't need movies, then no selection of movies will be asked before execution and no movie will be given to the script. Only the scripts that have this two last fields set to "True" are visible when the script window is called through "Get information" -> "From Internet using a script". When the window is called through "Scripting" menu, all scripts are displayed.
For each option that you define, you have to define its available values (positive integer numbers, associated to a description).
Debug tools
The toolbar visible in the script editor has commands similar to those available in Delphi: