;; @module ushaper.lsp ;; @description simple uTorrent shaper ;; @author Cyril Slobin ;; @location http://slobin.pp.ru/newlisp/ushaper.lsp ;; @version $Id: ushaper.lsp,v 1.9 2010/05/09 14:56:42 slobin Exp $ ; TODO: http://forum.utorrent.com/viewtopic.php?pid=461130#p461130 ; You should customize the following settings. ; Try not to lose your parentheses balance! (setq ip "192.168.0.2") (setq port "49158") (setq user "athens") (setq pass "greece") (setq other-screen-saver "ssmarque.scr /s") (setq monitor-power-off nil) ; or true (setq idle '( (max_dl_rate 400) (max_ul_rate 50) (max_ul_rate_seed 70) )) (setq busy '( (max_dl_rate 285) (max_ul_rate 50) (max_ul_rate_seed 50) )) ; The customizable settings end here. Do not edit anything ; below this line! Or do, I don't care... (when (!= (main-args -1) "/s") (exit)) (setq HWND_BROADCAST 65535) (setq WM_SYSCOMMAND 274) (setq SC_MONITORPOWER 61808) (setq url-base (format "http://%s:%s/gui/" ip port)) (setq ticket (base64-enc (append user ":" pass))) (setq auth (format "Authorization: Basic %s\r\n" ticket)) (setq token-url (append url-base "token.html")) (setq token-regex {\]*\>([^<]*)\<\/div\>}) (define (pair arg) (format "&s=%s&v=%s" (string (arg 0)) (string (arg 1)))) (define (call-webapi arg , head tail) (setq $1 "oops") ; should fail (regex token-regex (get-url token-url 500 auth)) (setq head (format "?token=%s&action=setsetting" $1)) (setq tail (join (map pair arg))) (get-url (append url-base head tail) 500 auth)) (call-webapi idle) (when monitor-power-off (import "User32" "SendMessageA") (SendMessageA HWND_BROADCAST WM_SYSCOMMAND SC_MONITORPOWER 1)) (! other-screen-saver) (call-webapi busy) (exit)