-- 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')..[=[ ライブラリ - EDCB ]=]) dirname=nil index=GetVarInt(mg.request_info.query_string,'i',1,#LIBRARY_LIST) if index then dir=DocumentToNativePath(LIBRARY_LIST[index]) if dir then dirhash=mg.get_var(mg.request_info.query_string,'d') if dirhash then for i,v in ipairs(edcb.FindFile(PathAppend(dir,'*'),0) or {}) do if v.isdir and mg.md5(v.name)==dirhash then dir=PathAppend(dir,v.name) dirname=LIBRARY_LIST[index]..'/'..v.name break end end else dirname=LIBRARY_LIST[index] end end end queryParent='' if not dirname then ct:Append('

ライブラリ

\n\n') else tsx=edcb.GetPrivateProfile('SET','TSExt','.ts','EpgTimerSrv.ini') xlist={tsx,table.unpack(MEDIA_EXTENSION_LIST)} hash=mg.get_var(mg.request_info.query_string,'h') if not hash then sort=mg.get_var(mg.request_info.query_string,'s') or 'dd' queryParent=dirhash and '?i='..index or '' ct:Append('

ライブラリ

\n\n') else xq=GetTranscodeQueries(mg.request_info.query_string) ct:Append('
\n') info=nil for i,v in ipairs(xlist) do for j,w in ipairs(edcb.FindFile(PathAppend(dir,'*'..v),0) or {}) do if not w.isdir and mg.md5(w.name)==hash then info=w info.ists=v==tsx break end end if info then break end end edcb.htmlEscape=15 if info then ref=dirname..'/'..info.name queryParent='?i='..index..(dirhash and '&d='..dirhash or '') if vtag==1 then ct:Append(VideoWrapperBegin() ..''..VideoWrapperEnd()..'\n'..VideoScriptTemplate()) else ct:Append('/'..EdcbHtmlEscape(ref) ..'\n[DL]') end if info.ists then fsec,fsize=0,0 f=edcb.io.open(PathAppend(dir,info.name),'rb') if f then fsec,fsize=GetDurationSec(f) f:close() end ct:Append(' ('..('%dm%02ds|'):format(math.floor(fsec/60),fsec%60)..math.floor(fsize/1048576)..'M)
\n' ..'
\n' ..(vtag==0 and '\n' or '\n' ..(dirhash and '\n' or '') ..'\n\n' ..'\n') ..'\n' ..'→Video' or '0">DL')..'\n' ..TranscodeSettingTemplate(xq,fsec) ..'
') if vtag==10 then src='xcode.lua?fname='..mg.url_encode(ref)..ConstructTranscodeQueries(xq) ct:Append('\n'..VideoWrapperBegin() ..(xq.tslive and '' or '') ..VideoWrapperEnd()..'\n' ..'\n'..TranscodeScriptTemplate(false,xq.caption,xq.jikkyo,{ofssec=fsec*(xq.offset or 0)/100,fast=xq.fast})) if xq.tslive then ct:Append(TsliveScriptTemplate()) elseif ALLOW_HLS then ct:Append(HlsScriptTemplate('xcode.lua')) end end else ct:Append((vtag~=1 and '\n[Mux-to-TS]' or '') ..' ('..math.floor(info.size/1048576)..'M)
\n') end end ct:Append('
\n') 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'))