Guest User

Untitled

a guest
Dec 10th, 2017
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 11.58 KB | None | 0 0
  1.  
  2. alias ut_getinfo {
  3.  
  4. ; Incarnation: 2010-03-04 17:00
  5.  
  6. ; -============================ CHANGE THE VALUES BELOW ============================- ;
  7.  
  8. ; the username for the webui:
  9. var %ut_username admin
  10.  
  11. ; the password for the webui:
  12. var %ut_password admin
  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 5
  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 312[µT] Showing the first %ut_flood_max torrents containing $3-
  41. }
  42. elseif ( %ut_action == downloading ) {
  43. ; msg %ut_activechan 312[µ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 = 312[µT]14 $left(%torrentname,40) $+ $ut_convert_status( %status , %progress ) UP: $+ $bytes( $regml(tor,7) ).suf SIZE: $+ $bytes( $regml(tor,4) ).suf R: $+ $calc( $regml(tor,8) / 1000) UL: $+ $bytes( $regml(tor,9) ).suf $+ /s P: $+ $regml(tor,13) $+ ( $+ $regml(tor,14) $+ ) S: $+ $regml(tor,15) $+ ( $+ $regml(tor,16) $+ )
  158. }
  159. else {
  160. var %temp = 12[µT]14 $left(%torrentname,40) $+ $ut_convert_status( %status , %progress ) DOWN: $+ $bytes( $regml(tor,6) ).suf SIZE: $+ $bytes( $regml(tor,4) ).suf P: $+ $calc( %progress / 10) $+ $chr(37) DL: $+ $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) )
  161. }
  162. msg %ut_activechan %temp
  163. }
  164. inc %ut_flood_count
  165. }
  166. }
  167. elseif ( %ut_action == downloading && %progress < 1000 && $isbit(%status,1) == 1 && $isbit(%status,6) == 0) {
  168. if ( %ut_flood_count < %ut_flood_max ) {
  169. var %temp = 3 12[µT]14 $left(%torrentname,40) $+ $ut_convert_status( %status , %progress ) DOWN: $+ $bytes( $regml(tor,6) ).suf SIZE: $+ $bytes( $regml(tor,4) ).suf P: $+ $calc( %progress / 10) $+ $chr(37) DL: $+ $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) )
  170. msg %ut_activechan %temp
  171. }
  172. inc %ut_flood_count
  173. }
  174. elseif ( %ut_action == seeding && %progress == 1000 && $isbit(%status,1) == 1 && $isbit(%status,6) == 0 ) {
  175. if ( %ut_flood_count < %ut_flood_max ) {
  176. var %temp 312[µT]14 $left(%torrentname,40) $+ $ut_convert_status( %status , %progress ) UP: $+ $bytes( $regml(tor,7) ).suf SIZE: $+ $bytes( $regml(tor,4) ).suf R: $+ $calc( $regml(tor,8) / 1000) UL: $+ $bytes( $regml(tor,9) ).suf $+ /s P: $+ $regml(tor,13) $+ ( $+ $regml(tor,14) $+ ) S: $+ $regml(tor,15) $+ ( $+ $regml(tor,16) $+ )
  177. msg %ut_activechan %temp
  178. }
  179. inc %ut_flood_count
  180. }
  181. }
  182. }
  183. unset %temp
  184. }
  185.  
  186. alias ut_getinfo_end {
  187. sockclose ut_token
  188. sockclose ut_info
  189. if ( %ut_sockerr == 0 ) {
  190. if ( %ut_action == find || %ut_action == downloading || %ut_action == seeding ) {
  191. ; msg %ut_activechan 3,412[µT] Found %ut_flood_count torrents.
  192. }
  193. if ( %ut_action == stats ) {
  194. if ( %ut_err_torrents > 0 ) {
  195. var %temp = 312[µ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
  196. }
  197. else {
  198. var %temp = 312[µT] 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 Downloaded: $bytes( %ut_downloaded ).suf Uploaded: $bytes( %ut_uploaded ).suf
  199. }
  200. msg %ut_activechan %temp
  201. }
  202. }
  203. else {
  204. ; msg %ut_activechan 12[µT] Error: webui is not responding (socket error).
  205. }
  206. unset %ut_action
  207. unset %ut_activechan
  208. unset %ut_credentials
  209. unset %ut_download
  210. unset %ut_downloadingcount
  211. unset %ut_err_torrents
  212. unset %ut_find_string
  213. unset %ut_flood_max
  214. unset %ut_flood_count
  215. unset %ut_ratio_sum
  216. unset %ut_remaining
  217. unset %ut_seedingcount
  218. unset %ut_sockerr
  219. unset %ut_torrentcount
  220. unset %ut_url
  221. unset %ut_upload
  222. unset %temp
  223. unset %ut_cookie
  224. unset %ut_token
  225. unset %ut_uploaded
  226. unset %ut_downloaded
  227. unset %ut_port
  228. .timerut_getinfo_end off
  229. }
  230.  
  231. alias ut_convert_status {
  232. if ( $1 isnum && $2 isnum ) {
  233. if ( $isbit( $1, 1) == 1 ) {
  234. if ( $isbit( $1, 6) == 1 ) {
  235. return Paused
  236. }
  237. else {
  238. if ( $isbit( $1, 7) == 1 ) {
  239. if ( $2 == 1000 ) {
  240. return Seeding
  241. }
  242. else {
  243. return Downloading
  244. }
  245. }
  246. else {
  247. if ( $2 == 1000 ) {
  248. return Seeding [F]
  249. }
  250. else {
  251. return Downloading [F]
  252. }
  253. }
  254. }
  255. }
  256. elseif ( $isbit( $1 , 2 ) == 1 ) {
  257. return Checking
  258. }
  259. elseif ( $isbit( $1 , 5 ) == 1 ) {
  260. return Error
  261. }
  262. elseif ( $isbit( $1 , 7 ) == 1 ) {
  263. if ( $2 == 1000 ) {
  264. return Queued Seeding
  265. }
  266. else {
  267. return Queued
  268. }
  269. }
  270. if ( $2 == 1000 ) {
  271. return Finished
  272. }
  273. else {
  274. return Stopped
  275. }
  276. }
  277. return Invalid
  278. }
  279.  
  280. alias utstats {
  281. ut_getinfo $chan stats
  282. }
  283. alias utdl {
  284. ut_getinfo $chan downloading
  285. }
  286. alias utul {
  287. ut_getinfo $chan seeding
  288. }
  289. alias utfind {
  290. ut_getinfo $chan find $1-
  291. }
  292. alias uthelp {
  293. echo Command -=- Workings (Make sure you have filled in the username, password, hostname and port of µtorrent in the script first)
  294. echo /uthelp -=- Shows this info
  295. echo /utstats -=- Shows overall µtorrent stats
  296. echo /utdl -=- Shows torrents currently downloading
  297. echo /utul -=- Shows torrents currently seeding
  298. echo /utfind string -=- Shows torrents containing the string
  299. echo /utchan enable/disable -=- Enables/Disables the channel commands (disabled by default). (eg: !utstats)
  300. echo People in a channel can request your info using a ! instead of a / in the command (eg: !utstats)
  301.  
  302. }
  303. alias utchan {
  304. if ( $1 == enable ) {
  305. set %ut_perm_nochan_ $+ $chan 0
  306. echo uTorrent channel commands enabled for $chan
  307. }
  308. else {
  309. set %ut_perm_nochan_ $+ $chan 1
  310. echo uTorrent channel commands disabled for $chan
  311. }
  312. }
  313. on *:TEXT:!ut*:#:{
  314. if ( $eval( $var( ut_perm_nochan_ $+ $chan, 1 ), 2 ) == 0 ) {
  315. if ( $1 == !utstats ) {
  316. ut_getinfo $chan stats
  317. }
  318. elseif ( $1 == !utdl ) {
  319. ut_getinfo $chan downloading
  320. }
  321. elseif ( $1 == !utul ) {
  322. ut_getinfo $chan seeding
  323. }
  324. elseif ( $1 == !utfind ) {
  325. ut_getinfo $chan find $2-
  326. }
  327. }
  328. }
  329. ; -================================ RIGHT-CLICK MENU ===============================- ;
  330.  
  331. Menu Channel {
  332. -
  333. µTorrent
  334. .$iif($menu != Menu Channel,Stats): /utstats
  335. .$iif($menu != Menu Channel,Download): /utdl
  336. .$iif($menu != Menu Channel,Upload): /utul
  337. .$iif($menu != Menu Channel,Find): { /utfind $$?="Enter Search String" }
  338. .Channels
  339. ..$iif($menu != Menu Channel,Enable Channel): { /utchan enable }
  340. ..$iif($menu != Menu Channel,Disable Channel): { /utchan disable }
  341. .$iif($menu != Menu Channel,Help): /uthelp
  342. -
  343. }
Add Comment
Please, Sign In to add comment