How to add new websites to Movienizer?
Movienizer uses Pascal scripts to fetch information from the internet. The available scripts are stored in %APPDATA%\Movienizer\Scripts\ and are named *_movie.pas (information about movies) or *_person.pas (information about people), where '*' should be replaced with the name of the site.
Using the existing scripts as an example and taking into account the following information, you can create new scripts.
Download Information About Movies
Script functions called from the main program.
- function GetMovieNameByUPC(barcode: string): string; //Get the name of the movie by its UPC Barcode. Returns the title.
- function GetSearchURLbyName(MovieName: string): string; //Generate a search URL to search for the requested title. Returns the search URL.
- function DownloadSearchURL(url: string): integer; //Load the HTML page with search results. Returns number of search results if download successful, or -1 otherwise.
- function GetMovieURL(code: string; images_only: boolean): string; //Generate URL of the page that contains information about the movie by movie's code in the website's format. Returns the URL.
- function SaveFrontCover(url, Filename: string): boolean; //Save picture from its URL to the given file. Returns true if successful, else false.
- procedure GetImages; //Loading images.
- function GetInfo(url: string; images_only: boolean): string; //Get information about the movie by its URL. If 'images_only' is true, only images will be loaded. Returns "-1" if couldn't get info and the downloaded page otherwise.
- function GetMovieSiteURL(code: string): string; //Generate URL of the movie page in the format of the website. Returns the URL.
- function GetPersonSiteURL(code: string): string; //Generate URL of the page for the person in the format of the website. Returns the URL.
Custom functions can also be defined, if needed.
How much information to download/ to extract?
Movienizer features "Download options" available in the "Options" menu (F10). On the page the user can set up what should be downloaded. This allows saving time by reducing number of pages to download, if the user doesn't need this information.
The following variables should be used in scripts to provide the functionality:
- DownloadMovieBigCover: boolean - if true, download big cover images. If false, download only small images.
- DownloadMovieFullCast: boolean - if true, download all available cast and crew information. If false, download only the cast and crew information available on the main page of the movie (don't download any additional page). Sometimes there is no additional cast/crew page, in such cases the variable is not used.
- DownloadMovieBigDescription: boolean - if true, download the full description. If false, get only the description from the main page (don't download any additional pages). Sometimes the main page contains the complete description, in such cases there is no use for this variable.
- DownloadMovieComments: boolean - if true, download user comments about the movie from the site. If false, don't download or extract comments.
- DownloadMovieStudios: boolean - if true, download information about studios. If false, don't download or extract information about studios.
- DownloadMovieAwards: boolean - if true, download/extract information about awards. If false, don't do this.
- DownloadMovieEarnings: boolean - if true, download gross information. If false, don't download this information.
- DownloadMovieAdditionalInfo: boolean - if true, download any other information worth of attention (for example, fun stuff etc.). If false, don't download or extract additional information.
- DownloadMovieSeasonsList: boolean - if true, download seasons for TV series. If false, don't download such information.
- DownloadMovieTechnicalInfo: boolean - if true, download technical information about DVD (features, audio tracks etc.)
- MaxShotsCount: integer - maximum number of shots to download from the site. If an additional page should be downloaded to start extracting shots, the script must check if MaxShotsCount > 0. If MaxShotsCount = 0, no page should be downloaded.
- MaxPicturesCount: integer - deprecated, replaced by MaxShotsCount.
Transferring the fetched data to the main program.
- procedure SetGenre(name: string); //Set genre of the movie.
- procedure SetCountry(name: string); //Set country that produced the movie.
- procedure SetPersonName(name, character: string; mode: integer; code:
string); //Set people that participated in the movie.
name - name of the person
character - character in the movie played by the person
mode - 1=director, 2=writer, 3=actor/actress, 4=composer - procedure SetSearchResult(name, code:
string); //Set
search results.
name - of what has been found
code - code in the format of the website - procedure SetMovieName(name, character:
string; mode: integer; code, year: string); //Set
movies where the given person participated.
name - name of the person
character - character in the movie played by the person
mode - 1=director, 2=writer, 3=actor/actress, 4=composer
code - code of the person in the website's format
year - year the movie was published - procedure SetImageName(path, url,
description: string; mode: integer); //Set list of
images.
path - filename
url - URL of the image
description - description of the image
mode - type of the image:
1=Front cover
2=Back cover
3=Shot from the movie
4=Poster
5=User image
6=Photo - procedure SaveLoginInfo(UserName, UserPassword, ScriptName: string); //Save user related information required to enter and search the website.
- procedure SetEpisode(season, episode, EpisodeTitle, EpisodeDescription, EpisodeIMDB, AirDate); //Save information about the current episode.
- procedure SetStudio(name: string); //Save the extracted studio (movie production). Name is the name of the studio.
- procedure SetSubtitle(name: string); //Save the extracted information about the current subtitle track (DVD info). Call as many times as necessary to include all available subtitles.
- procedure SetAudioTrack(name: string); //Save the extracted information about the current audio track (DVD info). Call as many times as necessary to include all available audio tracks.
The function GetInfo sets the following global variables used by the program later (all are STRING values, if not stated otherwise):
- title - title of the movie.
- original_title - original title of the movie (if translated)
- year - the year of publishing.
- country - the country that produced.
- description - description of the movie.
- duration - in minutes.
- imdb_code - IMDB code of the movie.
- movie_code - code of the movie in the format of the website.
- movie_site_url - URL of movie's website
- imdb_rating - IMDB rating of the movie
- script_name - name of the script
- mpaa - MPAA rating (G, PG etc.)
- mpaa_rating - MPAA rating (reason for being rated so)
- rating - site rating
- awards - awards received by the movie (like Oscar, Golden Globe etc.), plain text.
- salary - gross of the movie
- resolution - screen resolution of the movie
- barcode - barcode of the media (DVD, Blu Ray etc.)
- aspect_ratio - aspect ratio of the picture
- features - DVD features
- media_format - format of the media (DVD, Blu Ray etc.)
- video_codec - video codec
- duration_min (integer) - duration of the movie in minutes
Functions of the main program called from scripts.
- var DecimalSeparator: char; //Decimal symbol
- var ResponseCode: integer; //Response code from the server
- var UserName: string; //Username for logging in
- var UserPassword: string; //User password for logging in
- function ParseString(all, s: string; nom: integer): string; //Parse a string using regular expressions. Returns the parsed result (string).
- function RemoveEndLines(all: string): string; //Remove end of line symbols using regular expressions. Not recommended.
- function RemoveTags(all: string): string; //Convert HTML to plain-text. Returns the text without HTML tags.
- function DecodeHTML(all: string): string; //Convert HTML-codes of symbols into plain text symbols. Returns the text with HTML-codes replaced by normal characters.
- function DownloadURL(URL: string): string; //Download page from the URL and return it as a string. If not successful, returns -1. Server's response can be seeing with GetResponseCode. The result should be saved in the global variable 'all'. Returns the downloaded page.
- function DownloadURLWithReferer(url, referer: string): string; //Download URL using HTTP_REFERER. If referer=post, POST-method will be used for GET-inquiries. Returns the downloaded page.
- function ReplaceStr(s, s1, s2: string; ind: integer): string; //Searches s for s1-occurancies and replaces them with s2. For example, url:=ReplaceStr(url, ' ', '+') will replace all spaces with pluses in url. Returns the string with replaced substrings.
- function MyPos(substr, s: string; ind: integer): integer; //Searches for substr in s starting from the position ind. Returns the position in the text.
- function ClearExtraSpaces(s: string): string; //Remove extra spaces at the beginning/end. Removes the string without extra spaces.
- function ClearExtraCharacters(s: string): string: //Remove beginning/end codes <32 . Returns the string without blank characters.
- function ConvertUTF8toASCII(s: string): string; //Converts the provided UTF8-string into ANSI-string for western European languages. Returns the converted string.
- function GetResponseCode: integer; //Gets the response code from the server.
- function ClearExtraXCharacters(s: string): string; //Removal of leading and trailing 'enters', tabs and spaces.
Variables that can be used from scripts:
- ScriptsPath (string) - path to the script directory of Movienizer on the local machine (i.e. the folder where all scripts are stored).
Downloading data.
To download information about a movie, the program should:
- Find the movie.
- Download necessary information.
1. Finding the movie.
If UPC Barcode is provided, we search for the title with the help of GetMovieNameByUPC. If the title is known, we generate URL for searching using GetSearchURLbyName. Then DownloadSearchURL is called to get a list of movies with similar titles. In this function, the script should create a list using SetSearchResult.
2. Loading information about the movie.
For downloading information, GetInfo function is called. It should parse HTML code and set all necessary variables, like title, year, genres, actors, directors etc., images should be downloaded.
Download Information About People
Script functions called from the main program.
- function GetSearchURLbyName(PersonName: string): string; //Generate a search URL to search for the requested name. Returns the search URL.
- function DownloadSearchURL(url: string): integer; //Load the HTML page with search results. Returns the number of search results if download successful, or -1 otherwise.
- function GetPersonURL(code: string; images_only: boolean): string; //Generate URL of the person's page in the format of the website. Returns the URL.
- procedure GetImages; //Loading images.
- function SavePhoto(url, FileName: string): boolean; //Save picture from its URL to the given file. Returns true if successful, else false.
- function GetInfo(url: string; images_only: boolean): string; //Get information about the person by its URL. If 'images_only' is true, only images will be loaded. Returns "-1" if couldn't get info and the downloaded page otherwise.
- function GetMovieSiteURL(code: string): string; //Generate URL of the movie page in the format of the website. Returns the URL.
- function GetPersonSiteURL(code: string): string; //Generate URL of the page for the person in the format of the website. Returns the URL.
The function GetInfo sets the following variables:
- person (string) - name of the person
- person_code (string) - code of the person in the website's format
- imdb_code (string) - code of the person on imdb
- person_site_url (string) - URL of the person's page on the site
- original_name (string) - original name of the person
- biography (string) - biography of the person
- birth_date (string) - birth date of the person
- birthplace (string) - place of birth
- death_date (string) - death date of the person, empty if non-applicable
- height (string) - height of the person
- salary (string) - information about salaries
- description (string) - additional description
Custom functions can also be defined, if needed.
How much information to download/ to extract?
Movienizer features "Download options" available in the "Options" menu (F10). On the page the user can set up what should be downloaded. This allows saving time by reducing number of pages to download, if the user doesn't need this information.
Transferring the fetched data to the main program.
- procedure SetSearchResult(name, code:
string); //Transfer the parsed search result into the
program
name - name (and additional information) of the person
code - code of the person in the site's format - procedure SetImageName(path, url,
description: string; mode: integer); //Transfer
information about the current image
path - filename
url - URL of the image
description - description of the image
mode - type of the image:
1=Front cover
2=Back cover
3=Shot from the movie
4=Poster
5=User image
6=Photo - procedure SetMovieName(name, character:
string; mode: integer; code, year: string); //Transfer
information about the current movie from the filmography
name - title of the movie
character - character in the movie played by the person
mode - 1=director, 2=writer, 3=actor/actress, 4=composer
code - code of the movie in the website's format
year - year the movie was published
The following variables should be used in scripts to provide the functionality:
- DownloadPersonBiography: boolean - if true, download or extract biography of the person. If false, don't do it.
- DownloadPersonAdditionalInfo: boolean - if true, download or extract any interesting additional information. If false, don't download or extract any additional information.
- MaxPhotosCount: integer - number of photos to download. If an additional page has to be loaded to extract URLs of photos, the script must check if MaxPhotosCount > 0. If it is 0, no page has to be downloaded.
Functions of the main program called from scripts.
Please refer to the section about scripts for movies (above).
Downloading data.
To download information about a person, the program should:
- Find the person on the corresponding site.
- Download and extract necessary information.
1. Finding the movie.
We generate a URL for searching by calling GetSearchURLbyName with the name of the person provided by the user. Then DownloadSearchURL is called to get a list of persons with similar names. In this function, the script should create a list using SetSearchResult.
2. Loading information about the person.
For downloading and extracting information, GetInfo function is called. It should parse the HTML code and set all necessary variables, like person (name), birth_date, birthplace, biography, filmography etc., photos should be downloaded.
If you wish to share your script, please contact us. We will include it into the main package, and other people will be able to enjoy the new functionality. If you have any questions, please feel free to contact support any time.