Author Topic: Making a script tutorial #1  (Read 13233 times)

Offline chip!

  • Bad Ass
  • Administrator
  • Unstoppable
  • *****
  • Posts: 2301
  • Karma: +629/-6
    • View Profile
Making a script tutorial #1
« on: October 09, 2006, 05:16:50 pm »
Making a script tutorial #1
by chip!


Site:  IPTorrents.com


1. Start with the main site homepage. Here you will see the login boxes. View the HTML and find the Form POST action:
action="/takelogin.php"

Now, since this site appears to be similar to many other torrent tracker's, lets find a script already built for a similar one. Odds are, if the login uses the same PHP scripts to handle the login, the output from the search will be similar, thus making it easy to convert a old script to this site. After looking at a few other private site scripts, Dimeadozeng.ini appears to have a very similar login structure so lets try choose this one.

2. Open "dimeadozen.ini" and save it as "iptorrents.ini"

3. Change the references in from "dimeadozen.org" to "iptorrents.com"

4. Change the login= to reflect the action from the HTML source code:
login=http://www.iptorrents.com/takelogin.php

5. Update the login failed tag as well: 
failed=action="takelogin.php"

6. Now we need to update the search url for IPtorrents.com. Login to your account and make a search. Grab the URL address of your browser. Replace your search term with %SEARCH% and save it as "main="
main=http://www.iptorrents.com/browse.php?incldead=0&search=%SEARCH%&cat=0

7. Now we are ready to parse the results. Search the HTML for a tag or reference that is somewhat near the begin of the torrent  results. Header of the Table for the torrent results are often a good bet because they are often unique in the HTML source code. "Seeders[/url]</td>" is an example because its right before the start of the torrent search and it is not found anywhere else in the HTML source code. Next we see that the following "</tr>" is the last html tag before the start of the torrent results. Set the first line of the script code to:

x=h(x,d,Seeders[/url]</td>,/tr>)

we notice that </table> is the end of the torrent results in the HTML code, so the script template seems to be good so far. Lets move on.

8.  Go down to the first torrent result '<tr>' block in the HTML. Copy and paste this block into QAD:
Code: [Select]
<tr>

<td align=center style='padding: 0px'><a href="browse.php?cat=3"><img class="musicmisc" border="0" src=/pic/blank2.gif alt="Music > Audio" /></a></td>
<td align=left><a href="details.php?id=4938&amp;hit=1"><b>VA-Dance Mania-The Ultimate Club Party-PROPER-2CD-2006-MUSiQ</b></a><a class="index" href="download.php/4938/VA-Dance_Mania-The_Ultimate_Club_Party-PROPER-2CD-2006-MUSiQ.torrent"><img style=border:none alt=download src=pic/download.gif align=right></a></td>
<td align="right"><b><a href="details.php?id=4938&amp;hit=1&amp;filelist=1">6</a></b></td>
<td align="right"><b><a href="details.php?id=4938&amp;hit=1&amp;tocomm=1">14</a></b></td>
<td align=center><nobr>2006-09-20<br />16:55:19</nobr></td>
<td align=center><img src="pic/progress-4.gif"/> (86%)</td>
<td align=center>212.52<br>MB</td>
<td align=center>9.90 kB/s</td>

<td align=center>77<br>times</td>
<td align="right"><b><span class="green">3</b></span></td>
<td align=right><b>1</b></td>
</tr>


Using the default delimiter, QAD produces:

Code: [Select]
q(0):
<tr>

<td align=center style='padding: 0px'><a href="browse.php?cat=3"><img class="musicmisc" border="0" src=/pic/blank2.gif alt="Music > Audio" /></a>

q(1):
<td align=left><a href="details.php?id=4938&amp;hit=1"><b>VA-Dance Mania-The Ultimate Club Party-PROPER-2CD-2006-MUSiQ</b></a><a class="index" href="download.php/4938/VA-Dance_Mania-The_Ultimate_Club_Party-PROPER-2CD-2006-MUSiQ.torrent"><img style=border:none alt=download src=pic/download.gif align=right></a>

q(2):
<td align="right"><b><a href="details.php?id=4938&amp;hit=1&amp;filelist=1">6</a></b>

q(3):
<td align="right"><b><a href="details.php?id=4938&amp;hit=1&amp;tocomm=1">14</a></b>

q(4):
<td align=center><nobr>2006-09-20<br />16:55:19</nobr>

q(5):
<td align=center><img src="pic/progress-4.gif"/> (86%)

q(6):
<td align=center>212.52<br>MB

q(7):
<td align=center>9.90 kB/s

q(8):
<td align=center>77<br>times

q(9):
<td align="right"><b><span class="green">3</b></span>

q(10):
<td align=right><b>1</b>

Appears to be a perfect array split up because we can neatly see the torrent details in different arrays. So we continue on.

9. We can see that the torrent name (#1), the torrent page (#3) and the torrent URL (#7) are all in the array q(1). Our template script already starts off with this array, so we continue.

10. Delete the extra lines in the script that arent needed:
t=replace(t,<strong>,)
x=p(1)

11.  Torrent page is easily stored after finding the first 'href=' and extracting from " to ".
z=i(z,t,href=)
3=x(t,z,",",http://www.iptorrents.com/)

12.  Delete the script lines that follow this until the next array change "t=array(q,6)" because we can easily see that the torrent name is followed after a <'b> tag and we dont need to do any of that script code to get the name/url.

Lines to delete:
t=replace(t,<strong>,)
x=p(1)
z=i(x,t,href=)
3=x(t,z,",",http://www.iptorrents.com/)
x=i(x,t,?id=)
z=i(x,t,&)
x=+(4)
k=c(t,x,z)
m=p(http://www.iptorrents.com/download.php/)
m=&(m,k)
k=p(/)
m=&(m,k)
x=i(x,t,>)
z=i(x,t,</)
x=+(1)
k=c(t,x,z)
1=save(k)
k=replace(k, ,.)
m=&(m,k)
k=p(.torrent)
m=&(m,k)
7=save(m)


We can then use the following code to extract the torrent name:
z=i(z,t,<'b>)
1=x(t,z,>,</)
This extracts from the <'b>'s  ">" to the next HTML tag: "</"

13.  Further on we see the next href= is the beginning of the torrent URL which is easily extracted and stored:
z=i(z,t,href=)
7=x(t,z,",",http://www.iptorrents.com/)

14. Now we are done with this array so lets grab the array with the file size (which is conveniently the same as the script template):
t=array(q,6)

15. We can move on to the next array change because the script code appear to be perfect as it is. The script is then at the line:
"t=array(q,8)" but we notice in QAD that the 'seeders' information is in array 9 instead of 8. So update the script:
t=array(q,9)

16. Instead of the 'color=' tag in the script, we see in the HTML source that there is a '<span' tag we can search to:
z=i(z,t,<span)

17. The extract & save code appears to be the same so we move on to the 'leechers' information. In QAD we see this information is in array 10 instead of 9. So update the script code and we should be done!:
t=array(q,10)

18. Fire up the script debugger in Bit Che and perform a search. Step through each line to make sure we're extracting and saving the information properly. If something is not correct, edit the "IPTorrents.ini", save it, and step BACK in the script debugger to update the script in Bit Che and try again. Since this script was pretty much the same as the original template, we should be in good shape! (and we are).. so we're done.
« Last Edit: October 09, 2006, 05:29:15 pm by chip! »
  -  https://convivea.com  -   And...  boom goes the dynamite.

Offline chip!

  • Bad Ass
  • Administrator
  • Unstoppable
  • *****
  • Posts: 2301
  • Karma: +629/-6
    • View Profile
Making a script tutorial #1
« Reply #1 on: October 09, 2006, 05:30:50 pm »
is this helpful to anyone? I know it appears long and tedious, but if you are already slightly familiar with the script functions, maybe this is good practice reference for writing/creating a script?
  -  https://convivea.com  -   And...  boom goes the dynamite.

Offline Quantum

  • Ascended One
  • Hero Member
  • *****
  • Posts: 782
  • Karma: +206/-0
  • Daniel Jackson is looking at you!
    • View Profile
Making a script tutorial #1
« Reply #2 on: October 09, 2006, 06:36:24 pm »
This is quite helpful, I would have done a couple of scripts by this point but I've been very bogged down with work.

There's a few Anime torrent sites I'll give a quick go at in the next couple of days, I have no lectures tomorrow so plenty of time to work on it  :).
Daniel: "This tastes like chicken."
Carter: "So what's wrong with it?"
Daniel: "It's macaroni and cheese."

sHaDYvB

  • Guest
Re: Making a script tutorial #1
« Reply #3 on: December 14, 2006, 04:54:05 pm »
chip , this really was helpfull in the beginning ,

but as some point when u left alot of things i became lost :s

duno :(

will try to make this on my own , but u try to make another one without editing a previoud script , yes it'll be alittle hard , but it'll make it clear for more ppl to make alot of scripts ;)