Code:
; type /uthelp for info
alias ut_getinfo {
; -============================ CHANGE THE VALUES BELOW ============================- ;
; the username for the webui:
var %ut_username (Name)
; the password for the webui:
var %ut_password (Password)
; the hostname or ip of the machine running µtorrent, if µtorrent + webui is running on the same computer leave it at localhost:
set %ut_url (Location... Dynamic DNS address will work)
; µtorrent port (or the alternative webui port if activated):
var %ut_port (Port)
; OPTIONAL! maximum number of displayed torrentlines (not counting header and footer):
set %ut_flood_max 5
; -============================ CHANGE THE VALUES ABOVE ============================- ;
var %continue
if ( (ut_info).to ) {
if ( (ut_info).to > 25 ) {
ut_getinfo_end
%continue =
}
}
else {
%continue =
}
if ( %continue == && $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 (%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
timerut_getinfo_end 1 20 ut_getinfo_end
sockopen ut_info %ut_url %ut_port
}
}
on 1:SOCKOPEN:ut_info:{
if ( > 0 ) {
%ut_sockerr =
ut_getinfo_end
return
}
sockwrite -n GET /gui/?list=1 HTTP/1.1
sockwrite -n Host: %ut_url
sockwrite -n Connection: Keep-Alive
sockwrite -n Authorization: Basic %ut_credentials
sockwrite -n
unset %ut_credentials
unset %ut_url
}
on 1:SOCKREAD:ut_info:{
if ( > 0 ) {
%ut_sockerr =
ut_getinfo_end
return
}
sockread %temp
if ( (%temp,12) == ,"torrentc": ) {
ut_getinfo_end
}
else {
var %temp2 = ( %temp , 2, ( ( %temp ) - 3 ) )
%temp2 = (%temp2,",`)
if ( (%temp2,44) >= 19 ) {
var %hash = (%temp2,1,34)
var %torrentname = (%temp2,3,34)
var %label
if ( (%temp2,34) == 6 ) {
%label = (%temp2,5,34)
%temp2 = (%temp2,%label,)
}
%temp2 = (%temp2,%torrentname,,%hash,)
%torrentname = (%torrentname,`,"
if ( (%temp2,44) == 19 ) {
var %progress (%temp2,5,44)
var %status (%temp2,2,44)
inc %ut_remaining (%temp2,19,44)
inc %ut_torrentcount
inc %ut_download (%temp2,10,44)
inc %ut_upload (%temp2,9,44)
inc %ut_ratio_sum (%temp2,8,44)
if ( (%status,1) == 1 && (%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 12[µT]14 (%torrentname,40) $+ ( %status , %progress ) UP: $+ ( (%temp2,7,44) ).suf SIZE: $+ ( (%temp2,4,44) ).suf R: $+ ( (%temp2,8,44) / 1000) UL: $+ ( (%temp2,9,44) ).suf $+ /s P: $+ (%temp2,13,44) $+ ( $+ (%temp2,14,44) $+ ) S: $+ (%temp2,15,44) $+ ( $+ (%temp2,16,44) $+ )
}
else {
/msg %ut_activechan 12[µT]14 (%torrentname,40) $+ ( %status , %progress ) DOWN: $+ ( (%temp2,6,44) ).suf SIZE: $+ ( (%temp2,4,44) ).suf P: $+ ( %progress / 10) $+ (37) DL: $+ ( (%temp2,10,44) ).suf $+ /s P: $+ (%temp2,13,44) $+ ( $+ (%temp2,14,44) $+ ) S: $+ (%temp2,15,44) $+ ( $+ (%temp2,16,44) $+ ) ETA: $+ ( (%temp2,11,44) )
}
}
inc %ut_flood_count
}
}
elseif ( %ut_action == downloading && %progress < 1000 && (%status,1) == 1 && (%status,6) == 0) {
if ( %ut_flood_count < %ut_flood_max ) {
/msg %ut_activechan 12[µT]14 (%torrentname,40) $+ ( %status , %progress ) DOWN: $+ ( (%temp2,6,44) ).suf SIZE: $+ ( (%temp2,4,44) ).suf P: $+ ( %progress / 10) $+ (37) DL: $+ ( (%temp2,10,44) ).suf $+ /s P: $+ (%temp2,13,44) $+ ( $+ (%temp2,14,44) $+ ) S: $+ (%temp2,15,44) $+ ( $+ (%temp2,16,44) $+ ) ETA: $+ ( (%temp2,11,44) )
}
inc %ut_flood_count
}
elseif ( %ut_action == seeding && %progress == 1000 && (%status,1) == 1 && (%status,6) == 0 ) {
if ( %ut_flood_count < %ut_flood_max ) {
/msg %ut_activechan 12[µT]14 (%torrentname,40) $+ ( %status , %progress ) UP: $+ ( (%temp2,7,44) ).suf SIZE: $+ ( (%temp2,4,44) ).suf R: $+ ( (%temp2,8,44) / 1000) UL: $+ ( (%temp2,9,44) ).suf $+ /s P: $+ (%temp2,13,44) $+ ( $+ (%temp2,14,44) $+ ) S: $+ (%temp2,15,44) $+ ( $+ (%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 12[µT] Found %ut_flood_count torrents.
}
if ( %ut_action == stats ) {
if ( %ut_err_torrents > 0 ) {
msg %ut_activechan 12[µT] Torrents: ( %ut_torrentcount + %ut_err_torrents ) (Seed: $+ %ut_seedingcount $+ , Leech: $+ %ut_downloadingcount $+ , Inactive: $+ ( %ut_torrentcount - %ut_seedingcount - %ut_downloadingcount ) $+ , Unknown: $+ %ut_err_torrents $+ ). (%ut_download).suf $+ /s down, (%ut_upload).suf $+ /s up. Ratio: (((%ut_ratio_sum / 1000) / %ut_torrentcount),2) Remaining: ( %ut_remaining ).suf
}
else {
msg %ut_activechan 12[µT] Torrents: %ut_torrentcount (Seed: $+ %ut_seedingcount $+ , Leech: $+ %ut_downloadingcount $+ , Inactive: $+ ( %ut_torrentcount - %ut_seedingcount - %ut_downloadingcount ) $+ ). (%ut_download).suf $+ /s down, (%ut_upload).suf $+ /s up. Ratio: (((%ut_ratio_sum / 1000) / %ut_torrentcount),2) Remaining: ( %ut_remaining ).suf
}
}
}
else {
msg %ut_activechan 12[µT] 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
timerut_getinfo_end off
}
alias ut_convert_status {
if ( $1 isnum && $2 isnum ) {
if ( ( $1, 1) == 1 ) {
if ( ( $1, 6) == 1 ) {
return Paused
}
else {
if ( ( $1, 7) == 1 ) {
if ( $2 == 1000 ) {
return Seeding
}
else {
return Downloading
}
}
else {
if ( $2 == 1000 ) {
return Seeding [F]
}
else {
return Downloading [F]
}
}
}
}
elseif ( ( $1 , 2 ) == 1 ) {
return Checking
}
elseif ( ( $1 , 5 ) == 1 ) {
return Error
}
elseif ( ( $1 , 7 ) == 1 ) {
if ( $2 == 1000 ) {
return Queued Seeding
}
else {
return Queued
}
}
if ( $2 == 1000 ) {
return Finnished
}
else {
return Stopped
}
}
return Invalid
}
alias utstats {
ut_getinfo stats
}
alias utdl {
ut_getinfo downloading
}
alias utul {
ut_getinfo seeding
}
alias utfind {
ut_getinfo 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
echo /utchan enable/disable -=- Enables/Disables the channel commands (eg: !utstats)
echo People in a channel can request your info using a ! instead of a / in the command (eg: !utstats)
}
alias utchan {
if ( $1 == enable ) {
unset %ut_perm_nochan
}
else {
set %ut_perm_nochan 1
}
}
on *:TEXT:!ut*:#:{
if ( %ut_perm_nochan != 1 ) {
if ( $1 == !utstats ) {
ut_getinfo stats
}
elseif ( $1 == !utdl ) {
ut_getinfo downloading
}
elseif ( $1 == !utul ) {
ut_getinfo seeding
}
elseif ( $1 == !utfind ) {
ut_getinfo find $2-
}
}
}
Bookmarks