Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ; type /uthelp for info
- alias ut_getinfo {
- ; Incarnation: 2010-03-04 17:00
- ; -============================ CHANGE THE VALUES BELOW ============================- ;
- ; the username for the webui:
- var %ut_username mirc
- ; the password for the webui:
- var %ut_password joanne
- ; the hostname or ip of the machine running µtorrent, if µtorrent + webui is running on the same computer leave it at localhost:
- set -n %ut_url localhost
- ; µtorrent port (or the alternative webui port if activated):
- set -n %ut_port 8080
- ; OPTIONAL! maximum number of displayed torrentlines (not counting header and footer):
- set %ut_flood_max 10
- ; -============================ CHANGE THE VALUES ABOVE ============================- ;
- 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 12[µT] Showing the first %ut_flood_max torrents containing $3-
- }
- elseif ( %ut_action == downloading ) {
- ; msg %ut_activechan 12[µT] Showing the first %ut_flood_max torrents downloading.
- }
- elseif ( %ut_action == seeding ) {
- ; msg %ut_activechan 12[µ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 %pattern = \["(\w*)",(\d*),"(.*)",(\d*),(\d*),(\d*),(\d*),(\d*),(\d*),(\d*),(-?\d*),"(.*)",(\d*),(\d*),(\d*),(\d*),(\d*),(-?\d*),(\d*)[\]|,]
- if ( $regex(tor,%temp,%pattern) == 1 ) {
- var %hash = $regml(tor,1)
- var %status $regml(tor,2)
- var %torrentname = $regml(tor,3)
- var %progress $regml(tor,5)
- var %label = $regml(tor,12)
- inc %ut_torrentcount
- inc %ut_remaining $regml(tor,19)
- inc %ut_download $regml(tor,10)
- inc %ut_upload $regml(tor,9)
- inc %ut_downloaded $regml(tor,6)
- inc %ut_uploaded $regml(tor,7)
- inc %ut_ratio_sum $regml(tor,8)
- 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 ) {
- var %temp = 10[µT]14 $left(%torrentname,40) 10Status:14 $+ $ut_convert_status( %status , %progress )
- 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) $+ )
- }
- else {
- var %temp = 10[µT]14 $left(%torrentname,40) 10Status:14 $+ $ut_convert_status( %status , %progress )
- 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) )
- }
- msg %ut_activechan %temp
- msg %ut_activechan %temp1
- }
- 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 ) {
- var %temp = 10[µT] $left(%torrentname,40) [: $+ $ut_convert_status( %status , %progress )
- var %temp1 = 10Downloaded:14 $+ $bytes( $regml(tor,6) ).suf :: Uploaded: $+ $bytes( $regml(tor,7) ).suf
- var %temp2 = 10SIZE:14 $+ $bytes( $regml(tor,4) ).suf 10Total Complete:14 $+ $calc( %progress / 10) $+ $chr(37)
- var %temp3 = 10Upload Speed:14 $+ $bytes( $regml(tor,9) ).suf $+ /s76
- 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) )
- msg %ut_activechan %temp
- msg %ut_activechan %temp1
- msg %ut_activechan %temp2
- msg %ut_activechan %temp3
- msg %ut_activechan %temp4
- }
- 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 ) {
- var %temp = 10[µT] $left(%torrentname,40)
- 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) $+ )
- msg %ut_activechan %temp
- msg %ut_activechan %temp4
- }
- inc %ut_flood_count
- }
- }
- }
- unset %temp
- }
- alias ut_getinfo_end {
- sockclose ut_token
- sockclose ut_info
- if ( %ut_sockerr == 0 ) {
- if ( %ut_action == find || %ut_action == downloading || %ut_action == seeding ) {
- ; msg %ut_activechan 12[µT] Found %ut_flood_count torrents.
- }
- if ( %ut_action == stats ) {
- if ( %ut_err_torrents > 0 ) {
- 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
- }
- else {
- 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 ) $+ )
- 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
- }
- msg %ut_activechan %temp
- msg %ut_activechan %temp1
- }
- }
- else {
- ; msg %ut_activechan 12[µT] Error: $sock($sockname).wsmsg
- }
- unset %ut*
- .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 Finished
- }
- else {
- return Stopped
- }
- }
- return Invalid
- }
- alias utstats {
- ut_getinfo $chan stats
- }
- alias utdl {
- ut_getinfo $chan downloading
- }
- alias utul {
- ut_getinfo $chan seeding
- }
- alias utfind {
- ut_getinfo $chan find $1-
- }
- alias uthelp {
- echo Command -=- Workings (Make sure you have filled in the username, password, hostname and port of µtorrent in the script first)
- echo /uthelp -=- Shows this info
- echo /utstats -=- Shows overall µtorrent stats
- echo /utdl -=- Shows torrents currently downloading
- echo /utul -=- Shows torrents currently seeding
- echo /utfind string -=- Shows torrents containing the string
- }
- menu Channel,Status {
- . Utorrent
- .. Show Uploading: /utul
- .. Show Downloading: /utdl
- .. Show Stats: /utstats
- .. Find: { .dialog -m Utorrent-GUI Utorrent-GUI }
- }
- dialog Utorrent-GUI {
- title "UTGUI"
- size -1 -1 160 38
- option dbu
- text "Utorrent GUI By JoelP53", 2, 48 1 64 7, nowrap
- button "Search", 1, 26 22 53 15, default multi ok
- button "Cancel", 4, 84 22 53 15, cancel
- edit "", 5, 28 10 105 10 autohs %result
- }
- on *:dialog:Utorrent-GUI:sclick:1: {
- var %result = $1-
- /utfind %result
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement