-- vim:set ft=lua: dofile(mg.script_name:gsub('[^\\/]*$','')..'util.lua') --<0:再生画面へのリンク, 0:DLリンク, 1:トランスコード再生画面, 2~3:直接再生画面(偶数:ローカルファイル再生) 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')..[=[ ]=]..DefaultHeadContents()..[=[ ライブラリ - 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={} for s in (mg.get_var(mg.request_info.query_string,'d') or ''):gmatch('[0-9a-f]+') do dirhash[#dirhash+1]=s end --3階層まで if #dirhash<=3 then dirname=LIBRARY_LIST[index] for i,v in ipairs(dirhash) do found=false for j,w in ipairs(edcb.FindFile(PathAppend(dir,'*'),0) or {}) do if w.isdir and not w.name:find('^%.') and mg.md5(w.name)==v then found=true dir=PathAppend(dir,w.name) dirname=dirname..'/'..w.name break end end if not found then dirname=nil break end end end end end thumbs={''} 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>0 and '?i='..index..(#dirhash>1 and '&d='..table.concat(dirhash,',',1,#dirhash-1) or '') 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>0 and '&d='..table.concat(dirhash,',') or '') if vtag==2 or vtag==3 then if vtag%2==0 then ct:Append('') end ct:Append(VideoWrapperBegin() ..''..VideoWrapperEnd()..'\n'..VideoScriptTemplate(info.ists)) else ct:Append((info.ists and '' or '') ..'/'..EdcbHtmlEscape(ref)..(info.ists and '' or '') ..'\n[OpenFile]' ..'\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) if vtag<=0 then thumbs=ThumbnailTemplate(f,fsec,fsize,ref) end 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>0 and '\n' or '') ..'\n\n' ..'\n') ..'\n' ..'→Video' or '0">DL')..'\n' ..TranscodeSettingTemplate(xq,vtag==0,fsec) ..(vtag==0 and '
※OpenFile用のファイルを作成するときは[TS-Live!以外][0m00s][x1.0]を選択してxcodeしてください\n' or '') ..'
'..thumbs[1]) if vtag==1 then src='xcode.lua?fname='..mg.url_encode(ref)..ConstructTranscodeQueries(xq) ct:Append('\n'..VideoWrapperBegin() ..(xq.tslive and '' or '') ..VideoWrapperEnd()..'\n'..TranscodeScriptTemplate(false,xq.caption,xq.jikkyo,{ofssec=fsec*(xq.offset or 0)/100,fast=xq.fast})) if xq.tslive then ct:Append(TsliveScriptTemplate(xq.autoCinema)) elseif ALLOW_HLS then ct:Append(HlsScriptTemplate('xcode.lua')) end end else ct:Append((vtag~=2 and vtag~=3 and '\n[Mux-to-TS]' or '') ..' ('..math.floor(info.size/1048576)..'M)
\n') end ct:Append([=[
]=]) end ct:Append('
\n') end end ct:Append([=[ ]=]) for i=2,#thumbs do ct:Append(thumbs[i]) 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'))