reges007

YT limitter with redirect video

Jan 4th, 2015
682
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.85 KB | None | 0 0
  1. --[[ <HCExtension>
  2. @name youtube con limiter
  3. @author noscar
  4. @version 1
  5. @rule videoplayback
  6. @event RequestHeaderReceived/cek
  7. @event AnswerHeaderReceived/wawaw
  8. @event Init/init
  9. </HCExtension> ]]
  10.  
  11. function init()
  12. hc.put_msg(30, 'YOUTUBE LIMIT')
  13. local path = hc.cache_path ..'temp\\limit\\'
  14. hc.delete_file(path)
  15. end
  16.  
  17. function cek_file(s)
  18. local f=io.open(s,"r")
  19. if f~=nil then io.close(f) return true
  20. else return false
  21. end
  22. end
  23.  
  24.  
  25.  
  26. function cek ()
  27. local ip = hc.user_ip
  28. local path = hc.cache_path ..'temp\\limit\\'..ip
  29. local id = re.find(hc.url, [[&id=.*?&]])
  30. local id = re.replace(id, [[(&id=)(.*?)(&)]], [[\2]])
  31. if hc.method == 'GET' and hc.cache_file_name == '' then
  32. if cek_file(path) == false then
  33. hc.prepare_path(path)
  34. local clr = io.open(path, "w")
  35. clr:write(id)
  36. clr:close()
  37. hc.monitor_string = 'LIMIT'
  38. else
  39. local idv = io.open(path, "r")
  40. local idv2 = idv:read('*a')
  41.  
  42. if id ~= idv2 then
  43. -- hc.client_disconnect()
  44. local newurl = "http://www48.indowebster.com/cba0d1c40c249db6075a28eab19aebbb.mp4"
  45. hc.request_header = re.replace(hc.request_header, [[\AGET \K[^\r\n]+(?= HTTP/)]], newurl)
  46.  
  47. end
  48. idv:close()
  49. end
  50.  
  51. end
  52. end
  53.  
  54. function wawaw()
  55. if hc.cache_file_name == '' then
  56. hc.call_me_for('BeforeAnswerBodySend', 'ceki')
  57. end
  58. end
  59.  
  60. function ceki ()
  61. local ip = hc.user_ip
  62. local path = hc.cache_path ..'temp\\limit\\'..ip
  63. local id = re.find(hc.url, [[&id=.*?&]])
  64. local id = re.replace(id, [[(&id=)(.*?)(&)]], [[\2]])
  65.  
  66. if hc.client_connected == false or hc.last_part then
  67. local iv = io.open(path, "r")
  68. local iv2 = iv:read('*a')
  69. if id == iv2 then
  70. iv:close()
  71. --hc.put_msg(30, 'dooooooong')
  72. hc.delete_file(path)
  73. end
  74. end
  75. end
Advertisement
Add Comment
Please, Sign In to add comment