Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ; para funcionar, vc tem que ativar o WEB UI
- ; ele fica no menu OPCOES, PREFERENCIAS, AVANCADO, do uTorrent
- ; Original version by iF
- ; Multiple IP Feature By SideshowBob
- ; -============================ CHANGE THE VALUES BELOW ============================- ;
- ;Multiple IPs function:
- ;Setup this aliase with the defaut access
- ;if webui is running on the same computer leave localhost in the IP
- ;alias .default { setip IP USERNAME PASSWORD PORT NAME }
- alias .default { setip IP USERNAME PASSWORD PORT NAME }
- ; -============================ CHANGE THE VALUES ABOVE ============================- ;
- alias ut_getinfo {
- ; maximum number of displayed torrentlines (not counting header and footer):
- set %ut_flood_max 7
- var %continue $false
- if ( $sock(ut_info).to ) {
- if ( $sock(ut_info).to > 25 ) {
- ut_getinfo_end
- %continue = $true
- }
- }
- else {
- %continue = $true
- }
- if ( %continue == $true && $1 && $2 ) {
- set %ut_activechan $1
- set %ut_action $2
- if ( %ut_action == find && $3 ) {
- set %ut_find_string $3-
- ; msg %ut_activechan 1[ %name ] Showing the first %ut_flood_max torrents containing $3-
- }
- elseif ( %ut_action == downloading ) {
- ; msg %ut_activechan 1[µT] Showing the first %ut_flood_max torrents downloading.
- }
- elseif ( %ut_action == seeding ) {
- ; msg %ut_activechan 1[µT] Showing the first %ut_flood_max torrents seeding.
- }
- set %ut_credentials $encode(%ut_username $+ : $+ %ut_password,m)
- set %ut_download 0
- set %ut_downloadingcount 0
- set %ut_err_torrents 0
- set %ut_flood_count 0
- set %ut_ratio_sum 0
- set %ut_remaining 0
- set %ut_seedingcount 0
- set %ut_sockerr 0
- set %ut_torrentcount 0
- set %ut_upload 0
- set %ut_downloaded
- set %ut_uploaded
- .timerut_getinfo_end 1 20 ut_getinfo_end
- sockopen ut_token %ut_url %ut_port
- }
- }
- on 1:SOCKOPEN:ut_token:{
- if ( $sockerr > 0 ) {
- %ut_sockerr = $sockerr
- ut_getinfo_end
- return
- }
- sockwrite -n $sockname GET /gui/token.html HTTP/1.1
- sockwrite -n $sockname Host: $+(%ut_url,:,%ut_port)
- sockwrite -n $sockname Authorization: Basic %ut_credentials
- sockwrite -n $sockname $crlf
- }
- on 1:SOCKREAD:ut_token:{
- if ( $sockerr > 0 ) {
- %ut_sockerr = $sockerr
- echo ow: $sockerr
- ut_getinfo_end
- return
- }
- var %i 1
- while (%i > 0 ) {
- sockread -f %temp
- if ( Set-Cookie: isin %temp ) {
- if ( $regex(ut_re_c,%temp,/GUID=([^; ]*)/) > 0 ) {
- set %ut_cookie $regml(ut_re_c,1)
- }
- }
- if ( $+(id,$chr(61),$chr(34),token,$chr(34)) isin %temp || $+(id,$chr(61),$chr(39),token,$chr(39)) isin %temp ) {
- if ( $regex(ut_re,%temp,/<div[^>]*id=["\']token["\'][^>]*>([^<]*)</div>/) > 0 ) {
- set %ut_token $regml(ut_re,1)
- sockopen ut_info %ut_url %ut_port
- sockclose ut_token
- }
- }
- %i = $sockbr
- }
- }
- on 1:SOCKOPEN:ut_info:{
- if ( $sockerr > 0 ) {
- %ut_sockerr = $sockerr
- ut_getinfo_end
- return
- }
- sockwrite -n $sockname GET /gui/?list=1&token= $+ %ut_token HTTP/1.1
- sockwrite -n $sockname Host: $+(%ut_url,:,%ut_port)
- sockwrite -n $sockname Cookie: GUID= $+ %ut_cookie
- sockwrite -n $sockname Authorization: Basic %ut_credentials
- sockwrite -n $sockname $crlf
- unset %ut_credentials
- unset %ut_url
- }
- on 1:SOCKREAD:ut_info:{
- if ( $sockerr > 0 ) {
- %ut_sockerr = $sockerr
- ut_getinfo_end
- return
- }
- sockread %temp
- if ( $left(%temp,12) == ,"torrentc": ) {
- ut_getinfo_end
- }
- else {
- var %temp2 = $mid( %temp , 2, $calc( $len( %temp ) - 3 ) )
- %temp2 = $replace(%temp2,\",`)
- if ( $numtok(%temp2,44) >= 19 ) {
- var %hash = $gettok(%temp2,1,34)
- var %torrentname = $gettok(%temp2,3,34)
- var %label
- if ( $numtok(%temp2,34) == 6 ) {
- %label = $gettok(%temp2,5,34)
- %temp2 = $replace(%temp2,%label,)
- }
- %temp2 = $replace(%temp2,%torrentname,,%hash,)
- %torrentname = $replace(%torrentname,`,")
- if ( $numtok(%temp2,44) == 19 ) {
- var %progress $gettok(%temp2,5,44)
- var %status $gettok(%temp2,2,44)
- inc %ut_remaining $gettok(%temp2,19,44)
- inc %ut_torrentcount
- inc %ut_download $gettok(%temp2,10,44)
- inc %ut_upload $gettok(%temp2,9,44)
- inc %ut_downloaded $gettok(%temp2,6,44)
- inc %ut_uploaded $gettok(%temp2,7,44)
- inc %ut_ratio_sum $gettok(%temp2,8,44)
- if ( $isbit(%status,1) == 1 && $isbit(%status,6) == 0 ) {
- if ( %progress == 1000 ) {
- inc %ut_seedingcount
- }
- else {
- inc %ut_downloadingcount
- }
- }
- if ( %ut_action == find ) {
- if ( %ut_find_string isin %torrentname ) {
- if ( %ut_flood_count < %ut_flood_max ) {
- if ( %progress == 1000 ) {
- /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) $+ )
- }
- else {
- /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) )
- }
- }
- inc %ut_flood_count
- }
- }
- elseif ( %ut_action == downloading && %progress < 1000 && $isbit(%status,1) == 1 && $isbit(%status,6) == 0) {
- if ( %ut_flood_count < %ut_flood_max ) {
- /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) )
- }
- inc %ut_flood_count
- }
- elseif ( %ut_action == seeding && %progress == 1000 && $isbit(%status,1) == 1 && $isbit(%status,6) == 0 ) {
- if ( %ut_flood_count < %ut_flood_max ) {
- /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) $+ )
- }
- inc %ut_flood_count
- }
- }
- else {
- inc %ut_err_torrents
- }
- }
- }
- }
- alias ut_getinfo_end {
- sockclose ut_info
- if ( %ut_sockerr == 0 ) {
- if ( %ut_action == find || %ut_action == downloading || %ut_action == seeding ) {
- ; msg %ut_activechan 1[ %name ] Found %ut_flood_count torrents.
- }
- if ( %ut_action == stats ) {
- if ( %ut_err_torrents > 0 ) {
- 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
- }
- else {
- 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
- }
- }
- }
- else {
- msg %ut_activechan 1[ %name ] Error: webui is not responding (socket error).
- }
- unset %ut_action
- unset %ut_activechan
- unset %ut_credentials
- unset %ut_download
- unset %ut_downloadingcount
- unset %ut_err_torrents
- unset %ut_find_string
- unset %ut_flood_max
- unset %ut_flood_count
- unset %ut_ratio_sum
- unset %ut_remaining
- unset %ut_seedingcount
- unset %ut_sockerr
- unset %ut_torrentcount
- unset %ut_url
- unset %ut_upload
- unset %temp
- unset %ut_url
- unset %ut_username
- unset %ut_password
- unset %ut_port
- unset %name
- unset %ut_cookie
- unset %ut_token
- .timerut_getinfo_end off
- }
- alias ut_convert_status {
- if ( $1 isnum && $2 isnum ) {
- if ( $isbit( $1, 1) == 1 ) {
- if ( $isbit( $1, 6) == 1 ) {
- return Paused
- }
- else {
- if ( $isbit( $1, 7) == 1 ) {
- if ( $2 == 1000 ) {
- return Seeding
- }
- else {
- return Downloading
- }
- }
- else {
- if ( $2 == 1000 ) {
- return Seeding [F]
- }
- else {
- return Downloading [F]
- }
- }
- }
- }
- elseif ( $isbit( $1 , 2 ) == 1 ) {
- return Checking
- }
- elseif ( $isbit( $1 , 5 ) == 1 ) {
- return Error
- }
- elseif ( $isbit( $1 , 7 ) == 1 ) {
- if ( $2 == 1000 ) {
- return Queued Seeding
- }
- else {
- return Queued
- }
- }
- if ( $2 == 1000 ) {
- return Finnished
- }
- else {
- return Stopped
- }
- }
- return Invalid
- }
- alias bw {
- ut_getinfo $chan stats
- }
- alias dl {
- ut_getinfo $chan downloading
- }
- alias ul {
- ut_getinfo $chan seeding
- }
- alias find {
- ut_getinfo $chan find $1-
- }
- on *:INPUT:*:{
- if ( $1 == .bw ) {
- if ( $2 ) { $2 | if ( %name ) { ut_getinfo $chan stats }
- else { //msg $chan uTorrent nao cadastrado: $2 }
- }
- else {
- .default
- ut_getinfo $chan stats
- }
- }
- elseif ( $1 == .dl ) {
- if ( $2 ) { $2 | if ( %name ) { ut_getinfo $chan downloading }
- else { //msg $chan uTorrent nao cadastrado: $2 }
- }
- else {
- .default
- ut_getinfo $chan downloading
- }
- }
- elseif ( $1 == .ul ) {
- if ( $2 ) { $2 | if ( %name ) { ut_getinfo $chan seeding }
- else { //msg $chan uTorrent nao cadastrado: $2 }
- }
- else {
- .default
- ut_getinfo $chan seeding
- }
- }
- elseif ( $1 == .find ) {
- if ( $2 ) { $2 | if ( %name ) { ut_getinfo $chan find $3- }
- else { //msg $chan uTorrent nao cadastrado: $2 }
- }
- else {
- .default
- ut_getinfo $chan find $2-
- }
- }
- }
- 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