-- vim:set ft=lua:
dofile(mg.script_name:gsub('[^\\/]*$','')..'util.lua')
vtag=GetVarInt(mg.request_info.query_string,'vtag') or -1
ct=CreateContentBuilder(GZIP_THRESHOLD_BYTE)
ct:Append((vtag<=0 and DOCTYPE_HTML4_STRICT or '\n')..[=[
]=])
focus=nil
post=AssertPost()
if post then
focus=edcb.GetReserveData(GetVarInt(post,'del') or 0)
if focus then
edcb.DelReserveData(focus.reserveID)
ct:Append('
削除しました
\n')
end
end
edcb.htmlEscape=15
a=edcb.GetReserveData()
if not focus then
focus=GetVarInt(mg.request_info.query_string,'id')
focus=focus and BinarySearch(a,{reserveID=focus},CompareFields('reserveID'))
end
table.sort(a, function(a,b) return os.time(a.startTime) < os.time(b.startTime) end)
pageCount=RESERVE_PAGE_COUNT
if focus then
--focusの行を含むページを探す
focusIndex=BinarySearchBound(a,focus,function(a,b) return os.time(a.startTime)
pageCount then
for i=math.max(page-1,1),math.min(math.max(page-1,1)+6,(#a+pageCount-1)/pageCount) do
pageNav=pageNav..(i-1==page and ((i-1)*pageCount+1)..'~ ' or ''..((i-1)*pageCount+1)..'~ ')
end
pageNav=(page==0 and '|<< ' or '|<< ')..pageNav
..(page==math.floor((#a-1)/pageCount) and '>>|' or '>>|\n')
end
ct:Append(pageNav)
ct:Append([=[
]=])
a={}
for i,v in ipairs(edcb.FindFile(SendTSTCPPipePath('*',0),0) or {}) do
n=v.name:match('^[^_]+_(%d+)_%d+')
if n then
a[#a+1]=n
end
end
if #a>0 then
n=mg.get_var(mg.request_info.query_string,'n') or a[1]
xq=GetTranscodeQueries(mg.request_info.query_string)
ct:Append('視聴 →
'..(vtag==0 and 'Video' or 'DL')..'\n'
..'
\n')
if vtag==1 then
for i,v in ipairs(a) do
if n==v then
src='view.lua?n='..v..ConstructTranscodeQueries(xq)..'&ctok='..CsrfToken('view.lua')
ct:Append(VideoWrapperBegin()
..(xq.tslive and '
' or
'
')
..VideoWrapperEnd()..'\n'
..'
'..src..'
\n'..TranscodeScriptTemplate(true,xq.caption,xq.jikkyo,{n=v}))
if xq.tslive then
ct:Append(TsliveScriptTemplate())
elseif ALLOW_HLS then
ct:Append(HlsScriptTemplate('view.lua'))
end
ct:Append('\n')
break
end
end
end
end
ct:Append([=[
]=])
ct:Finish()
mg.write(ct:Pop(Response(200,'text/html','utf-8',ct.len,ct.gzip)
..'Cross-Origin-Embedder-Policy: require-corp\r\n'
..'Cross-Origin-Opener-Policy: same-origin\r\n'
..'\r\n'))