airpwn

IDM Speed Limit (testing)

Oct 26th, 2016
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.77 KB | None | 0 0
  1. --[[ <HCExtension>
  2. @name    IDM Speed Limit (testing)
  3. @author  bdstd, Komunitas Handycache Indonesia
  4. @version testing
  5. @event  RequestHeaderReceived/Rikwes
  6. @event  Init/init
  7. </HCExtension> ]]
  8.  
  9. function init()
  10.     hc.put_msg(30, 'IDM Speed limit')
  11. end
  12.  
  13. function GetContentLength(s)
  14.   _,_,x = string.find(s, '[cC]ontent%-[lL]ength: *(%d+)')
  15.   if x==nil then return -1 else return tonumber(x) end
  16. end
  17.  
  18. function Rikwes()
  19.     if re.match(hc.request_header, [[^Range:\sbytes=.*\r\n]]) then
  20.         if hc.cache_file_name=='' then
  21.             hc.call_me_for('AnswerHeaderReceived', 'Limit')
  22.         end
  23.     end
  24. end
  25.  
  26. function Limit()
  27.     len = GetContentLength(hc.answer_header)  
  28.         if len > 102400 then
  29.             hc.file_speed_limit = 55000
  30.             hc.monitor_string = 'Limit IDM '
  31.         end
  32. end
Add Comment
Please, Sign In to add comment