HC Youtube Saver by Bdstd.lua

Embed Size (px)

Citation preview

[[ @name Youtube Saver @author bdstd @version 1.0.1 @rule ^.*youtube\.com/videoplayback\?.* @event AnswerHeaderReceived/save @event URLToFileNameConverting/convert @event RequestHeaderReceived/block ]] function save() local pyt = re.match(hc.url, [[^.*youtube\.com/videoplayback\?.*]]) if pyt then local dsv = re.find(hc.url, [[begin=.*(?!0)]]) local dsv2 = re.find(hc.answer_header, [[^HTTP/1.+302.+Found]]) local prt206 = re.find(hc.answer_header, [[^HTTP/1.+206.+Partial.+Content]]) if not prt206 and not dsv and not dsv2 then hc.action = save hc.monitor_string = Saving end end end function convert() local pyt = re.match(hc.url, [[^.*youtube\.com/videoplayback\?.*]]) if pyt then local id = re.find(hc.url, [[id=[^&]+]]) local itag = re.find(hc.url, [[itag=[^&]+]]) local rg = re.find(hc.url, [[range=[^&]+]]) if id and itag then cache_file_iditag = hc.cache_path .. HCINTERNAL\\Youtube\\ ..id..itag.. .flv hc.preform_cache_file_name(cache_file_iditag) hc.monitor_string = YT-Non-Range-Converted end if id and itag and rg then cache_file_iditagrg = hc.cache_path .. HCINTERNAL\\Youtube\\ ..id.. \\ ..itag..rg hc.preform_cache_file_name(cache_file_iditagrg) hc.monitor_string = YT-Range-Converted end end end function block() local pyt = re.match(hc.url, [[^.*youtube\.com/videoplayback\?.*]]) if pyt then local itagx = re.find(hc.url, [[itag=(.{1}|.{2})\&]]) local rangex = re.find(hc.url, [[range=[^&]+]]) if itagx and rangex then hc.action = stop hc.monitor_string = Blocked By Extension end end end