Skip to content

Commit

Permalink
Legacy WebUI: xcode.luaを二重音声、デュアルモノ、逆テレシネに対応
Browse files Browse the repository at this point in the history
  • Loading branch information
xtne6f committed Aug 22, 2020
1 parent cbbb077 commit d84d94a
Show file tree
Hide file tree
Showing 6 changed files with 176 additions and 64 deletions.
33 changes: 27 additions & 6 deletions ini/HttpPublic/legacy/epglist.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

ct=CreateContentBuilder(GZIP_THRESHOLD_BYTE)
ct:Append([=[
<!DOCTYPE HTML]=]..(vtag<0 and ' PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"' or '')..[=[>
<!DOCTYPE HTML]=]..(vtag<=0 and ' PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"' or '')..[=[>
<html lang="ja">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
Expand Down Expand Up @@ -106,13 +106,34 @@ <h1>リスト番組表</h1>
<form method="POST" action="view.lua"><div>
<input type="hidden" name="ctok" value="]=]..CsrfToken('view.lua')..[=[">
<input type="hidden" name="n" value="0">
<input type="hidden" name="s" value="]=]..onid..'-'..tsid..'-'..sid..[=[">
<input type="submit" value="view.lua -nwtv0]=]..(sid==0 and ' -term' or '')..[=[">
<input type="hidden" name="id" value="0-0-0">
<input type="submit" value="view.lua -nwtv0 -term">
</div></form>]=])
else
ct:Append((vtag==0 and ' <video autoplay controls src="' or ' <a href="')
..'view.lua?ctok='..CsrfToken('view.lua')..'&amp;n=0&amp;s='..onid..'-'..tsid..'-'..sid..'">view.lua -nwtv0'
..(vtag==0 and '</video>' or '</a> <a href="epglist.html?id='..onid..'-'..tsid..'-'..sid..'&amp;vtag=0#footer">(video)</a>'))
audio2=GetVarInt(mg.request_info.query_string,'audio2')==1
dual=GetVarInt(mg.request_info.query_string,'dual',0,2)
cinema=GetVarInt(mg.request_info.query_string,'cinema')==1
ct:Append('視聴 →<a href="epglist.html?id='..onid..'-'..tsid..'-'..sid
..(audio2 and '&amp;audio2=1' or '')..(dual and '&amp;dual='..dual or '')..(cinema and '&amp;cinema=1' or '')
..'&amp;vtag='..(vtag==0 and '-1#footer">Video' or '0#footer">DL')..'</a>\n'
..'<form method="GET" action="'..(vtag==0 and 'view.lua' or 'epglist.html#footer')..'"><div>\n'
..'<input type="submit" value="view.lua -nwtv0">\n'
..'<input type="checkbox" name="audio2" value="1"'..(audio2 and ' checked' or '')..'>audio2\n'
..'<select name="dual">'
..'<option value="0"'..(dual~=1 and dual~=2 and ' selected' or '')..'>*'
..'<option value="1"'..(dual==1 and ' selected' or '')..'>dual-main'
..'<option value="2"'..(dual==2 and ' selected' or '')..'>dual-sub'
..'</select>\n'
..'<input type="checkbox" name="cinema" value="1"'..(cinema and ' checked' or '')..'>cinema\n'
..'<input type="hidden" name="id" value="'..onid..'-'..tsid..'-'..sid..'">\n'
..(vtag==0 and '<input type="hidden" name="n" value="0">\n<input type="hidden" name="ctok" value="'..CsrfToken('view.lua')..'">\n'
or '<input type="hidden" name="vtag" value="1">\n')
..'</div></form>')
if vtag==1 then
ct:Append('\n<video autoplay controls style="max-width:95%" src="view.lua?n=0&amp;id='..onid..'-'..tsid..'-'..sid
..(audio2 and '&amp;audio2=1' or '')..(dual and '&amp;dual='..dual or '')..(cinema and '&amp;cinema=1' or '')
..'&amp;ctok='..CsrfToken('view.lua')..'">view.lua -nwtv0</video>')
end
end
ct:Append([=[
Expand Down
42 changes: 32 additions & 10 deletions ini/HttpPublic/legacy/recinfodesc.html
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
-- vim:set ft=lua:
dofile(mg.script_name:gsub('[^\\/]*$','')..'util.lua')

vtag=GetVarInt(mg.request_info.query_string,'vtag') or 0
vtag=GetVarInt(mg.request_info.query_string,'vtag') or -1

ct=CreateContentBuilder(GZIP_THRESHOLD_BYTE)
ct:Append([=[
<!DOCTYPE HTML]=]..(vtag==0 and ' PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"' or '')..[=[>
<!DOCTYPE HTML]=]..(vtag<=0 and ' PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"' or '')..[=[>
<html lang="ja">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
Expand All @@ -19,6 +19,10 @@ <h1>録画済み詳細</h1>
]=])

id=GetVarInt(mg.request_info.query_string,'id') or 0
offset=GetVarInt(mg.request_info.query_string,'offset',0,100)
audio2=GetVarInt(mg.request_info.query_string,'audio2')==1
dual=GetVarInt(mg.request_info.query_string,'dual',0,2)
cinema=GetVarInt(mg.request_info.query_string,'cinema')==1

post=AssertPost()
if post then
Expand Down Expand Up @@ -52,28 +56,46 @@ <h1>録画済み詳細</h1>
..' <dt>結果</dt><dd>'..v.comment..'</dd>\n'
..' <dt>ドロップ</dt><dd>'..v.drops..'</dd>\n'
..' <dt>スクランブル</dt><dd>'..v.scrambles..'</dd>\n'
..' <dt>ファイル →<a href="recinfodesc.html?id='..v.id..(vtag==0 and '&amp;vtag=-1">Video' or '">DL')..'</a></dt><dd>\n')
..' <dt>ファイル →<a href="recinfodesc.html?id='..v.id..(offset and '&amp;offset='..offset or '')..(audio2 and '&amp;audio2=1' or '')
..(dual and '&amp;dual='..dual or '')..(cinema and '&amp;cinema=1' or '')..'&amp;vtag='..(vtag==0 and '-1">Video' or '0">DL')..'</a></dt><dd>\n')
ref=w and NativeToDocumentPath(w.recFilePath)
if ref then
for i,ext in ipairs({'.mp4','.webm',''}) do
ff=edcb.FindFile and edcb.FindFile(w.recFilePath..ext,1)
if ff then
ct:Append((vtag==i and '<video autoplay controls src="' or '<a href="')
ct:Append((vtag==i and '<video autoplay controls style="max-width:95%" src="' or '<a href="')
..(vtag~=0 and vtag~=i and 'recinfodesc.html?id='..v.id..'&amp;vtag='..i or PathToRoot()..mg.url_encode(ref..ext):gsub('%%2f','/'))
..'">/'..EdcbHtmlEscape(ref..ext)..(vtag==i and '</video>' or '</a>'))
if ext=='' then
for j=0,9 do
ct:Append('\n'..(j==0 and '[' or '')..(vtag==j+10 and '<br><video autoplay controls src="' or '<a href="')
..(vtag~=0 and vtag~=j+10 and 'recinfodesc.html?id='..v.id..'&amp;vtag='..(j+10) or 'xcode.lua?'..(j*10)..'='..mg.url_encode(ref))
..'">'..(j==0 and 'xcode.lua' or j)..(vtag==j+10 and '</video>' or '</a>'))
end
fsec,fsize=0,0
f=edcb.io.open(w.recFilePath,'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)<br>\n')
ct:Append(' ('..('%dm%02ds|'):format(math.floor(fsec/60),fsec%60)..math.floor(fsize/1048576)..'M)<br>\n'
..'<form method="GET" action="'..(vtag==0 and 'xcode.lua' or 'recinfodesc.html')..'"><div>\n'
..(vtag==0 and '<input type="hidden" name="fname" value="'..EdcbHtmlEscape(ref)..'">\n'
or '<input type="hidden" name="id" value="'..v.id..'">\n<input type="hidden" name="vtag" value="10">\n')
..'<input type="submit" value="xcode.lua">\n'
..'offset: <select name="offset">')
for j=0,95,5 do
ct:Append('<option value="'..j..'"'..((offset or 0)==j and ' selected' or '')..'>'
..(fsec>0 and ('%dm%02ds|'):format(math.floor(fsec*j/100/60),fsec*j/100%60) or '')..j..'%')
end
ct:Append('</select>\n'
..'<input type="checkbox" name="audio2" value="1"'..(audio2 and ' checked' or '')..'>audio2\n'
..'<select name="dual">'
..'<option value="0"'..(dual~=1 and dual~=2 and ' selected' or '')..'>*'
..'<option value="1"'..(dual==1 and ' selected' or '')..'>dual-main'
..'<option value="2"'..(dual==2 and ' selected' or '')..'>dual-sub'
..'</select>\n'
..'<input type="checkbox" name="cinema" value="1"'..(cinema and ' checked' or '')..'>cinema\n'
..'</div></form>')
if vtag==10 then
ct:Append('\n<video autoplay controls style="max-width:95%" src="xcode.lua?fname='..mg.url_encode(ref)..(offset and '&amp;offset='..offset or '')
..(audio2 and '&amp;audio2=1' or '')..(dual and '&amp;dual='..dual or '')..(cinema and '&amp;cinema=1' or '')..'">xcode.lua</video>')
end
else
ct:Append(' ('..math.floor(ff[1].size/1048576)..'M)<br>\n')
end
Expand Down
53 changes: 46 additions & 7 deletions ini/HttpPublic/legacy/reserve.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

ct=CreateContentBuilder(GZIP_THRESHOLD_BYTE)
ct:Append([=[
<!DOCTYPE HTML]=]..(vtag<0 and ' PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"' or '')..[=[>
<!DOCTYPE HTML]=]..(vtag<=0 and ' PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"' or '')..[=[>
<html lang="ja">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
Expand Down Expand Up @@ -76,17 +76,56 @@ <h1>予約一覧</h1>
ct:Append([=[
</div>
<div class="aside">
view.lua]=])
for i,v in ipairs(edcb.FindFile and edcb.FindFile('\\\\.\\pipe\\SendTSTCP_*',0) or {}) do
]=])
a={}
for i,v in ipairs(edcb.FindFile('\\\\.\\pipe\\SendTSTCP_*',0) or {}) do
n=v.name:match('^[^_]+_(%d+)_%d+$')
if n then
ct:Append((vtag..''==n and ' <video autoplay controls src="' or ' <a href="')
..'view.lua?ctok='..CsrfToken('view.lua')..'&amp;n='..n..'">-pipe'..n
..(vtag..''==n and '</video>' or '</a> <a href="reserve.html?vtag='..n..'#footer">(video)</a>'))
a[#a+1]=n
end
end
if #a>0 then
n=mg.get_var(mg.request_info.query_string,'fname') or a[1]
audio2=GetVarInt(mg.request_info.query_string,'audio2')==1
dual=GetVarInt(mg.request_info.query_string,'dual',0,2)
cinema=GetVarInt(mg.request_info.query_string,'cinema')==1
ct:Append('視聴 →<a href="reserve.html?vtag='..(vtag==0 and '-1' or '0')
..(audio2 and '&amp;audio2=1' or '')..(dual and '&amp;dual='..dual or '')..(cinema and '&amp;cinema=1' or '')
..'#footer">'..(vtag==0 and 'Video' or 'DL')..'</a>\n'
..'<form method="GET" action="'..(vtag==0 and 'view.lua' or 'reserve.html#footer')..'"><div>\n'
..'<input type="submit" value="view.lua">\n'
..'<select name="n">')
for i,v in ipairs(a) do
ct:Append('<option value="'..v..'"'..(n==v and ' selected' or '')..'>-pipe'..v)
end
ct:Append('</select>\n'
..'<input type="checkbox" name="audio2" value="1"'..(audio2 and ' checked' or '')..'>audio2\n'
..'<select name="dual">'
..'<option value="0"'..(dual~=1 and dual~=2 and ' selected' or '')..'>*'
..'<option value="1"'..(dual==1 and ' selected' or '')..'>dual-main'
..'<option value="2"'..(dual==2 and ' selected' or '')..'>dual-sub'
..'</select>\n'
..'<input type="checkbox" name="cinema" value="1"'..(cinema and ' checked' or '')..'>cinema\n'
..(vtag==0 and '<input type="hidden" name="ctok" value="'..CsrfToken('view.lua')..'">\n'
or '<input type="hidden" name="vtag" value="1">\n')
..'</div></form>\n')
if vtag==1 then
for i,v in ipairs(a) do
if n==v then
ct:Append('<video autoplay controls style="max-width:95%" src="view.lua?n='..v
..(audio2 and '&amp;audio2=1' or '')..(dual and '&amp;dual='..dual or '')..(cinema and '&amp;cinema=1' or '')
..'&amp;ctok='..CsrfToken('view.lua')..'">view.lua</video>\n')
break
end
end
end
end
ct:Append([=[
<a href="view.lua?ctok=]=]..CsrfToken('view.lua')..[=[&amp;n=-1">-term</a>
<form method="POST" action="view.lua"><div>
<input type="hidden" name="ctok" value="]=]..CsrfToken('view.lua')..[=[">
<input type="hidden" name="n" value="-1">
<input type="submit" value="view.lua -term">
</div></form>
</div>
<div id="footer">
<a href="index.html">メニュー</a>
Expand Down
52 changes: 36 additions & 16 deletions ini/HttpPublic/legacy/reserveinfo.html
Original file line number Diff line number Diff line change
Expand Up @@ -73,11 +73,11 @@
return false
end

vtag=GetVarInt(mg.request_info.query_string,'vtag') or 0
vtag=GetVarInt(mg.request_info.query_string,'vtag') or -1

ct=CreateContentBuilder(GZIP_THRESHOLD_BYTE)
ct:Append([=[
<!DOCTYPE HTML]=]..(vtag==0 and ' PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"' or '')..[=[>
<!DOCTYPE HTML]=]..(vtag<=0 and ' PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"' or '')..[=[>
<html lang="ja">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
Expand All @@ -91,6 +91,10 @@ <h1>予約詳細</h1>
]=])

id=GetVarInt(mg.request_info.query_string,'id') or 0
offset=GetVarInt(mg.request_info.query_string,'offset',0,100)
audio2=GetVarInt(mg.request_info.query_string,'audio2')==1
dual=GetVarInt(mg.request_info.query_string,'dual',0,2)
cinema=GetVarInt(mg.request_info.query_string,'cinema')==1

post=AssertPost()
if post then
Expand All @@ -110,36 +114,52 @@ <h1>予約詳細</h1>
epgInfo=ConvertEpgInfoText2(r.onid, r.tsid, r.sid, r.eid)
dur=r.startTime.hour*3600+r.startTime.min*60+r.startTime.sec+r.durationSecond
ct:Append(' <dl>\n'
..' <dt>番組情報</dt><dd>'..(#epgInfo>0 and '\n'..string.gsub(epgInfo, '\r?\n', '<br>\n')
..' <dt>番組情報</dt><dd>'..(#epgInfo>0 and '\n'..epgInfo:gsub('\r?\n','<br>\n')
or FormatTimeAndDuration(r.startTime, r.durationSecond)..'<br>'..r.stationName..'<br>'..r.title..'<br><br>'
..string.format('OriginalNetworkID:%d(0x%04X)<br>', r.onid, r.onid)
..string.format('TransportStreamID:%d(0x%04X)<br>', r.tsid, r.tsid)
..string.format('ServiceID:%d(0x%04X)<br>', r.sid, r.sid)
..('OriginalNetworkID:%d(0x%04X)<br>'):format(r.onid,r.onid)
..('TransportStreamID:%d(0x%04X)<br>'):format(r.tsid,r.tsid)
..('ServiceID:%d(0x%04X)<br>'):format(r.sid,r.sid)
)..'</dd>\n'
..' <dt>ファイル →<a href="reserveinfo.html?id='..r.reserveID..(vtag==0 and '&amp;vtag=-1">Video' or '">DL')..'</a></dt><dd>\n')
..' <dt>ファイル →<a href="reserveinfo.html?id='..r.reserveID..(offset and '&amp;offset='..offset or '')..(audio2 and '&amp;audio2=1' or '')
..(dual and '&amp;dual='..dual or '')..(cinema and '&amp;cinema=1' or '')..'&amp;vtag='..(vtag==0 and '-1">Video' or '0">DL')..'</a></dt><dd>\n')
ref=recFilePath and NativeToDocumentPath(recFilePath)
if ref then
for i,ext in ipairs({'.mp4','.webm',''}) do
ff=edcb.FindFile and edcb.FindFile(recFilePath..ext,1)
if ff then
ct:Append((vtag==i and '<video autoplay controls src="' or '<a href="')
ct:Append((vtag==i and '<video autoplay controls style="max-width:95%" src="' or '<a href="')
..(vtag~=0 and vtag~=i and 'reserveinfo.html?id='..r.reserveID..'&amp;vtag='..i or PathToRoot()..mg.url_encode(ref..ext):gsub('%%2f','/'))
..'">/'..EdcbHtmlEscape(ref..ext)..(vtag==i and '</video>' or '</a>'))
if ext=='' then
for j=0,9 do
ct:Append('\n'..(j==0 and '[' or '')..(vtag==j+10 and '<br><video autoplay controls src="' or '<a href="')
..(vtag~=0 and vtag~=j+10 and 'reserveinfo.html?id='..r.reserveID..'&amp;vtag='..(j+10) or 'xcode.lua?'..(j*10)..'='..mg.url_encode(ref))
..'">'..(j==0 and 'xcode.lua' or j)..(vtag==j+10 and '</video>' or '</a>'))
end
fsec,fsize=0,0
f=edcb.io.open(recFilePath,'rb')
if f then
fsec,fsize=GetDurationSec(f)
f:close()
end
ct:Append('\n'..(vtag==99 and '<br><video autoplay controls src="' or '<a href="')
..(vtag~=0 and vtag~=99 and 'reserveinfo.html?id='..r.reserveID..'&amp;vtag=99' or 'xcode.lua?99='..mg.url_encode(ref))
..'">('..('%dm%02ds|'):format(math.floor(fsec/60),fsec%60)..math.floor(fsize/1048576)..'M)'..(vtag==99 and '</video>' or '</a>')..']<br>\n')
ct:Append(' ('..('%dm%02ds|'):format(math.floor(fsec/60),fsec%60)..math.floor(fsize/1048576)..'M)<br>\n'
..'<form method="GET" action="'..(vtag==0 and 'xcode.lua' or 'reserveinfo.html')..'"><div>\n'
..(vtag==0 and '<input type="hidden" name="fname" value="'..EdcbHtmlEscape(ref)..'">\n'
or '<input type="hidden" name="id" value="'..r.reserveID..'">\n<input type="hidden" name="vtag" value="10">\n')
..'<input type="submit" value="xcode.lua">\n'
..'offset: <select name="offset">')
for j=0,100,5 do
ct:Append('<option value="'..j..'"'..((offset or 0)==j and ' selected' or '')..'>'
..(fsec>0 and ('%dm%02ds|'):format(math.floor(fsec*j/100/60),fsec*j/100%60) or '')..j..'%')
end
ct:Append('</select>\n'
..'<input type="checkbox" name="audio2" value="1"'..(audio2 and ' checked' or '')..'>audio2\n'
..'<select name="dual">'
..'<option value="0"'..(dual~=1 and dual~=2 and ' selected' or '')..'>*'
..'<option value="1"'..(dual==1 and ' selected' or '')..'>dual-main'
..'<option value="2"'..(dual==2 and ' selected' or '')..'>dual-sub'
..'</select>\n'
..'<input type="checkbox" name="cinema" value="1"'..(cinema and ' checked' or '')..'>cinema\n'
..'</div></form>')
if vtag==10 then
ct:Append('\n<video autoplay controls style="max-width:95%" src="xcode.lua?fname='..mg.url_encode(ref)..(offset and '&amp;offset='..offset or '')
..(audio2 and '&amp;audio2=1' or '')..(dual and '&amp;dual='..dual or '')..(cinema and '&amp;cinema=1' or '')..'">xcode.lua</video>')
end
else
ct:Append(' ('..math.floor(ff[1].size/1048576)..'M)<br>\n')
end
Expand Down

0 comments on commit d84d94a

Please sign in to comment.