Scripting
How to make a script for XMM
Example: FILMTV.IT
1. Set the script’s description for information purposes (no execution)
-------------------------------------------------
- eXtreme Movie Manager -
- MagicScript Technology -
- 2001-2016 BinaryWorks.it -
--------------------------------------------------
- Web : FilmTV.IT -
- Author : JDommi -
- Date : 5/June/2013 -
- Comments: Import All Information -
---------------------------------------------------
2. Setup of the script (needed/shown on selecting a script for import)
#MADEBY#=JDommi
#DATEBUILD#=2018-05-14 - 09:38
#WEBSITE#=FilmTV.IT (Italian)
#NOTE#=Importa tutte le informazioni disponibili
#SCRIPTQUALITY#=5
#SCRIPTGENERATION#=3
#REPLACESPACES#=+
#TVSERIES#=FALSE
#SCRIPTFORACTORS#=FALSE
#LANGUAGESORT#=IT
[LANGUAGESORT]=EN=English|IT=Italian|FR=France|DE=Deutsche
#TYPE#=0
[TYPE]=0=Complete|1=Covers|2=Trailers|3=Tunes|4=Subtitles|5=Chains|6=Mistakes|7=Games|8=Adult|9=Anime
#OPTIONS#=1
[OPTIONS]=0=No Options
3. Set the search term
#WEBQUERY#=https://www.filmtv.it/cerca/?q=#MOVIE##film
4. Script specific options (#LOADOPTIONS#)
#SETOPTION#=#90#1[Importa Galleria Foto]0=Non prendere foto|1=Prendi tutte le foto
#SETOPTION#=#91#3[Note e Commentari]0=Niente|1=Solo Note|2=Solo Commentari|3=Note e Commentari
5. Set global variables to their values (#SETVARIABLES#)
#PUT#=0#00#
6. Check if the search term is already a valid link (#RIGHTPAGEFOUND#) for updating an already imported movie
7. Read the list of movies that match the search term (#CREATEMOVIELIST#) and output them this way:
#WRITETITLELIST#=webaddress ---> Title [more info if wanted] §Link to Cover
8. Preload subpages for later use (#LOADWEBSLOTS#) if needed
#OPENWEBSLOT1#=#03#
#LOADWEBSLOT1#
… script code …
#RESTOREMAIN#
Alternatively use #OPENNEWWEB# … #RESTOREWEB# in other blocks
9. Get all the info of a movie (different blocks)
See http://www.binaryworks.it/cgi-bin/data/wiki/doku.php?id=programmer_s_guide
10. Special blocks for removing/replacing HTML code constants
#DELETETAGS# #61664; remove phrases from a variable #61664; #DELETEWORD#=Top 250:
#SUBSTITUTETAGS# #61664; replace HTML code #61664; #SUBSTITUTEWORD#=±=±
#SUBSTITUTEWEBQUERY# #61664; replace HTML code in WEBQUERY’s search term #61664; #SUBSTITUTEWEBQUERYWORD#=#=%23
11. Important commands to set, save or get saved positions (line / cursor)
#COMPUTECURSOR#=+/- value #61664; set the cursor position relatively to it’s current position
#RESETCURSOR# #61664; set cursor to the start of the line
#STARTREADWEB# #61664; set line and cursor to the start
#PUTCURSOR#=#01# #61664; save the cursor position to a variable
#LOADCURSOR#=#01# #61664; reload the cursor position
#SAVEWEBSITELINE# #61664; save the actual websiteline (No variable used)
#RESTOREWEBSITELINE# #61664; reload the actual websiteline (No variable used)
12. Special commands
Search a phrase in the loaded HTML of the website
#FIND#=text#01# #61664; find next occurrence of text in current website line and store the cursor position in variable
#FINDPREVIOUS#=text#01# #61664; find previous occurrence of text in current website line and store the cursor position in variable
#FINDLINE#=text#01# #61664; find next occurrence of text in website lines and store the cursor position in variable
#FINDPREVIOUSLINE#=text#01# #61664; find previous occurrence of text in website lines and store the cursor position in variable
#READNEXTLINE# #61664; read next line of website or
#READNEXTLINE#=2 #61664; read 2 lines of website
#TAKEWORD#=#13#,#01#,#02# #61664; store website line from position 1 to position 2 in variable 13
#CHECKVARIABLE#=#13# #61664; perform replacements on variable #61664; #STARTSUBSTITUTETAGS#, #STARTDELETETAGS#, #CLEARTAGS#, #TRIM#
#STRING#=#13#=text #61664; combine text and/or variable (or multiple phrases)
#PUT#=0#13# #61664; fill a variable with an alphanumerical value
13. Loops and conditions
#IF# #01#==#02# // ==, <<, >>
… code or #GOTO#=LABEL // continue with code line :LABEL
#ENDIF#
#REPEAT#
… code …
#WHILE# #01#==#02#
Use only one condition of the same kind (do not nest them).
You can combine both #IF# and #REPEAT#
14. Take info (different commands)
See http://www.binaryworks.it/cgi-bin/data/wiki/doku.php?id=programmer_s_guide
15. There are a few more commands but in 99% of all cases you need only the above mentioned.
16. For scripting use either the MagicScript Editor or the ScriptDebugger.
MagicScript Editor is the internal one
ScriptDebugger is a plugin and behaves under rare conditions slightly different but is much more comfortable