PROGRAMMER'S GUIDE

MagicScript Technology

Programmer's Guide

    (C) 2001-2003 BinaryWorks.it
   
Web : http://www.binaryworks.it/
    E-Mail : alessioviti@binaryworks.it
    Documentation Version [2.0]


Contents

Disclaimer

The author is in no way responsible for any damage, loss or costs that the installation or use of this program (or attempted installation or use) may cause you or your equipment. Installation and use of this program is entirely at your own risk. This program comes with no guarantees and is provided on an 'as is' basis. The author makes no guarantees on its soundness, reliability or suitability for any given purpose.

This program is Freeware. You may distribute this program freely but you must request permission and include the full unmodified setup package including all program files and documentation. If you wish to distribute this program commercially, you must request permission from the author.

What Is

MagicScript Technology is the new way to import information of your favourites movies from the web . In its past version, eXtreme Movie Manager allowed you to import Info from two important web-sites only: imdb.com & dvdempire.com.
With This new version, you can in theory import information from all the web-sites you want!

Top

How To Use

MagicScript is a mini programmer-language that will allow you to make oriented-code to obtain information from a HTML page.
For this purpose, you can use the IF , REPEAT-WHILE statements and many others. Of course, this language isn't as powerful as other complete languages like Basic etc.. but it is sufficient for eXtreme Movie Manager Goals.

The Script won't be simple to build if you don't know any other prog-languages.In this case you can use the Ready-Scripts available on my web page.

Script Structure

The Script is a normal TXT File composed with INSTRUCTIONS, BLOCKS and STATEMENTS that you can edit with any editor.

Every Script File is associated with one Movie-Site, so there will be a file Script for imdb, another one for dvdempire etc...

The structure of the text is free, this means that you can add notes and comments where you want, because all key-words are written inside sharp like this : #IF#

The basic structure that must be present in every Script is formed by the keyword #WEBQUERY# and the Block #RIGHPAGEFOUND#, we will see better their functions

A Script consists in a series of BLOCKS: Functions & Instruction inside Blocks are executed sequentially until the end of every BLOCK is reached.

When you want to import information, MagicScript opens the Script of Web-Page you want and proceeds to gathering infomation in the way that is written on the Script. Of course, a script written for imdb.com will not work in the dvdempire.com site, and probably you will have an unpredictable end of program.

As I have said, what must be on the Script is the Keyword #WEBQUERY# to question the DB of a movie-website. The BLOCK #RIGHTPAGEFOUND# is vital too, it can check if you have found what you are looking for. All other blocks are not indispensable.
For Example, if the information got from imdb.com is satisfactory to you, but you want all the BoxCover inside dvdempire.com, you can write a Fully Script for imdb and a little script for dvdempire with only the BLOCK to take the images : #POSTER#...#ENDPOSTER#
Of course there is another way to do it : you can simply check in eXtreme Movie Manager Import Config the Cover Option and you will take only that.

Why Block Structure? :
For every information imported there is a special Block, this because if user want import only a particular thing, he can uncheck all the others directly inside the software, without modify the script. For example, for take the TITLE of a movie, you should write all instructions inside this Block:

#MOVIETITLE#
    ......
    ......
    #TITLE#=#03# #ONERROR#=*ASK*
#ENDMOVIETITLE#

Of couser, you can also use only one Block ( #MOVIETITLE# in that case) to write ALL instructions for gathering all information, but your script will be less configurable by users.

 
Top


First & Second Script Generation

From eXtreme Movie Manager 1.0 engine can handle two different types of Scripts : the OLD, know also as First Generation, and the Latest, or Second Generation. The instructions and Function are the same for both ( 2 have some new ), but the difference is the HTML.
When engine detect a First Generation, the HTML is "pre-processed", this means that the HTML is rewrited in more line, how it is if you edit with a normal text editor. The Second Generation didn't pre-process the HTML (so the speed is increased), but the HTML in the most cases is in only one line. This means that a script of Second generation cannot work with Divxmanager 0.9, because the HTML are always pre-processed.

Divxmanager 1.0 can work with both 1 and 2 because can "read" the generation with this line :
#SCRIPTGENERATION#=2

The 2 have also another Header's variable : #REPLACESPACES#=
This tells to the engine what characters must be used for replace spaces in the movie title when quering the Web-sites. This is indispensable for web like ALLOCINE.FR (or the movie will not be found).




Functions & Instructions

Here is the list of Function available on MagicScript:

MagicScript Language Function Reference

#WEBQUERY#
#STARTREADWEB#
#FINDLINE#
#FIND#
#TAKEWORD#
#TAKEWORDLEN#
#READNEXTLINE#
#STRING#
#PUT#
#SETCURSOR#
#COMPUTECURSOR#
#PUTCURSOR#
#COMPUTEVAR#
#LOADCURSOR#
#IF#-#ENDIF#
#REPEAT#-#WHILE#
#RESETCURSOR#
#STARTDELETETAGS#
#STARTSUBSTITUTETAGS#
#GOTO#
#OPENNEWWEB#-#RESTOREWEB#
#SHOWVAR#
#CHECKVARIABLE#
#STRING#
#GETTITLE#
#CLEARTAGS#
#CONDITIONRIGHTPAGE#
#WRITETITLELIST#
#
#WRITETITLELISTACTORS#
#

 

 

 

 

 

 





 




















Special Function Reference

#TITLE#
#TAKEDIRECTOR#
#TAKEACTOR#
#TAKEGENRE#
#TAKERATING#
#TAKECOMMENTS#
#TAKEPLOT#
#TAKERUNTIME#
#TAKEYEAR#
#TAKEPOSTER#
#TAKECOUNTRY#
#TAKELANGUAGE#
#TAKETAGLINE#
#TAKEMOVIEID#
#TAKEPRODUCER#
#TAKEWRITER#
#TAKEREGION#
#TAKEEDITION#
#TAKESCREENDVD#
#TAKEAUDIODVD#
#TAKEPHOTOGRAPHER#
#TAKESTUDIO#
#TAKEMPAA#
#TAKEMUSIC#
#TAKEDISTRIBUTOR#
#TAKEOFFICIALWEB#
#TAKEACTORNAME#
#TAKEACTORBDATE#
#TAKEACTORBPLACE#
#TAKEACTORSEX#
#TAKEACTORCOUNTRY#
#TAKEACTORFILM#
#TAKEPICTURE#
#TAKECUSTOM10#
#TAKECUSTOM11#
#TAKEFILE#
#TAKESUBGENRE#
#TAKEUPC#
#TAKEACTORWEB#
#TAKEACTORBIO#
#TAKESEASON#
#ADDACTOR#
#

 

 

 

 

 

 






 

 

 

 

 

 

 

 

 

 

 

 



 

 

 

 

 

 

 



The #WEBQUERY# Instruction

Contains the query for question the Movie's Website.

Syntax:

#WEBQUERY#=text#MOVIE#text

Parameters:

text Required. The text of the proper query for access a web-site.
#MOVIE# Optional. Is the CONSTANT that contain the Title of the movie you are looking for.

Examples:

1.	#WEBQUERY#=http://imdb.com/Tsearch?title=#MOVIE#&restrict=Movies+only

The Engine will replace the Variable #MOVIE# with the title of it, so it can make the query to the web.

Remarks:

You can put this instruction where you want in the Script, but only ONCE (if there are more of this instruction, Engine will take the first)
Note that if you didn't write the CONSTANT #MOVIE#, you will probably find nothing from web.

Script Function Reference | Top


The #STARTREADWEB# Instruction

Reset the Read Engine to the first line of HTML and set the CURSOR Variable to 1.

Syntax:

#STARTREADWEB#

Parameters:

No Parameter  
This Instruction Tell to engine that you want start your search to the top of the HTML file. 

Remarks:

It's recommended that you put this instruction in all Blocks for re-initializing the Engine. If you read the title of a movie that is at the bottom of the HTML file, and then read the Director that is at the top,you will not find Director's info if you didn't re-initialize the engine with this instruction .

Script Function Reference | Top


The #FINDLINE# Function

Search for a string in all HTML page.

Syntax:

#FINDLINE#=text#??##ONERROR#=*options*

Parameters:

text Required. The text to find in the HTML.
#??# Required. The number of Variable where Function store the result of the Search.
               If the text is found, the variable will contain value 1 , if no text is found, value 0
#ONERROR#=*options* Optional. In the options you can specify what Engine must do in case of ERROR of the Function :
              STOP -> Will terminate the BLOCK where is the Function.
              ASK   -> Will show you the message of error and the script-line where is located
              OK     -> Will ignore the error and go on with executing the others functions 

Examples:

1.	#FINDLINE#=<title>#12##ONERROR#=*STOP*
2.	#FINDLINE#=<title> #01##ONERROR#=*ASK*

Note that these two functions search for different strings! the first search "<title>", Second the String "<title> " .Be careful!

This Instruction is useful when you want to  search for a particular string in the whole HTML , but you don't know where it is. It is different from the #FIND# 
function that searches for a string only in the CURRENT Line of HTML. To know the the position in the string where is text you are looking for begin,
you can use the CURSOR Variable.

Remarks:

This function writes on the main variable CURSOR the position where the string you are searching starts. Remember that all others functions start to
search text from the position of the CURSOR variable!.



Script Function Reference | Top


The #FIND# Function

Search for a string only in the CURRENT LINE of HTML page.

Syntax:

#FIND#=text#??##ONERROR#=*options*

Parameters:

text Required. The text to find in the HTML.
#??# Required. The number of Variable where Function store the result of the Search.
               If the text is found, the variable will contain his position , if no text is found, value 0
#ONERROR#=*options* Optional. In the options you can specify what Engine must do in case of ERROR of the Function :
              STOP -> Will terminate the BLOCK where is the Function.
              ASK   -> Will show you the message of error and the script-line where is located
              OK     -> Will ignore the error and go on with executing the others functions 

Examples:

1.	#FIND#=<title>#12##ONERROR#=*ASK*
2.	#FIND#=<title> #12##ONERROR#=*OK*
Note that these two functions search for different strings! the first searches "<title>",  the Second the String "<title> " .Be careful! 
This Instruction is similar to the #FINDLINE#, but searches for the text only in the current line of HTML.

Remarks:

This function writes also on the main variable CURSOR the position where the string you search starts. remember that all other functions start to
search text from the position of the CURSOR variable.


Script Function Reference | Top


The #TAKEWORD# Function

Takes a string from the current line;

Syntax:

#TAKEWORDLEN#=#?1#,#?2#,#?3#

Parameters:

#?1# Required. The Variable where is the Text Extracted.
#?2# Required. The Variable of starting point of the Text to extract.
#?3# Required. The Variable of ending point of the Text to extract. If you set this = "0", you will take all the line!

Examples:

1.	#TAKEWORD#=#03#,#01#,#02#
This Example takes a string from CURRENT LINE, starting from the position stored on variable #01# through #02# , and puts the text in the #03# Variable. 

Remarks:

This function is fundamental for working with strings, it doesn't modify the CURSOR Variable.

Script Function Reference | Top


The #TAKEWORDLEN# Function

Takes a string from the current line;

Syntax:

#TAKEWORDLEN#=#?1#,#?2#,#?3#

Parameters:

#?1# Required. The Variable where is the Text Extracted.
#?2# Required. The Variable of starting point of the Text to extract.
#?3# Required. The length of the string to extract.

Examples:

1.	#TAKEWORD#=#03#,#01#,#02#
This Example take a string LONG #02# from CURRENT LINE, starting at position stored on variable #01#, and puts the text in the #03# Variable. 

Remarks:

This function is fundamental for working with strings, it doesn't modify the CURSOR Variable.

Script Function Reference | Top


The #READNEXTLINE# Instruction

Read the next line of HTML and set the CURSOR Variable to 1;

Syntax:

#READNEXTLINE#

Parameters:

No Parameter

Remarks:

This instruction is useful when you have found a particular thing with #FINDLINE# instruction and you want analyze the text line by line.

Script Function Reference | Top


The #STRING# Function

Puts a string into a variable , the string can contain text and variables.

Syntax:

#STRING#=#?1#=[Text1][#?2#]{Text#??#}

Parameters:

#?1# Required. The Variable where put the string.
Text1, Text ... Optional. The Text you want put in the string.
#??# Optional. The Variable you want put in the string at the particular position.

Examples:

1.      #PUT#=www.emuitalia.com/#01#
        #PUT#=aletsg/#02#
	#STRING#=#04#=http:/#01##02#divxmanager/
This Example put in the Variable #04# the text "http://www.movieplayer.it/divxmanager/" that is formed of various text and variables . 

Remarks:

With this function you can build your strings before sending it to the Engine.

Script Function Reference | Top


The #PUT# Function

Puts a text or a number into a variable.

Syntax:

#PUT#=Text#??#

Parameters:

Text Required. The Text (or number) you want put into the variable.
#??# Required. The Variable where put the text.

Examples:

1.	#PUT#=mytext#02#
This Example put in the Variable #02# the text "mytext". 

Remarks:

Remember that your text must be inside "="<-and first->"#" : the function #PUT#=text#02#  is different from #PUT#=text #02# !.

Script Function Reference | Top


The #SETCURSOR# Function

Puts a value in the CURSOR Variable.

Syntax:

#SETCURSOR#=number

Parameters:

number Required. The number you want put into the CURSOR variable.

Examples:

1.	#SETCURSOR#=12
This Example puts in the value 12 in the CURSOR variable. 

Script Function Reference | Top

The #COMPUTECURSOR# Function

Makes a SUM or SUBTRACTION to the CURSOR variable.

Syntax:

#COMPUTECURSOR#=number

Parameters:

Required. Is the operation you want make.
number Required. Is the Value to SUM or SUBTRACT

Examples:

1.	#COMPUTECURSOR#=+2
This Example sum to the value of CURSOR "2". 

Script Function Reference | Top

The #PUTCURSOR# Function

Puts the value of CURSOR into a variable.

Syntax:

#PUTCURSOR#=#??#

Parameters:

#??# Required. The Variable where put the value of CURSOR.

Examples:

1.	#PUTCURSOR#=#01#
This Example puts in the CURSOR into #01# variable. 


Script Function Reference | Top

The #COMPUTEVAR# Function

Puts the value of CURSOR into a variable.

Syntax:

#PUTCURSOR#=#??#

Parameters:

#??# Required. The Variable where put the value of CURSOR.

Examples:

1.	#PUTCURSOR#=#01#
This Example puts in the CURSOR into #01# variable. 


Script Function Reference | Top

The #CONDITIONRIGHTPAGE# Special Function

Specifies if you have found directly the page of a movie.

Syntax:

#CONDITIONRIGHTPAGE# #?1#==#?2#

Parameters:

#?1# Required. The first variable to compare.
#?2# Required. The second variable to compare.
== Required. The Operator. It can assume this value :
              
"==" this means "Equal To"
               "<>" this means "Different to"

Examples:

1.	#CONDITIONRIGHTPAGE# #03#<>#04#

Here the page you found is directly of the movie if value of #03# variable is different from value of #04#.

Remarks:

You can use with this function only Variables, so if you need to compare a variable with a string, first you must #PUT# you string in another variable and then compare.

Script Function Reference | Top


The #WRITETITLELIST# Special Function

Writes the string in the MOVIE LIST FOUND; the string can contain text and variables.

Syntax:

#WRITETITLELIST#=[Text1][#?2#]    --->{Text#??#}

Parameters:

Text1, Text ... Optional. The Text you want write.
#??# Optional. The Variable you want put in the string at the particular position.
"    --->" Required. This String is REQUIRED : Engine use this for separate the URL of a movie from his TITLE!

Examples:

1.      #PUT#=Title=?0133093#06#
        #PUT#=Matrix, The#07#
	#WRITETITLELIST#=http://imdb.com/#06# ---> #07#
This Example write the URL and the TITLE of the "Matrix" Movie. 

Remarks:

You MUST use this function for create the list of all movies found on a page.

Script Function Reference | Top


The #TITLE# Special Function

Takes the TITLE of the movie.

Syntax:

#TITLE#=#??# #ONERROR#=*?*

Parameters:

#??# Required. The Variable where is stored the TITLE of the movie.
#ONERROR#=*options* Optional. In the options you can specify what Engine must do in case of ERROR of the Function :
              STOP -> Will terminate the BLOCK where is the Function.
              ASK   -> Will show you the message of error and the script-line where it is located
              OK     -> Will ignore the error and go on with executing the others functions 

Examples:

1.	#TITLE#=#03# #ONERROR#=*ASK*
This Example Takes the title of the movie that is stored on the #03# variable. 

Script Function Reference | Top

The #TAKEDIRECTOR# Special Function

Takes the Director of the movie.

Syntax:

#TAKEDIRECTOR#=#??#

Parameters:

#??# Required. The Variable where the NAME of the Director is stored.

Examples:

1.	#TAKEDIRECTOR#=#03#
This Example Takes the Name of Director of the movie that is stored on the #03# variable. 

Script Function Reference | Top

The #TAKEACTOR# Special Function

Takes the Name of an Actor.

Syntax:

#TAKEACTOR#=#??#

Parameters:

#??# Required. The Variable where the NAME of the Actor is stored.

Examples:

1.	#TAKEACTOR#=#03#
This Example Takes the Name of Actor that is stored on the #03# variable. You can use this function several time for take all actors.

Script Function Reference | Top

The #TAKEGENRE# Special Function

Takes the Genre of a Movie.

Syntax:

#TAKEGENRE#=#??#

Parameters:

#??# Required. The Variable where the GENRE of the Movie is stored.

Examples:

1.	#TAKEGENRE#=#03#
This Example Takes the Name of Actor that is stored on the #03# variable.

Script Function Reference | Top

The #TAKERATING# Special Function

Takes the Rating of Movie.

Syntax:

#TAKERATING#=#??#

Parameters:

#??# Required. The Variable where RATING of the Movie is stored.

Examples:

1.	#TAKERATING#=#03#
This Example Takes the Rating on the #03# variable.

Script Function Reference | Top

The #TAKECOMMENTS# Special Function

Takes the Comments of Movie.

Syntax:

#TAKECOMMENTS#=#??#

Parameters:

#??# Required. The Variable where the Comment of the Movie is stored.

Examples:

1.	#TAKECOMMENTS#=#03#
This Example Takes a comment on the #03# variable.You can use this several times for take all comment's line.

Script Function Reference | Top

The #TAKEPLOT# Special Function

Takes the Plot of Movie.

Syntax:

#TAKEPLOT#=#??#

Parameters:

#??# Required. The Variable where the Plot of the Movie is stored.

Examples:

1.	#TAKEPLOT#=#03#
This Example Takes a Plot on the #03# variable.You can use this several times for take all plot's line.

Script Function Reference | Top

The #TAKERUNTIME# Special Function

Takes the Runtime of Movie.

Syntax:

#TAKERUNTIME#=#??#

Parameters:

#??# Required. The Variable where Runtime of the Movie is stored.

Examples:

1.	#TAKERUNTIME#=#03#
This Example Takes the RUNTIME on the #03# variable.

Script Function Reference | Top

The #TAKEYEAR# Special Function

Takes the Year of Movie.

Syntax:

#TAKEYEAR#=#??#

Parameters:

#??# Required. The Variable where Year of the Movie is stored.

Examples:

1.	#TAKEYEAR#=#03#
This Example Takes the Year on the #03# variable.

Script Function Reference | Top

The #TAKEPOSTER# (#TAKEPICTURE#) Special Function

Takes the Poster of Movie and stores it for you.

Syntax:

#TAKEPOSTER#=#??#

Parameters:

#??# Required. The Variable where the URL of the Poster is stored.

Examples:

1.	#TAKEPOSTER#=#03#
This Example Takes the Poster at the URL stored on #03# variable.

Remarks:

You must write on the variable #??# the URL of the poster Image, Engine will download and rename it for you.You can use this function several times for download all images you want.

Script Function Reference | Top

The #LOADCURSOR# Special Function

Loads a value in the Cursor Variable.

Syntax:

#LOADCURSOR#=#??#

Parameters:

#??# Required. The Variable where the value is stored.

Examples:

1.	#LOADCURSOR#=#03#

Script Function Reference | Top

The #TAKEXXX# Special Function

Take the XXX Variable.

Syntax:

#TAKEXXX#=#??#

Parameters:

#??# Required. The Variable where the XXX of the Movie is stored.

Examples:

1.	#TAKEXXX#=#03#
This Example Takes the XXX on the #03# variable.

Script Function Reference | Top

The #RESETCURSOR# Special Function

Reset the Cursor variable.

Syntax:

#RESETCURSOR#

Parameters:

Examples:

1.	#RESETCURSOR#


Script Function Reference | Top

The #GETTITLE# Special Function

Put the title of the movie inn a variable, useful if you need the movie's title in the script.

Syntax:

#GETTITLE#=#??#

Parameters:

#??# Required. The Variable where the title movie must be loaded.

Examples:

1.	#GETTITLE#=#03#

Script Function Reference | Top

The #CLEARTAGS# Special Function

Clear all tags inside a variable.

Syntax:

#CLEARTAGS#=#??#

Parameters:

#??# Required. The Variable that must be cleared

Script Function Reference | Top

The #TAKEFILE# Special Function

Download a file from web and save it in the "Download" subfolder of XMM. Useful for Subtitles for example.

Syntax:

#TAKEFILE#=#??#

Parameters:

#??# Required. The Variable that contain the URL of the file

Script Function Reference | Top





Constant & Variables

In the MagicScript you can use VARIABLES & CONSTANT, some of them are fundamental for right import information. Let's see :

Variables

You have 50 VARIABLES at your disposal. You can use the variables in the script with this format #??#.
All Variables can contain strings & numbers, the Engine will automatically handle them in the right way. It's important that you write it correctly; for example if you want to use the variable 1, you Must write #01#!
Some FUNCTIONS write values directly into Variables. You must specify to every FUNCTION the number of the Variable where to put the result.
YOU CAN'T use any other name for a Variable : if you accidentally write a wrong format probably the function will have an unpredictable end.
NOTE : You can use the same variables for every Block ! Isn't important that you use every time different Variables, this is the reason because the number of 50 it's enough!

"Cursor" Variable

This is probably the most important variable in the Engine.
With this variable you can know/specify the position in a string where to start most FUNCTIONS, and you can do operations of SUM and SUBTRACTION that isn't possible to do with others VARIABLE. It works like a "Register".
Of course, you can also ASSIGN a particular VALUE to it.
Go to FUNCTIONS & INSTRUCTIONS to learn more.

top

Blocks

The Script consist of a series of BLOCKS, every one can import or make a particular thing. For example, the Block :

#MOVIETITLE#
    ......
    ......
    #TITLE#=#03# #ONERROR#=*ASK*
#ENDMOVIETITLE#


take the Title of the movie stored on the #03# VARIABLE.
There are 2 family of Blocks :

1- IMPORT BLOCKS for import movie information
2- GENERAL BLOCKS for make other various things.

Every Block has a "Begin" and an "End", as you can see, the end is set by KEYWORD with an END.
The Functions & Instruction inside the Blocks are executed sequentially until END-KEYWORD of the BLOCK is reached.

You can't Put a BLOCK Inside another. The result of this action may be unpredictable.

This is a List of Blocks Available at this time, more will come in future :


Import Blocks

BEGIN END SPECIAL FUNCTION DESCRIPTION
#MOVIETITLE# #ENDMOVIETITLE# #TITLE# Imports the TITLE of the Movie. Write the Code to find it and then use the special #TITLE# Function to pass it to eXtreme Movie Manager.
#DIRECTOR# #ENDDIRECTOR# #TAKEDIRECTOR# Imports the NAME of the Director of the Movie. Write the Code to find it and then use the special #TAKEDIRECTOR# Function to pass it to eXtreme Movie Manager.
#ACTORS# #ENDACTORS# #TAKEACTOR# Imports the ACTORS of a Movie. Write the Code to find ALL Actors and every time you find one, use the Special Function to ADD it to eXtreme Movie Manager.
#SUBGENRE# #ENDSUBGENRE# #TAKESUBGENRE# Imports the SUBGENRE of a Movie. Write the Code to find it and then use the special  Function to pass it to eXtreme Movie Manager.
#GENRE# #ENDGENRE# #TAKEGENRE# Imports the GENRE of a Movie. Write the Code to find it and then use the special  Function to pass it to eXtreme Movie Manager.
#RATING# #ENDRATING# #TAKERATING# Imports the RATING of a Movie. Write the Code to find it and then use the special Function to pass it to eXtreme Movie Manager.
#COMMENTS# #ENDCOMMENTS# #TAKECOMMENTS# Imports the COMMENTS to a Movie. Write the Code to find ALL Comments Linet and use the special Function to add it one by one to eXtreme Movie Manager.
#PLOT# #ENDPLOT# #TAKEPLOT# Imports the PLOT of a Movie. Write the Code to find ALL Comments Linet and use the special Function to add it one by one to eXtreme Movie Manager.
#RUNTIME# #ENDRUNTIME# #TAKERUNTIME# Imports the RUNTIME of a Movie. Write the Code to find it and then use the special Function to pass it to eXtreme Movie Manager.
#YEAR# #ENDENDYEAR# #TAKEYEAR# Imports the YEAR of a Movie. Write the Code to find it and then use the special Function to pass it to eXtreme Movie Manager.
#POSTER# #ENDPOSTER# #TAKEPOSTER# Imports POSTER,COVERS And ALL IMAGES you want, simply write the Code to find the "URL" of the POSTER and pass it at the Special Function that will convert and archive it for you!
#COUNTRY# #ENDCOUNTRY# #TAKECOUNTRY#  
#LANGUAGE# #ENDLANGUAGE# #TAKELANGUAGE#  
#TAGLINE# #ENDTAGLINE# #TAKETAGLINE#  
#MOVIEID# #ENDMOVIEID# #TAKEMOVIEID#  
#PRODUCER# #ENDPRODUCER# #TAKEPRODUCER#  
#WRITER# #ENDWRITER# #TAKEWRITER#  
#REGION# #ENDREGION# #TAKEREGION#  
#EDITION# #ENDEDITION# #TAKEEDITION#  
#SCREENDVD# #ENDSCREENDVD# #TAKESCREENDVD#  
#AUDIODVD# #ENDAUDIODVD# #TAKEAUDIODVD#  
#PHOTOGRAPHER# #ENDPHOTOGRAPHER# #TAKEPHOTOGRAPHER#  
#STUDIO# #ENDSTUDIO# #TAKESTUDIO#  
#MPAA# #ENDMPAA# #TAKEMPAA#  
#MUSIC# #ENDMUSIC# #TAKEMUSIC#  
#DISTRIBUTOR# #ENDDISTRIBUTOR# #TAKEDISTRIBUTOR#  
#OFFICIALWEB# #ENDOFFICIALWEB# #TAKEOFFICIALWEB#  
#CUSTOMINFO# #ENDCUSTOMINFO# #TAKECUSTOM10#
#TAKECUSTOM11#
 
#UPC# #ENDUPC# #TAKEUPC#  
#AWARDS# #ENDAWARDS# #TAKEAWARDS#  
#SEASON# #ENDSEASON# #TAKESEASON#  
       
#ACTORDATA# #ENDACTORDATA# ALL All Actor's functions must be inside this block
       



General Blocks

BEGIN END SPECIAL FUNCTION DESCRIPTION
#RIGHTPAGEFOUND# #ENDRIGHTPAGEFOUND# #CONDITIONRIGHTPAGE# Use This to know if you have found directly the page of the movie or you are in a movie's list page. You can set the Condition with special function, if positive, you have found it!
#CREATEMOVIELIST# #ENDCREATEMOVIELIST# #WRITETITLELIST# Use this to create a list of movies (if you haven't found the right page), but read carefully how to do in the Function Section!
#DELETETAGS# #ENDDELETETAGS# #CHECKVARIABLE#
#STARTDELETETAGS#
#DELETEWORD#
This is a particular Block. With this you can write to Engine what "Tags" or Word you want eliminate from a variable. You must go to the Help of the Function for learn more.
#SUBSTITUTETAGS# #ENDSUBSTITUTETAGS# #CHECKVARIABLE#
#STARTSUBSTITUTETAGS#
#SUBSTITUTEWORD#
This is a particular Block. With this you can write to Engine what "Tags" or Word you want replace from a variable. You must go to the Help of the Function for learn more.
       

          top

IF...ENDIF Statement

The Engine can support the IF Statement, but you can't make an IF statement inside another IF. It Means that you can use any IF you want but each one must be used separatly; however, you can put an IF Statement inside a REPEAT...WHILE and vice-versa
This release of MagicScript Doesn't support the "ELSE" statement, but you have the #GOTO# Function that will help you in many different cases. The Structure is :

#IF# #??#==#??#
    .....
    .....
#ENDIF#

The IF compares two (RED) VARIABLES, and supports only these variables. If the result of the comparison is positive, Engine will execute the instruction inside IF-ENDIF, else all instructions will be ignored.This means that if you want to compare two strings, you must put it on empty VARIABLES first and then use the IF Statement. This isn't a big limitation for this kind of application.

Operators

Operators you can use with IF Statement :

"=="  that means "Equal To", you can use it for strings and number comparisons
"<>"  that means "Different", you can use it for strings and number comparisons
"<<"  that means "Minor" , this makes a comparison only between numbers
">>"  that means "Major" , this makes a comparison only between numbers

It isn't supported any operator like <= or >= because these operators are useless.

top

REPEAT...WHILE Statement

The Engine can support REPEAT...WHILE Statement, but you can't make a REPEAT statement inside another REPEAT. It Means that you can use any REPEAT you want but each one must be used separatly. Inside a REPEAT, you can put all the instructions you want, also IF Statements (and vice-versa).
The Structure is :

#REPEAT#
    .....
    .....
#WHILE#
#??#==#??#

The WHILE compares two (RED) VARIABLES, and supports only these variables. If the result of the comparison is positive, Engine will execute the cycle of instructions again, otherwise it will terminate the REPEAT-WHILE Statement.If you want to compare two strings, you must first put them on empty VARIABLES and then use the WHILE. This isn't a big limitation for this kind of application.

Operators

Operators you can use with the WHILE Statement are :

"=="  that means "Equal To", you can use it for strings and number comparison
"<>"  that means "Different", you can use it for strings and number comparison

You must be careful when you use a #GOTO# Instruction! See Example :

Good Code :
In this part of code everything is OK, the #GOTO# Instruction points to a LABEL that is out of any IF and REPEAT.

#REPEAT#
        #FIND#=Href="#10# #ONERROR#=*OK*
        #IF# #10#==#09#
                #GOTO#=
CAST2
        #ENDIF#
        #FIND#=>#01# #ONERROR#=*ASK*
        #FIND#=<#02# #ONERROR#=*ASK*
        #TAKEWORD#=#03#,#01#,#02#
        #TAKEACTOR#=#03#
#WHILE# #09#<>#10#
:CAST2

BAD Code :
This code is BADLY written, because the #GOTO# Instruction points to a LABEL that is inside another REPEAT! At this time of development, MagicScript will not warn you of this error, and the result of this script ARE UNPREDICTABLE!

#REPEAT#
        #FIND#=Href="#10# #ONERROR#=*OK*
        #IF# #10#==#09#
                #GOTO#=
CAST2
        #ENDIF#
        #TAKEWORD#=#03#,#01#,#02#
        #TAKEACTOR#=#03#
#WHILE# #09#<>#10#
#REPEAT#
        #FIND#=Href="#10# #ONERROR#=*OK*
       
:CAST2
       
#TAKEWORD#=#03#,#01#,#02#
        #TAKEACTOR#=#03#
#WHILE# #09#<>#10#



top

OPENNEWWEB Special Function

Particular attention must be focused on this Special Function #OPENNEWWEB#. Basically MagicScript Works with the HTML specified on #WEBQUERY# when you find directly the page of a movie, or another HTML you select from the LIST of MOVIE FOUND. With this instruction, you can OPEN and work to another HTML Until #RESTOREWEB# instruction is reached. This is particularly useful when some information (like plot in imdb.com, box covers in dvdempire.com) is stored in a different page. It is important that you SAVE the position of the CURSOR before using this function, so that you will find it when you go back to the original HTML.

Example

#OPENNEWWEB#=#50#
    #REPEAT#
        #FINDLINE#=http://posters.imdb.com#12##ONERROR#=*STOP*
        #FIND#=http://posters.imdb.com#01# #ONERROR#=*STOP*
        #IF# #12#<>#09#
            #FIND#="#02# #ONERROR#=*STOP*
            #TAKEWORD#=#03#,#01#,#02#
            #STRING#=#04#=h#03#
            #TAKEPOSTER#=#04#
        #ENDIF#
    #WHILE# #09#<>#12#
#RESTOREWEB#

This is a part of imdb's Script. In the variable #50# is stored the URL of the page that contains the posters.
The Engine with #OPENNEWWEB# re-initializes itself. To start reading the new HTML, set the first line at the top (without #STARTREADWEB# function) and set CURSOR to 1. The functions inside #OPENNEWWEB# are executed sequentially until #RESTOREWEB# is reached.

NOTE: You can use this function where you want in the script and as many times as you want, BUT you can't use it inside another #OPENNEWWEB#-#RESTOREWB#.

You can have :

#OPENNEWWEB#=#50#
    .....
#RESTOREWEB#
   ....
#OPENNEWWEB#=#50#
    .....
#RESTOREWEB#

But it is not correct to write:

#OPENNEWWEB#=#50#
    ......
    #OPENNEWWEB#=#50#
    ......
    #RESTOREWEB#
    ......
#RESTOREWEB#

The result of this Script are UNPREDICTABLE

top

GOTO Instruction

Helping you to write powerful scripts, the #GOTO# Instruction is at your disposal. When the Engine will find this, the execution will jump to the LABEL Specified.
The Structure of this Instruction is :

#GOTO#=LABEL

Where label is a LABEL in another line of the Script.
A LABEL statement is composed by a colon followed by text : ":LABEL1"

When you want to go to this label, you must use this instruction :

"#GOTO#=LABEL1"

It is important
not to put the colons in the #GOTO# instruction! : "#GOTO#=:LABEL1" and to cancel all spaces to the right! If you write a goto like this : "#GOTO#=LABEL1 ", the Engine will not find the Label and will report to you an error!

Particular attention must be payed when you use #GOTO# inside REPEAT..WHILE Statement :


Example

Good Code :
In this part of code everything is OK, the #GOTO# Instruction points to a LABEL that is out of any IF and REPEAT.

#REPEAT#
        #FIND#=Href="#10# #ONERROR#=*OK*
        #IF# #10#==#09#
                #GOTO#=
CAST2
        #ENDIF#
        #FIND#=>#01# #ONERROR#=*ASK*
        #FIND#=<#02# #ONERROR#=*ASK*
        #TAKEWORD#=#03#,#01#,#02#
        #TAKEACTOR#=#03#
#WHILE# #09#<>#10#
:CAST2

BAD Code :
This code is BADLY written, because the #GOTO# Instruction points to a LABEL inside another REPEAT! At this time of development, MagicScript will not warn you this error, and the result of this script ARE UNPREDICTABLE!

#REPEAT#
        #FIND#=Href="#10# #ONERROR#=*OK*
        #IF# #10#==#09#
                #GOTO#=
CAST2
        #ENDIF#
        #TAKEWORD#=#03#,#01#,#02#
        #TAKEACTOR#=#03#
#WHILE# #09#<>#10#
#REPEAT#
        #FIND#=Href="#10# #ONERROR#=*OK*
       
:CAST2
       
#TAKEWORD#=#03#,#01#,#02#
        #TAKEACTOR#=#03#
#WHILE# #09#<>#10#

Top

DELETETAGS Block

This is a particular Block where you can specify all the tags to delete from a Variable.Inside this block you can specify now this KEYWORD :

#DELETETAGS#
    #DELETEWORD#=&nbsp;
    #DELETEWORD#=<BR>
    #DELETEWORD#=</BR>
    #DELETEWORD#=</P>
    #DELETEWORD#=</BLOCKQUOTE>
#ENDDELETETAGS#

In every #DELETEWORD# Keyword you can specify which text you want to remove from a Variable. You can put this Block where you want in the Script, the Engine will find it for you.
To start the process, you must use two others KEYWORD :

#CHECKVARIABLE#=#03#
#STARTDELETETAGS#

In this Example, The Keyword #CHECKVARIABLE# Is used to tell the Engine which Variable you want to check, with #STARTDELETETAGS# Engine will execute the #DELETEWORD#, one by one inside #DELETETAGS# Block. This is useful for example when you import the PLOT or COMMENTS to a movie : some web-pages are full of tags like "<B>,<BR>" etc..

Also in this case, you must be careful : don't write any space after the text you want to delete. The keyword :
"#DELETEWORD#=&nbsp;"
Is different from keyword
"#DELETEWORD#=&nbsp; "

Top
 

SCRIPT'S HEADER

#MADEBY# Variable

This variable contains the name of Script's Creator.

#DATEBUILD# Variable

This variable contains the Date of Script's Creation.

#WEBSITE# Variable

This variable contains the URL of web site.

#NOTE# Variable

This variable contains the characteristic of Script.

#GENERATION# Variable

This variable contains the Generation of the Script.

#REPLACESPACES# Variable

This variable contains the characters that must replace the spaces in the Movie's Title (for query the web).

#ICONQUALITY# Variable

The #ICONQUALITY# Variable is used to set the icon associate to Script.
As you can imagine, the number 0 thru 5 specifies the quality of the script, but there are also others type of icon that you can associate. This is the available :

N   Description
0 Unknown Quality
1 Very Low Quality / Big Problems or too less Information Imported
2 Low Quality / Few Information Imported
3 Quite Good Script / Some Problem with particular Movies
4 Excellent Script, Takes full information / crash rarely
5 Perfects Script, Takes all information available without crash
6 This Script Takes Only Pictures
     

Top

Examples

Example 1 - Easy

If you want to import the TITLE of a movie, you must use the proper Title-Block.

Let's See an example: (this is a part of code of imdb.com Script)


 1 - eXtreme Movie Manager
 2 - 2003 Alessio "AleTsg" Viti
 3 - SCR File For SCRIPT ENGINE
 4
 5 #WEBQUERY#=http://imdb.com/Tsearch?title=#MOVIE#&restrict=Movies+only
 6
 7 #RIGHTPAGEFOUND#
 8     #STARTREADWEB#
 9     #FINDLINE#=<title>#12##ONERROR#=*STOP*
10     #FIND#=>#01##ONERROR#=*STOP*
11     #PUT#=4#02#
12     #TAKEWORDLEN#=#03#,#01#,#02#
13     #PUT#=IMDb#04#
14     #CONDITIONRIGHTPAGE# #03#<>#04#
15 #ENDRIGHTPAGEFOUND#


The first 3 lines contain only comments, MagicScript will ignore them. You can write comments where you want in the code, but not inside the instructions!
The Number in the line is only an example, you can use it or not; MagicScript will ignore it.

The line 5 contains the first Keyword : #WEBQUERY# & #MOVIE# in this case, Engine knows that when you ask a movie in imdb.com, the "query" to locate the page is (for example if you want the movie "ALIEN") :
http://imdb.com/Tsearch?title=ALIEN&restrict=Movies+only
The CONSTANT #MOVIE# contains directly the movie you are looking for, you can use this in any part of the script.

The lines 7 thru 15 contain a BLOCK. As I wrote before, a script is composed with BLOCKS, each one with a specific function.
The position of this block in the Script-Fileis isn't important, because the Engine will find it automatically.
What's important are the instructions INSIDE the BLOCK!
All commands or statements inside are executed sequentially until the end of the BLOCK is reached!
In this example, the block begins with  #RIGHTPAGEFOUND# and ends with #ENDRIGHTPAGEFOUND# .All blocks must have a beginning and a end!

#RIGHTPAGEFOUND# BLOCK is used to know wether the page that you have asked for in your web-movie-site is directly the page of the movie or a page with a list of movies (in this case you must choose one of them).

The line 8 contains the instruction
#STARTREADWEB#. This will reset all previous reads you have done in the HTML of the web-page and re-initialize Engine.As you know, an HTML file is similar to a TEXT File, it is composed with Lines, and every line has a string of different length. When you go on with the analisis of an HTML page, you can't know the number of the line you are in, but you CAN know the position of a variable called CURSOR. It is important to know this, because you will need to know where you are in the string!
You can do some operations in this Variable, that is the most important of the entire Engine.
Now that you know its existence, you must know that when the instruction
#STARTREADWEB# is executed, the CURSOR variable is set to 0 and Engine will start to read lines of HTML from the top of the File.

The line 9 Contains the Function #FINDLINE#. This function searches for you a specific line in the HTML that contains the text specified from = until first # : 
#FINDLINE#=<title>#12##ONERROR#=*STOP* and will put in the variable #12# the result of this search : 0->not found   1->found
It is INDISPENSABLE that you put the text you are looking for in the
=text#, note that if you write a thing like this =text # you will have a different result from this function, because in the former case it will search for a string like "text", in the latter a string like "text " with a space!!
With the #ONERROR# statement you can specify what Engine must do if it encounters an error. It supports 3 different CONSTANTS : *STOP*,*OK*,*ASK* , with *STOP* the engine will terminate the FUNCTION, with *ASK* it will show you the error and the line on the script where the function is, and with *OK* the engine it will ignore the error and will go on...
NOTE : The CURSOR Variable will contain the number of the first character you search in the String-Line!

Line 10 , #FIND# Function :
#FIND#=>#01##ONERROR#=*STOP* The Structure of this function is similar to #FINDLINE#. but this will search the text specified inside = and # in the line where CURSOR is and start to search it from the CURSOR's position. In the VARIABLE #01# you will have the address of the First character of your Text ( you will have 0 if Engine Can't found it!). the #ONERROR# statement is equal for all Function.

Line 11,
#PUT# Instruction : #PUT#=4#02# This instruction puts a text (or numbers) in a specified VARIABLE (in this case #02#). The text or numbers must be inside = and #!

Line 12, #TAKEWORDLEN# Function :
#TAKEWORDLEN#=#03#,#01#,#02# This Function Puts in the VARIABLE #03# the Text contained in the CURRENT LINE that starts at position contained in variable #01# with a LENGTH specified in the Variable #02#.
It is Important that when you use this Function, like the others, you respect completely the structure!
IF you write for example
#TAKEWORDLEN #= #03#,#01#,#02# with spaces, Engine will not recognize IT! and the Function will be ignored like a note!


Line 14 #CONDITIONRIGHTPAGE# This is a SPECIAL FUNCTION to CHECK if the page you found contains the movie you want or if it is a simple list of available movies. It works like an #IF# condition, #CONDITIONRIGHTPAGE# #03#<>#04# :If the content of the VARIABLE #03# is different from VARIABLE #04# the condition is true and you have found directly the page of the movie!

Now that you know some of the functions, let's see all the code at work in a little HTML part; This is the original imdb HTML of the movie "Matrix" :
This Code,as you know, is exactly what is taken by
#WEBQUERY# Instruction :

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
<HTML>
<HEAD>
<!-- This page is Copyright of the Internet Movie Database 1990-2001 -->
<!-- unless stated otherwise in the source. -->
<!-- see www.imdb.com/ for more information -->
<BASE TARGET="_top">
<!--
server=imdb-online-1106.imdb.com
cobrand=us.imdb.com
cache=const=133093
date=Thu, 03 Jan 2003 11:15:48 GMT
-->
<TITLE>Matrix, The (1999)</TITLE>
<BASE HREF="http://us.imdb.com/Title?0133093">
<META NAME="description" CONTENT="Matrix, The (1999) at IMDb">
<META NAME="keywords" CONTENT="Matrix, The (1999)">
.......

I will monitor all VARIABLES used in this part of code
Start with Line 8, we want know if this is the right page! (You must know that if it wasn't, the Title of web page was "IMDb" etc...)

I want inzialize the Engine :
#STARTREADWEB#
Line of HTML = 1 : <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
CURSOR Variable = 0

I want search where is specified the title of the web-page :
#FINDLINE#=<title>#12##ONERROR#=*STOP*
Line of HTML = 14 : <TITLE>Matrix, The (1999)</TITLE>
CURSOR Variable = 1 (start position of the text you search)
#12# Variable = 1 (text found!)

I have found the line, now I want know the title and to do it I must know the position of the title in the string, I must search this char : >
#FIND#=>#01##ONERROR#=*STOP*
Line of HTML = 14 : <TITLE>Matrix, The (1999)</TITLE> (The SAME!)
CURSOR Variable = 7 (position where the text you search starts)
#01# Variable = 7 (same as CURSOR)

I need to put number 4 in the variable #02# because the function #TAKEWORDLEN# works only with VARIABLES!
#PUT#=4#02#
Line of HTML = The SAME! This function doesn't touch this
CURSOR Variable = The SAME! This function doesn't touch this
#02# Variable = 4 (is the number of character that the function #TAKEWORDLEN# must read!)

I want take the first 4 letters of the title! if you see, the VARIABLE #03# will contain this, The VARIABLE #01# contains where the title starts (we have found it with #FIND# Function) and the VARIABLE #02# contains the LENGTH of the text to take (we have set it with #PUT# function) :
#TAKEWORDLEN#=#03#,#01#,#02#
Line of HTML = The SAME! This function doesn't touch this
CURSOR Variable = The SAME! This function doesn't touch this
#03# Variable = "Matr" (the part of the title)

I need to put the text "IMDb" in the variable #04# because the function #CONDITIORIGHTPAGE# works only with VARIABLES for make the comparison!
#PUT#=IMDb#04#
Line of HTML = The SAME! This function doesn't touch this
CURSOR Variable = The SAME! This function doesn't touch this
#04# Variable = "IMDb" (the string that tells me if I have found the right page)

 I want to know if I have found the right page : if the content of VARIABLE #03# is different of #04# I have found it! :
#CONDITIONRIGHTPAGE# #03#<>#04#
#03# Variable = "Matr" (the part of the title)
#04# Variable = "IMDb" (the string that tells me if I have found the right page)
#03#<>#04# : Word "Matr" in the VARIABLE #03# is DIFFERENT from word "IMDb" in the #04# VARIABLE --> YES! Now Engine knows IT!


#ENDRIGHTPAGEFOUND#
The BLOCK is Finished, Engine will execute the others Blocks



Top
 

Programmers Tips

#REPEAT#-#WHILE# Tips

Problem #1 : I need more nested Repeat-While Statement ! how can I do it ?

You know that Engine can support REPEAT...WHILE Statement, but you can't make a REPEAT statement inside another REPEAT (Nested); However, you can deceive this obstacle.
It's quite easy build an alternative structure of nested repeat-while statement, also if isn't a "good programmed" procedure :
You can write nested LABELS, and you can control the execution with IF statement :

Good Code :

 :REPEAT1
      #FIND#=>#01# #ONERROR#=*OK*
      #FIND#=<#02# #ONERROR#=*STOP*
      #TAKEWORD#=#03#,#01#,#02#
      :REPEAT2
            #FIND#=>#01# #ONERROR#=*OK*
            #FIND#=>#01# #ONERROR#=*OK*
            #TAKEWORD#=#03#,#01#,#02#
            #IF# #03#==#04#
                  #GOTO#=REPEAT2
            #ENDIF#
      :ENDREPEAT1
      #IF# #03#==#04#
            #GOTO#=REPEAT1
      #ENDIF#
:ENDREPEAT1

Unpredictable Code :

#REPEAT#
  :REPEAT1
      #FIND#=>#01# #ONERROR#=*OK*
      #FIND#=<#02# #ONERROR#=*STOP*
      #TAKEWORD#=#03#,#01#,#02#
      :REPEAT2
            #FIND#=>#01# #ONERROR#=*OK*
            #FIND#=>#01# #ONERROR#=*OK*
            #TAKEWORD#=#03#,#01#,#02#
            #IF# #03#==#04#
                  #GOTO#=REPEAT2
            #ENDIF#
      :ENDREPEAT1
      #IF# #03#==#04#
            #GOTO#=REPEAT1
      #ENDIF#
  :ENDREPEAT1
#WHILE# #01#==#02#

Note : if you decide to use this structure, don't put inside or ouside of it REPEAT-WHILE Statement! Because the result of this action may be unpredictable.

 

#OPENNEWWEB# Tips

Problem #1 : I need to go deeply in a web-site, but the #OPENEWWEB# instructions can't be nested, wht can I do ?

 This problems comes out for example when you want import covers. In this case, you can use a first time this instruction, save the deeply URL link to visit in a variable, close the first  #OPENNEWWEB# and use the instruction again for visit the new URL. With this simple method, you can access to more web-pages and not only one.




Top

MagicScript Editor

The Script File are normal TXT files, so you can open and modify with any program. The use of ScirptEngine Editor is useful when you want check your Script for typing errors.

At this phase of development, Editor can analyse Script for errors in the #GOTO# Instructions, #IF# and #REPEAT# Statement.


Known Bugs

At this time, there aren't known bugs, if you found one, please report it here.

Credits

MagicScript Technology @ By BinaryWorks.it @2003.
Source Code isn't available, in any case you can write your request here.

Top