For Bit Che version 2.0, please read: http://convivea.com/forums/index.php?topic=1972.0
EDIT: THIS PAGE IS OUT DATED AND IS REFERENCE ONLYBit Che Script Documentation v.01aNOTE: The easiest way to learn how to write scripts is to read over these first few paragraphs and the Quick Functions List, and then "debug" one of the existing scripts so that you can watch the functions and the script in action. Once you get the idea of how the script works, then attempts to write your own will be far easier.
Before you begin working on a script, first edit "settings.ini" and add a line "debug=1" in the "[options]" section. This file is found in the installation directory. Now, a menu item appears, "Debug Script" (or you can hit F12) to bring up a step-by-step debugger when working with Bit Che scripts. Initial Notes:
Scripts are designed to parse HTML output into 2 arrays (R & Q). The first array 'r' stores the data that contains all of the 'results' and is parsed based on whatever delimiter is required to put each complete result into its own array element of 'r'. The delimiter for 'r' is typically "</TR>". The second array 'q' is used when looping through each result in 'r' and splits the data into a organized data array. The delimiter for 'q' is typically something like "/TD>". Then we loop through the information array and store the torrent information to special variables.
Note: You might like to use the Quick Array Display tool to help you break down the HTML when parsing the data into the arrays: Quick Array DisplayVariable Handling:
Variables a to z can be used (lower case) with the exception of a few special ones.
r = assigned to the array containing ALL results
q = assigned to the information array of a single result
d = always the HTML data output sent to the script (can be edited/changed by the script at anytime).
z = is always reset to 1 after the array( function is used.numbers 1 - 7 are used for the torrent's information and can not be accessed as normal a-z character variables.
1 = name
2 = size
3 = source page
5 = seeds
6 = leeches
7 = .torrent url
With the exception of certain functions, basic script commands follow this pattern:X=F(p1,p2,p3)
where X is the return variable letter (a-z) for the function, F is the function name, and p1..p3 are string parametersQuick Functions List:i(
- searches for a stringh(
- searches for a string and halts if not foundr(
- searches for a string in reversec(
- crops/cuts a string split(
- split a data block into an arrayarray(
- access data from the 'q' arrayreplace(
- replace a string with anothersave(
- saves specific torrent information to # (see above)e(
- extract: combines search, crop/cut, and clean.x(
- eXtract: combines search, crop/cut, clean, and save.p(
- store a string into a variable&(
- combine strings OR variables+(
- add a number from a variable-(
- subtract a number from a variablestart
- indicates the start of the result parsing loopaloop
- adds the current torrent to the results list and loops back to 'start'Basic Functions Detailed:h -- Searches a string for another string but HALTS the script if it is not found. Typically the first line of the script. Stores the location of the found string as a integer into the return variable.
vRes = h ( vStart, vData, sSearch )
searches the data variable 'd' for '</td>' starting at position stored in variable 'x' and stores the result into variable 'z'. if '</td>' is not found, the script halts (dies).
Optional extended use, can search for successive terms (up to 10):
vRes = h ( vStart, vData, sSearch , sSearch2, sSearch3...etc )
Note: this will halt the script if the last '' is not found in order starting from the location of the first term. This us useful to make sure you are working with the expected HTML output.i -- Searches a string for another string. Typically Stores the location of the string as a integer into the return variable.
vRes = i ( vStart, vData, sSearch )
exact same as 'h' function but does not halt.r -- Searches in reverse for a string in a variable.
vRes = r ( vStart, vData, sSearch)
searches from the end of 't' for the location of 'title=' and stores it in 'x'
Note: '-1' for the vStart always searches from the END of the string. A number or a variable can be used here. c -- Crops a string into a variable based on a starting and ending location
vRes = c ( vData, vStart, VEnd)
d=c(d,x,z)split -- Used to split up a data block into the arrays.
This is a special function any only 2 result variables are allowed: r & q
r=split(d,</tr>) - sets up the 'r' array delimiting with </tr>
q=split(r,</td>) - sets up the 'q' array delimiting with </td>
Note: the delimiter can be anything you like, the result variables and the array variables can not be changed.array -- Used to access data from the 'q' array and stores into a variable for manipulation.
stores the 3rd item in the 'q' array to the string varriable 't'.
note: arrays always start numbering with 0 for the first item which means when accessing the array items:
0=1st 1=2nd 2=3rd ..etcreplace -- searches a string variable for a specific string and replaces it with another
vRes = replace ( vData, sSearch, sReplace)
Useful when Bit Che needs to parse tricky HTML code,etc.save -- saves a variable to a specific torrent information variable number:
saves the string in variable 'k' to torrent information variable '1' (name)
1 = name
2 = size
3 = source page
5 = seeds
6 = leeches
7 = .torrent url x -- special function that combines searching, cutting, extracting, cleaning, and saving.
vRes = x ( vData, vStart, vEnd)
searches variable 't' starting at the value of 'z' for '<bc>' and extracts the data until '[-bc-]'. this extracted data is then saved as special torrent information variable '2' (file size). The extracted data is automatically 'scrubbed' and cleaned from unwanted HTML codes.e -- special function that combines searching, cutting, extracting, and cleaning.
vRes = e ( vData, vStart, vEnd)
searches variable 't' starting at the value of 'z' for '<bc>' and extracts the data until '[-bc-]'. this extracted data is then saved into variable q. The extracted data is automatically 'scrubbed' and cleaned from unwanted HTML codes.
Note: This is the same as function 'x' except it does not save the result into the special torrent variable. This is useful if you want to use or manipulate the result before you save it to the special torrent # variable.p -- allows you to store a string into a variable
vRes = p ( sString )
stores 'hello world' into 't'
Note: you can store numbers or strings into variables.& -- allows you to combine strings OR variables into one variable.
vRes = & ( vFirst, vSecond, etc..)
combines 'k' with 'm' and saves it as variable 't'
Note: You can also combine text strings instead of variables by placing ' in front of the string. Example:
t = & ( 'http://www.domain.com
, q, '.torrent)
If variable q = "/download.php?name=file", then t would equal http://www.domain.com/download.php?name=file.torrent+/- -- allows you to add or subtract a number from a variable
vRes = + ( sNum)
variable 'x' = 'x' + 1
variable 'x' = 'x' - 5start -- indicates the line number in the script where Bit Che should 'loop' back to to process the next array item in the result array 'r'.aloop -- adds the currently stored special torrent information variables to a torrent result in Bit Che and loops back to the 'start' of the script. other special functions:vacuum -- removes characters like 'tab' and 'line return' from a string
A few other undocumented ones or modifications/extra parameters of the above functions might appear in some scripts. These will be addressed within time.
For some clarity here, lets use a blank TABLE example (typical of HTML output).
<TABLE width="100%" border="1" cellspacing="0" cellpadding="2">
<td>Torrent Name 1</td>
<td>File Size 1</td>
<td>Torrent Name 2</td>
<td>File Size 2</td>
<td>Torrent Name 3</td>
<td>File Size 3</td>
1. First we would trim the HTML data (always variable 'd') to hold what is between the first <tr> and the last </td>.
2. Next we would split the data into the 'r' array (always 'r').
3. Next we start the loop because we want to loop through all the different results in 'r'.
4. At the beginning of the loop, we need to split the current result from the 'r' array into the 'q' array. This puts a single result's data into a single organized array 'q' from which we can then easily work with.
This splits the current item 'r' into 'q'. the 'q' array will hypothetically look like (in memory):
q(0): <td>Torrent Name 1<
q(1): <td>File Size 1<
q(2): <td>URL 1<
5. Store the first array item from the information array 'q' into a string varriable.
6. Extract and save the torrent name.
7. Store the second array item from the information array 'q' into a string varriable.
8. Extract and save the torrent file size.
9. Store the third (last) array item from the information array 'q' into a string varriable.
10. Extract and save the torrent url.
11. Add the stored torrent result and loop back to the 'start' line to parse the next item in the results 'r' array.
12. Completed Example Script for the basic TABLE output:
Example Working Script for TorrentSpy.com:
ok thats all for now.. please ask questions if I can help clarify anything. since i am used to working with this script 'language', i dont know what needs more information, examples, etc.
oh and remember to edit "settings.ini" and write a line "debug=1" and then restart Bit Che if you would like to see some basic debug output from your script when you are testing/writing a script