sera que lo estoy haciendo mal ??
--[[ <HCExtension>
@name Youtube Guardado x Titulo (Marcado fullCache)(googlebot)
@author Komunitas Handycache Indonesia Edit JVProducciones Para IsP
@version 1.0.1
@rule ^.*youtube\.com.*
@rule ^.*/videoplayback.*
@rule youtube\.com/get_video_info\?
@event BeforeAnswerBodySend/videoname
@event URLToFileNameConverting/convert
@event AnswerHeaderReceived/nosave
@event RequestHeaderReceived/other
</HCExtension> ]]
function other()
if re.match(hc.url, [[^.*youtube\.com/watch\?.*\&spf=navigate]]) then
hc.action = 'stop'
hc.monitor_string = 'Bloqueado'
end
if re.match(hc.url, [[^.*(youtube|ytimg)\.com.*]]) then
hc.request_header = re.replace(hc.request_header, [[^User-Agent: \K[^\r\n]+]], 'Googlebot/2.1 (+http://www.googlebot.com/bot.html)')
hc.monitor_string = 'UserAgent Googlebot'
end
end
function nosave()
if re.match(hc.url, [[^.*/videoplayback\?.*]]) then
local sv = re.find(hc.answer_header, [[^HTTP/1\.1\s200\sOK]])
local dsv = re.find(hc.url, [[begin=(?!0)[0-9]+]])
if hc.method == 'GET' then
if sv and not dsv then
hc.action = 'save'
hc.monitor_string = 'Guardado'
else
hc.action = 'dont_save'
hc.monitor_string = 'No Guardado'
end
else
hc.action = 'dont_save'
hc.monitor_string = 'No Guardado'
end
if hc.cache_file_size >= 0 then
hc.answer_header = re.replace(hc.answer_header, [[^Server:\s\K[^\r\n]+]], 'HandyCache')
hc.action = 'dont_update'
hc.monitor_string = 'HIT'
end
end
end
function videoname()
if re.match(hc.url, [[.*youtube\.com\/watch]]) then
hc.update_url_info(hc.url)
local title = re.find(hc.url, [[v=.{11}]])
local title2 = re.replace(title, [[(v=)(.{11})]], [[\2]])
local x = re.match(hc.answer_body, [[<meta name="title" content="([^\n]*)">]])
if x then
local i=re.substr(1)
--local i= hc.recode(i, 65001, 1251)
local i = re.replace(i, [[([\\\/\:\*\?\!\"\<\>\|])]], '', true)
--hc.put_msg(30, 'jdul: \n',i)
local path = hc.cache_path ..'youtube.com\\temp\\'
hc.prepare_path(path)
local clr = io.open(path..title, "w")
clr:write(i)
clr:close()
end
hc.answer_body = string.gsub(hc.answer_body, 'videoplayback%%3F', 'videoplayback%%3Fpdo%%3D'..title2..'%%26')
hc.answer_body = string.gsub(hc.answer_body, '"dash": "1"', '"dash": "0"')
hc.answer_body = string.gsub(hc.answer_body, '"auto"', '"small"')
end
if re.match(hc.url, [[.*youtube\.com/get_video_info\?]]) then
local titlem = re.find(hc.url, [[&video_id=.{11}]])
local titlem2 = re.replace(titlem, [[(&video_id=)(.{11})]], [[\2]])
local x = re.match(hc.answer_body, [[title=([^&]*)]])
if x then
local i=re.substr(1)
local i = re.replace(i, [[([\\\/\:\*\?\!\"\<\>\|])]], '', true)
local i = re.replace(i, [[\+]], ' ', true)
--hc.put_msg(30, 'jdul: \n',i)
local path = hc.cache_path ..'youtube.com\\temp\\'
hc.prepare_path(path)
local clr = io.open(path..'v='..titlem2, "w")
clr:write(i)
clr:close()
end
--hc.answer_body = string.gsub(hc.answer_body, '%%26id%%3D', '%%26v%%3D'..title2..'%%26id%%3D')
hc.answer_body = string.gsub(hc.answer_body, 'videoplayback%%253F', 'videoplayback%%253Fpdo%%253D'..titlem2..'%%2526')
hc.answer_body = string.gsub(hc.answer_body, 'dash=1', 'dash=0')
hc.answer_body = string.gsub(hc.answer_body, 'vq=auto', 'vq=small')
hc.monitor_string = 'ytembed-ijk'
end
end
function convert()
if re.match(hc.url, [[^.*/videoplayback\?.*]]) then
local itag = re.find(hc.url, [[itag=[^&]+]])
local rg = re.find(hc.url, [[range=[^&]+]])
local id2 = re.find(hc.url, [[pdo=.{11}]])
local id = re.replace(id2, [[(pdo=)(.{11})]], [[v=\2]])
local path = hc.cache_path ..'youtube.com\\temp\\'
local idv = io.open(path..id, "r")
local idv2 = idv:read('*a')
if id and itag then
cache_file_iditag = hc.cache_path ..'youtube.com\\'..id..itag..'---'..idv2..'.flv'
hc.preform_cache_file_name(cache_file_iditag)
hc.monitor_string = 'video Entero'
end
if id and itag and rg then
cache_file_iditagrg = hc.cache_path ..'youtube.com\\'..id..'---'..idv2..'\\'..itag..rg
hc.preform_cache_file_name(cache_file_iditagrg)
hc.monitor_string = 'Parte del Video'
end
idv:close()
end
end