Advertisement
Guest User

Untitled

a guest
Jun 28th, 2017
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
mIRC 11.46 KB | None | 0 0
  1. ; para funcionar, vc tem que ativar o WEB UI
  2. ; ele fica no menu OPCOES, PREFERENCIAS, AVANCADO, do uTorrent
  3. ; Original version by iF
  4. ; Multiple IP Feature By SideshowBob
  5.  
  6. ; -============================ CHANGE THE VALUES BELOW ============================- ;
  7.  
  8. ;Multiple IPs function:
  9. ;Setup this aliase with the defaut access
  10. ;if webui is running on the same computer leave localhost in the IP
  11. ;alias .default { setip IP USERNAME PASSWORD PORT NAME }
  12.  
  13. alias .default { setip IP USERNAME PASSWORD PORT NAME }
  14.  
  15. ; -============================ CHANGE THE VALUES ABOVE ============================- ;
  16.  
  17. alias ut_getinfo {
  18.  
  19.   ; maximum number of displayed torrentlines (not counting header and footer):
  20.   set %ut_flood_max 7
  21.  
  22.   var %continue $false
  23.   if ( $sock(ut_info).to ) {
  24.     if ( $sock(ut_info).to > 25 ) {
  25.       ut_getinfo_end
  26.       %continue = $true
  27.     }
  28.   }
  29.   else {
  30.     %continue = $true
  31.   }
  32.   if ( %continue == $true && $1 && $2 ) {
  33.     set %ut_activechan $1
  34.     set %ut_action $2
  35.     if ( %ut_action == find && $3 ) {
  36.       set %ut_find_string $3-
  37.       ;      msg %ut_activechan 1[ %name ] Showing the first %ut_flood_max torrents containing $3-
  38.     }
  39.     elseif ( %ut_action == downloading ) {
  40.       ;      msg %ut_activechan 1[µT] Showing the first %ut_flood_max torrents downloading.
  41.     }
  42.     elseif ( %ut_action == seeding ) {
  43.       ;      msg %ut_activechan 1[µT] Showing the first %ut_flood_max torrents seeding.
  44.     }
  45.     set %ut_credentials $encode(%ut_username $+ : $+ %ut_password,m)
  46.     set %ut_download 0
  47.     set %ut_downloadingcount 0
  48.     set %ut_err_torrents 0
  49.     set %ut_flood_count 0
  50.     set %ut_ratio_sum 0
  51.     set %ut_remaining 0
  52.     set %ut_seedingcount 0
  53.     set %ut_sockerr 0
  54.     set %ut_torrentcount 0
  55.     set %ut_upload 0
  56.     set %ut_downloaded
  57.     set %ut_uploaded
  58.     .timerut_getinfo_end 1 20 ut_getinfo_end
  59.     sockopen ut_token %ut_url %ut_port
  60.   }
  61. }
  62.  
  63. on 1:SOCKOPEN:ut_token:{
  64.   if ( $sockerr > 0 ) {
  65.     %ut_sockerr = $sockerr
  66.     ut_getinfo_end
  67.     return
  68.   }
  69.   sockwrite -n $sockname GET /gui/token.html HTTP/1.1
  70.   sockwrite -n $sockname Host: $+(%ut_url,:,%ut_port)
  71.   sockwrite -n $sockname Authorization: Basic %ut_credentials
  72.   sockwrite -n $sockname $crlf
  73. }
  74.  
  75. on 1:SOCKREAD:ut_token:{
  76.   if ( $sockerr > 0 ) {
  77.     %ut_sockerr = $sockerr
  78.     echo ow: $sockerr
  79.     ut_getinfo_end
  80.     return
  81.   }
  82.   var %i 1
  83.   while (%i > 0 ) {
  84.     sockread -f %temp
  85.     if ( Set-Cookie: isin %temp ) {
  86.       if ( $regex(ut_re_c,%temp,/GUID=([^; ]*)/) > 0 ) {
  87.         set %ut_cookie $regml(ut_re_c,1)
  88.       }
  89.     }
  90.     if ( $+(id,$chr(61),$chr(34),token,$chr(34)) isin %temp || $+(id,$chr(61),$chr(39),token,$chr(39)) isin %temp ) {
  91.       if ( $regex(ut_re,%temp,/<div[^>]*id=["\']token["\'][^>]*>([^<]*)</div>/) > 0 ) {
  92.         set %ut_token $regml(ut_re,1)
  93.         sockopen ut_info %ut_url %ut_port
  94.         sockclose ut_token
  95.       }
  96.     }
  97.     %i = $sockbr
  98.   }
  99. }
  100.  
  101. on 1:SOCKOPEN:ut_info:{
  102.   if ( $sockerr > 0 ) {
  103.     %ut_sockerr = $sockerr
  104.     ut_getinfo_end
  105.     return
  106.   }
  107.   sockwrite -n $sockname GET /gui/?list=1&token= $+ %ut_token HTTP/1.1
  108.   sockwrite -n $sockname Host: $+(%ut_url,:,%ut_port)
  109.   sockwrite -n $sockname Cookie: GUID= $+ %ut_cookie
  110.   sockwrite -n $sockname Authorization: Basic %ut_credentials
  111.   sockwrite -n $sockname $crlf
  112.   unset %ut_credentials
  113.   unset %ut_url
  114. }
  115.  
  116. on 1:SOCKREAD:ut_info:{
  117.   if ( $sockerr > 0 ) {
  118.     %ut_sockerr = $sockerr
  119.     ut_getinfo_end
  120.     return
  121.   }
  122.   sockread %temp
  123.   if ( $left(%temp,12) == ,"torrentc": ) {
  124.     ut_getinfo_end
  125.   }
  126.   else {
  127.     var %temp2 = $mid( %temp , 2, $calc( $len( %temp ) - 3 )  )
  128.     %temp2 = $replace(%temp2,\",`)
  129.     if ( $numtok(%temp2,44) >= 19 ) {
  130.       var %hash = $gettok(%temp2,1,34)
  131.       var %torrentname = $gettok(%temp2,3,34)
  132.       var %label
  133.       if ( $numtok(%temp2,34) == 6 ) {
  134.         %label = $gettok(%temp2,5,34)
  135.         %temp2 = $replace(%temp2,%label,)
  136.       }
  137.       %temp2 = $replace(%temp2,%torrentname,,%hash,)
  138.       %torrentname = $replace(%torrentname,`,")
  139.       if ( $numtok(%temp2,44) == 19 ) {
  140.         var %progress $gettok(%temp2,5,44)
  141.         var %status $gettok(%temp2,2,44)
  142.         inc %ut_remaining $gettok(%temp2,19,44)
  143.         inc %ut_torrentcount
  144.         inc %ut_download $gettok(%temp2,10,44)
  145.         inc %ut_upload $gettok(%temp2,9,44)
  146.         inc %ut_downloaded $gettok(%temp2,6,44)
  147.         inc %ut_uploaded $gettok(%temp2,7,44)
  148.         inc %ut_ratio_sum $gettok(%temp2,8,44)
  149.         if ( $isbit(%status,1) == 1 && $isbit(%status,6) == 0 ) {
  150.           if ( %progress == 1000 ) {
  151.             inc %ut_seedingcount
  152.           }
  153.           else {
  154.             inc %ut_downloadingcount
  155.           }
  156.         }
  157.         if ( %ut_action == find ) {
  158.           if ( %ut_find_string isin %torrentname ) {
  159.             if ( %ut_flood_count < %ut_flood_max ) {
  160.               if ( %progress == 1000 ) {
  161.                 /msg %ut_activechan 1[ %name ]14 $left(%torrentname,40)  $+ $ut_convert_status( %status , %progress ) UP: $+ $bytes( $gettok(%temp2,7,44) ).suf SIZE: $+ $bytes( $gettok(%temp2,4,44) ).suf Ratio: $+ $calc( $gettok(%temp2,8,44) / 1000) UL: $+ $bytes( $gettok(%temp2,9,44) ).suf $+ /s P: $+ $gettok(%temp2,13,44) $+ ( $+ $gettok(%temp2,14,44) $+ ) S: $+ $gettok(%temp2,15,44) $+ ( $+ $gettok(%temp2,16,44) $+ )
  162.               }
  163.               else {
  164.                 /msg %ut_activechan 1[ %name ]14 $left(%torrentname,40)  $+ $ut_convert_status( %status , %progress ) DOWN: $+ $bytes( $gettok(%temp2,6,44) ).suf SIZE: $+ $bytes( $gettok(%temp2,4,44) ).suf Completed: $+ $calc( %progress / 10) $+ $chr(37) DL:04 $+ $bytes( $gettok(%temp2,10,44) ).suf $+ /s P: $+ $gettok(%temp2,13,44) $+ ( $+ $gettok(%temp2,14,44) $+ ) S: $+ $gettok(%temp2,15,44) $+ ( $+ $gettok(%temp2,16,44) $+ ) ETA: $+ $duration( $gettok(%temp2,11,44) )
  165.               }
  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.             /msg %ut_activechan 1[ %name ]14 $left(%torrentname,40)  $+ $ut_convert_status( %status , %progress ) DOWN: $+ $bytes( $gettok(%temp2,6,44) ).suf SIZE: $+ $bytes( $gettok(%temp2,4,44) ).suf Completed: $+ $calc( %progress / 10) $+ $chr(37) DL:04 $bytes( $gettok(%temp2,10,44) ).suf $+ /s P: $+ $gettok(%temp2,13,44) $+ ( $+ $gettok(%temp2,14,44) $+ ) S: $+ $gettok(%temp2,15,44) $+ ( $+ $gettok(%temp2,16,44) $+ ) ETA: $+ $duration( $gettok(%temp2,11,44) )
  173.           }
  174.           inc %ut_flood_count
  175.         }
  176.         elseif ( %ut_action == seeding && %progress == 1000 && $isbit(%status,1) == 1 && $isbit(%status,6) == 0 ) {
  177.           if ( %ut_flood_count < %ut_flood_max ) {
  178.             /msg %ut_activechan 1[ %name ]14 $left(%torrentname,40)  $+ $ut_convert_status( %status , %progress ) UP: $+ $bytes( $gettok(%temp2,7,44) ).suf SIZE: $+ $bytes( $gettok(%temp2,4,44) ).suf R: $+ $calc( $gettok(%temp2,8,44) / 1000) UL: $+ $bytes( $gettok(%temp2,9,44) ).suf $+ /s P: $+ $gettok(%temp2,13,44) $+ ( $+ $gettok(%temp2,14,44) $+ ) S: $+ $gettok(%temp2,15,44) $+ ( $+ $gettok(%temp2,16,44) $+ )
  179.           }
  180.           inc %ut_flood_count
  181.         }
  182.       }
  183.       else {
  184.         inc %ut_err_torrents
  185.       }
  186.     }
  187.   }
  188. }
  189.  
  190. alias ut_getinfo_end {
  191.   sockclose ut_info
  192.   if ( %ut_sockerr == 0 ) {
  193.     if ( %ut_action == find || %ut_action == downloading || %ut_action == seeding ) {
  194.       ;      msg %ut_activechan 1[ %name ] Found %ut_flood_count torrents.
  195.     }
  196.     if ( %ut_action == stats ) {
  197.       if ( %ut_err_torrents > 0 ) {
  198.         msg %ut_activechan 1[ %name ] Torrents: %ut_torrentcount (Seed: $+ %ut_seedingcount $+ , Leech: $+ %ut_downloadingcount $+ , Inactive: $+ $calc( %ut_torrentcount - %ut_seedingcount - %ut_downloadingcount ) $+ ).  $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 Total Downloaded: $bytes( %ut_downloaded ).suf Total Uploaded: $bytes( %ut_uploaded ).suf
  199.       }
  200.       else {
  201.         msg %ut_activechan 1[ %name ] Torrents: %ut_torrentcount (Seed: $+ %ut_seedingcount $+ , Leech: $+ %ut_downloadingcount $+ , Inactive: $+ $calc( %ut_torrentcount - %ut_seedingcount - %ut_downloadingcount ) $+ ).  $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 Total Downloaded: $bytes( %ut_downloaded ).suf Total Uploaded: $bytes( %ut_uploaded ).suf
  202.       }
  203.     }
  204.   }
  205.   else {
  206.     msg %ut_activechan 1[ %name ] Error: webui is not responding (socket error).
  207.   }
  208.   unset %ut_action
  209.   unset %ut_activechan
  210.   unset %ut_credentials
  211.   unset %ut_download
  212.   unset %ut_downloadingcount
  213.   unset %ut_err_torrents
  214.   unset %ut_find_string
  215.   unset %ut_flood_max
  216.   unset %ut_flood_count
  217.   unset %ut_ratio_sum
  218.   unset %ut_remaining
  219.   unset %ut_seedingcount
  220.   unset %ut_sockerr
  221.   unset %ut_torrentcount
  222.   unset %ut_url
  223.   unset %ut_upload
  224.   unset %temp
  225.   unset %ut_url
  226.   unset %ut_username
  227.   unset %ut_password
  228.   unset %ut_port
  229.   unset %name
  230.   unset %ut_cookie
  231.   unset %ut_token
  232.   .timerut_getinfo_end off
  233. }
  234.  
  235. alias ut_convert_status {
  236.   if ( $1 isnum && $2 isnum ) {
  237.     if ( $isbit( $1, 1) == 1 ) {
  238.       if ( $isbit( $1, 6) == 1 ) {
  239.         return Paused
  240.       }
  241.       else {
  242.         if ( $isbit( $1, 7) == 1 ) {
  243.           if ( $2 == 1000 ) {
  244.             return Seeding
  245.           }
  246.           else {
  247.             return Downloading
  248.           }
  249.         }
  250.         else {
  251.           if ( $2 == 1000 ) {
  252.             return Seeding [F]
  253.           }
  254.           else {
  255.             return Downloading [F]
  256.           }
  257.         }
  258.       }
  259.     }
  260.     elseif ( $isbit( $1 , 2 ) == 1 ) {
  261.       return Checking
  262.     }
  263.     elseif ( $isbit( $1 , 5 ) == 1 ) {
  264.       return Error
  265.     }
  266.     elseif ( $isbit( $1 , 7 ) == 1 ) {
  267.       if ( $2 == 1000 ) {
  268.         return Queued Seeding
  269.       }
  270.       else {
  271.         return Queued
  272.       }
  273.     }
  274.     if ( $2 == 1000 ) {
  275.       return Finnished
  276.     }
  277.     else {
  278.       return Stopped
  279.     }
  280.   }
  281.   return Invalid
  282. }
  283.  
  284. alias bw {
  285.   ut_getinfo $chan stats
  286. }
  287. alias dl {
  288.   ut_getinfo $chan downloading
  289. }
  290. alias ul {
  291.   ut_getinfo $chan seeding
  292. }
  293. alias find {
  294.   ut_getinfo $chan find $1-
  295. }
  296.  
  297. on *:INPUT:*:{
  298.   if ( $1 == .bw ) {
  299.     if ( $2 ) { $2 | if ( %name ) { ut_getinfo $chan stats }
  300.       else { //msg $chan uTorrent nao cadastrado: $2 }
  301.     }
  302.     else {
  303.       .default
  304.       ut_getinfo $chan stats
  305.     }
  306.   }
  307.   elseif ( $1 == .dl ) {
  308.     if ( $2 ) { $2 | if ( %name ) { ut_getinfo $chan downloading }
  309.       else { //msg $chan uTorrent nao cadastrado: $2 }
  310.     }
  311.     else {
  312.       .default
  313.       ut_getinfo $chan downloading
  314.     }
  315.   }
  316.   elseif ( $1 == .ul ) {
  317.     if ( $2 ) { $2 | if ( %name ) { ut_getinfo $chan seeding }
  318.       else { //msg $chan uTorrent nao cadastrado: $2 }
  319.     }
  320.     else {
  321.       .default
  322.       ut_getinfo $chan seeding
  323.     }
  324.   }
  325.   elseif ( $1 == .find ) {
  326.     if ( $2 ) { $2 | if ( %name ) { ut_getinfo $chan find $3- }
  327.       else { //msg $chan uTorrent nao cadastrado: $2 }
  328.     }
  329.     else {
  330.       .default
  331.       ut_getinfo $chan find $2-
  332.  
  333.     }
  334.   }
  335. }
  336.  
  337. alias setip { set %ut_url $1 | set %ut_username $2 | set %ut_password $3 | set %ut_port $4 | set %name $5 }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement