Advertisement
Guest User

Untitled

a guest
Jun 23rd, 2017
651
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
mIRC 11.05 KB | None | 0 0
  1. ; type /uthelp for info
  2.  
  3. alias ut_getinfo {
  4.  
  5.   ; Incarnation: 2010-03-04 17:00
  6.  
  7.   ; -============================ CHANGE THE VALUES BELOW ============================- ;
  8.  
  9.   ; the username for the webui:
  10.   var %ut_username mirc
  11.   ; the password for the webui:
  12.   var %ut_password joanne
  13.  
  14.   ; the hostname or ip of the machine running µtorrent, if µtorrent + webui is running on the same computer leave it at localhost:
  15.   set -n %ut_url localhost
  16.  
  17.   ; µtorrent port (or the alternative webui port if activated):
  18.   set -n %ut_port 8080
  19.  
  20.   ; OPTIONAL! maximum number of displayed torrentlines (not counting header and footer):
  21.   set %ut_flood_max 10
  22.  
  23.   ; -============================ CHANGE THE VALUES ABOVE ============================- ;
  24.  
  25.   var %continue $false
  26.   if ( $sock(ut_info).to ) {
  27.     if ( $sock(ut_info).to > 25 ) {
  28.       ut_getinfo_end
  29.       %continue = $true
  30.     }
  31.   }
  32.   else {
  33.     %continue = $true
  34.   }
  35.   if ( %continue == $true && $1 && $2 ) {
  36.     set %ut_activechan $1
  37.     set %ut_action $2
  38.     if ( %ut_action == find && $3 ) {
  39.       set %ut_find_string $3-
  40.       ;      msg %ut_activechan 12[µT] Showing the first %ut_flood_max torrents containing $3-
  41.     }
  42.     elseif ( %ut_action == downloading ) {
  43.       ;      msg %ut_activechan 12[µT] Showing the first %ut_flood_max torrents downloading.
  44.     }
  45.     elseif ( %ut_action == seeding ) {
  46.       ;      msg %ut_activechan 12[µT] Showing the first %ut_flood_max torrents seeding.
  47.     }
  48.     set %ut_credentials $encode(%ut_username $+ : $+ %ut_password,m)
  49.     set %ut_download 0
  50.     set %ut_downloadingcount 0
  51.     set %ut_err_torrents 0
  52.     set %ut_flood_count 0
  53.     set %ut_ratio_sum 0
  54.     set %ut_remaining 0
  55.     set %ut_seedingcount 0
  56.     set %ut_sockerr 0
  57.     set %ut_torrentcount 0
  58.     set %ut_upload 0
  59.     set %ut_downloaded
  60.     set %ut_uploaded
  61.     .timerut_getinfo_end 1 20 ut_getinfo_end
  62.     sockopen ut_token %ut_url %ut_port
  63.   }
  64. }
  65.  
  66.  
  67. on 1:SOCKOPEN:ut_token:{
  68.   if ( $sockerr > 0 ) {
  69.     %ut_sockerr = $sockerr
  70.     ut_getinfo_end
  71.     return
  72.   }
  73.   sockwrite -n $sockname GET /gui/token.html HTTP/1.1
  74.   sockwrite -n $sockname Host: $+(%ut_url,:,%ut_port)
  75.   sockwrite -n $sockname Authorization: Basic %ut_credentials
  76.   sockwrite -n $sockname $crlf
  77. }
  78.  
  79. on 1:SOCKREAD:ut_token:{
  80.   if ( $sockerr > 0 ) {
  81.     %ut_sockerr = $sockerr
  82.     echo ow: $sockerr
  83.     ut_getinfo_end
  84.     return
  85.   }
  86.   var %i 1
  87.   while (%i > 0 ) {
  88.     sockread -f %temp
  89.     if ( Set-Cookie: isin %temp ) {
  90.       if ( $regex(ut_re_c,%temp,/GUID=([^; ]*)/) > 0 ) {
  91.         set %ut_cookie $regml(ut_re_c,1)
  92.       }
  93.     }
  94.     if ( $+(id,$chr(61),$chr(34),token,$chr(34)) isin %temp || $+(id,$chr(61),$chr(39),token,$chr(39)) isin %temp ) {
  95.       if ( $regex(ut_re,%temp,/<div[^>]*id=["\']token["\'][^>]*>([^<]*)</div>/) > 0 ) {
  96.         set %ut_token $regml(ut_re,1)
  97.         sockopen ut_info %ut_url %ut_port
  98.         sockclose ut_token
  99.       }
  100.     }
  101.     %i = $sockbr
  102.   }
  103. }
  104.  
  105. on 1:SOCKOPEN:ut_info:{
  106.   if ( $sockerr > 0 ) {
  107.     %ut_sockerr = $sockerr
  108.     ut_getinfo_end
  109.     return
  110.   }
  111.   sockwrite -n $sockname GET /gui/?list=1&token= $+ %ut_token HTTP/1.1
  112.   sockwrite -n $sockname Host: $+(%ut_url,:,%ut_port)
  113.   sockwrite -n $sockname Cookie: GUID= $+ %ut_cookie
  114.   sockwrite -n $sockname Authorization: Basic %ut_credentials
  115.   sockwrite -n $sockname $crlf
  116.   unset %ut_credentials
  117.   unset %ut_url
  118. }
  119.  
  120. on 1:SOCKREAD:ut_info:{
  121.   if ( $sockerr > 0 ) {
  122.     %ut_sockerr = $sockerr
  123.     ut_getinfo_end
  124.     return
  125.   }
  126.   sockread %temp
  127.   if ( $left(%temp,12) == ,"torrentc": ) {
  128.     ut_getinfo_end
  129.   }
  130.   else {
  131.     var %pattern = \["(\w*)",(\d*),"(.*)",(\d*),(\d*),(\d*),(\d*),(\d*),(\d*),(\d*),(-?\d*),"(.*)",(\d*),(\d*),(\d*),(\d*),(\d*),(-?\d*),(\d*)[\]|,]
  132.     if ( $regex(tor,%temp,%pattern) ==  1 ) {
  133.       var %hash = $regml(tor,1)
  134.       var %status $regml(tor,2)
  135.       var %torrentname = $regml(tor,3)
  136.       var %progress $regml(tor,5)
  137.       var %label = $regml(tor,12)
  138.       inc %ut_torrentcount
  139.       inc %ut_remaining $regml(tor,19)
  140.       inc %ut_download $regml(tor,10)
  141.       inc %ut_upload $regml(tor,9)
  142.       inc %ut_downloaded $regml(tor,6)
  143.       inc %ut_uploaded $regml(tor,7)
  144.       inc %ut_ratio_sum $regml(tor,8)
  145.       if ( $isbit(%status,1) == 1 && $isbit(%status,6) == 0 ) {
  146.         if ( %progress == 1000 ) {
  147.           inc %ut_seedingcount
  148.         }
  149.         else {
  150.           inc %ut_downloadingcount
  151.         }
  152.       }
  153.       if ( %ut_action == find ) {
  154.         if ( %ut_find_string isin %torrentname ) {
  155.           if ( %ut_flood_count < %ut_flood_max ) {
  156.             if ( %progress == 1000 ) {
  157.               var %temp = 10[µT]14 $left(%torrentname,40) 10Status:14 $+ $ut_convert_status( %status , %progress ) 
  158.               var %temp1 = 10Uploaded:14 $+ $bytes( $regml(tor,7) ).suf 10Size:14 $+ $bytes( $regml(tor,4) ).suf 10Ratio:14 $+ $calc( $regml(tor,8) / 1000) 10Upload Speed:14 $+ $bytes( $regml(tor,9) ).suf $+ /s P: $+ $regml(tor,13) $+ ( $+ $regml(tor,14) $+ ) S: $+ $regml(tor,15) $+ ( $+ $regml(tor,16) $+ )
  159.             }
  160.             else {
  161.               var %temp = 10[µT]14 $left(%torrentname,40) 10Status:14 $+ $ut_convert_status( %status , %progress )
  162.               var %temp1 = 10Downloaded14: $+ $bytes( $regml(tor,6) ).suf 10Size:14 $+ $bytes( $regml(tor,4) ).suf 10Complete:14 $+ $calc( %progress / 10) $+ $chr(37) 10Download Speed:14 $+ $bytes( $regml(tor,10) ).suf $+ /s P: $+ $regml(tor,13) $+ ( $+ $regml(tor,14) $+ ) S: $+ $regml(tor,15) $+ ( $+ $regml(tor,16) $+ ) ETA: $+ $duration( $regml(tor,11) )
  163.             }
  164.             msg %ut_activechan %temp
  165.             msg %ut_activechan %temp1
  166.           }
  167.           inc %ut_flood_count
  168.         }
  169.       }
  170.       elseif ( %ut_action == downloading && %progress < 1000 && $isbit(%status,1) == 1 && $isbit(%status,6) == 0) {
  171.         if ( %ut_flood_count < %ut_flood_max ) {
  172.           var %temp = 10[µT] $left(%torrentname,40) [: $+ $ut_convert_status( %status , %progress )  
  173.           var %temp1 = 10Downloaded:14  $+ $bytes( $regml(tor,6) ).suf :: Uploaded: $+ $bytes( $regml(tor,7) ).suf
  174.           var %temp2 = 10SIZE:14  $+ $bytes( $regml(tor,4) ).suf 10Total Complete:14 $+ $calc( %progress / 10) $+ $chr(37) 
  175.           var %temp3 = 10Upload Speed:14 $+ $bytes( $regml(tor,9) ).suf $+ /s76 
  176.           var %temp4 = 10Download Speed:14  $+ $bytes( $regml(tor,10) ).suf $+ /s 10Peers:14 $+ $regml(tor,13) $+ ( $+ $regml(tor,14) $+ )  10Seeds:14 $+ $regml(tor,15) $+ ( $+ $regml(tor,16) $+ ) 10ETA:14 $+ $duration( $regml(tor,11) ) 
  177.           msg %ut_activechan %temp
  178.           msg %ut_activechan %temp1
  179.           msg %ut_activechan %temp2
  180.           msg %ut_activechan %temp3
  181.           msg %ut_activechan %temp4
  182.         }
  183.         inc %ut_flood_count
  184.       }
  185.       elseif ( %ut_action == seeding && %progress == 1000 && $isbit(%status,1) == 1 && $isbit(%status,6) == 0 ) {
  186.         if ( %ut_flood_count < %ut_flood_max ) {
  187.           var %temp = 10[µT] $left(%torrentname,40)   
  188.           var %temp4 = 14Upload Speed:10 $+ $bytes( $regml(tor,9) ).suf $+ /s 14Peers:10 $+ $regml(tor,13) $+ ( $+ $regml(tor,14) $+ ) 14Seeders:10 $+ $regml(tor,15) $+ ( $+ $regml(tor,16) $+ )
  189.           msg %ut_activechan %temp
  190.           msg %ut_activechan %temp4
  191.         }
  192.         inc %ut_flood_count
  193.       }
  194.     }
  195.   }
  196.   unset %temp
  197. }
  198.  
  199. alias ut_getinfo_end {
  200.   sockclose ut_token
  201.   sockclose ut_info
  202.   if ( %ut_sockerr == 0 ) {
  203.     if ( %ut_action == find || %ut_action == downloading || %ut_action == seeding ) {
  204.       ;      msg %ut_activechan 12[µT] Found %ut_flood_count torrents.
  205.     }
  206.     if ( %ut_action == stats ) {
  207.       if ( %ut_err_torrents > 0 ) {
  208.         var %temp = 12[µT] Torrents: $calc( %ut_torrentcount + %ut_err_torrents ) (Seed: $+ %ut_seedingcount $+ , Leech: $+ %ut_downloadingcount $+ , Inactive: $+ $calc( %ut_torrentcount - %ut_seedingcount - %ut_downloadingcount ) $+ , Unknown: $+ %ut_err_torrents $+ ).  $bytes(%ut_download).suf $+ /s down, $bytes(%ut_upload).suf $+ /s up. Ratio: $round($calc($calc(%ut_ratio_sum / 1000) / %ut_torrentcount),2) Remaining: $bytes( %ut_remaining ).suf Downloaded: $bytes( %ut_downloaded ).suf Uploaded: $bytes( %ut_uploaded ).suf
  209.       }
  210.       else {
  211.         var %temp = 10[µT] Total Torrents:14 %ut_torrentcount (10Seeding:14 $+ %ut_seedingcount $+ , 10Leeching:14 $+ %ut_downloadingcount $+ , 10Inactive:14 $+ $calc( %ut_torrentcount - %ut_seedingcount - %ut_downloadingcount ) $+ )
  212.         var %temp1 = 10Download Speed Total:14 $bytes(%ut_download).suf $+ /s ,10Upload Speed Total:14 $bytes(%ut_upload).suf $+ /s up. 10Ratio:14 $round($calc($calc(%ut_ratio_sum / 1000) / %ut_torrentcount),2) , 10Total Remaining:14 $bytes( %ut_remaining ).suf , 10Total Downloaded:14 $bytes( %ut_downloaded ).suf , 10Total Uploaded:14 $bytes( %ut_uploaded ).suf 
  213.       }
  214.       msg %ut_activechan %temp
  215.       msg %ut_activechan %temp1
  216.     }
  217.   }
  218.   else {
  219.     ;    msg %ut_activechan 12[µT] Error: $sock($sockname).wsmsg
  220.  
  221.  
  222.   }
  223.   unset %ut*
  224.  
  225.   .timerut_getinfo_end off
  226. }
  227.  
  228. alias ut_convert_status {
  229.   if ( $1 isnum && $2 isnum ) {
  230.     if ( $isbit( $1, 1) == 1 ) {
  231.       if ( $isbit( $1, 6) == 1 ) {
  232.         return Paused
  233.       }
  234.       else {
  235.         if ( $isbit( $1, 7) == 1 ) {
  236.           if ( $2 == 1000 ) {
  237.             return Seeding
  238.           }
  239.           else {
  240.             return Downloading
  241.           }
  242.         }
  243.         else {
  244.           if ( $2 == 1000 ) {
  245.             return Seeding [F]
  246.           }
  247.           else {
  248.             return Downloading [F]
  249.           }
  250.         }
  251.       }
  252.     }
  253.     elseif ( $isbit( $1 , 2 ) == 1 ) {
  254.       return Checking
  255.     }
  256.     elseif ( $isbit( $1 , 5 ) == 1 ) {
  257.       return Error
  258.     }
  259.     elseif ( $isbit( $1 , 7 ) == 1 ) {
  260.       if ( $2 == 1000 ) {
  261.         return Queued Seeding
  262.       }
  263.       else {
  264.         return Queued
  265.       }
  266.     }
  267.     if ( $2 == 1000 ) {
  268.       return Finished
  269.     }
  270.     else {
  271.       return Stopped
  272.     }
  273.   }
  274.   return Invalid
  275. }
  276.  
  277. alias utstats {
  278.   ut_getinfo $chan stats
  279. }
  280. alias utdl {
  281.   ut_getinfo $chan downloading
  282. }
  283. alias utul {
  284.   ut_getinfo $chan seeding
  285. }
  286. alias utfind {
  287.   ut_getinfo $chan find $1-
  288. }
  289. alias uthelp {
  290.   echo Command -=- Workings (Make sure you have filled in the username, password, hostname and port of µtorrent in the script first)
  291.   echo /uthelp -=- Shows this info
  292.   echo /utstats -=- Shows overall µtorrent stats
  293.   echo /utdl -=- Shows torrents currently downloading
  294.   echo /utul -=- Shows torrents currently seeding
  295.   echo /utfind string -=- Shows torrents containing the string
  296.  
  297. }
  298. menu Channel,Status {
  299.   . Utorrent
  300.   .. Show Uploading: /utul
  301.   .. Show Downloading: /utdl
  302.   .. Show Stats: /utstats
  303.   .. Find: { .dialog -m Utorrent-GUI Utorrent-GUI }
  304. }
  305.  
  306. dialog Utorrent-GUI {
  307.   title "UTGUI"
  308.   size -1 -1 160 38
  309.   option dbu
  310.   text "Utorrent GUI By JoelP53", 2, 48 1 64 7, nowrap
  311.   button "Search", 1, 26 22 53 15, default multi ok
  312.   button "Cancel", 4, 84 22 53 15, cancel
  313.   edit "", 5, 28 10 105 10 autohs %result
  314. }
  315.  
  316. on *:dialog:Utorrent-GUI:sclick:1: {
  317.   var %result = $1-
  318.   /utfind %result
  319. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement