-- vim:set ft=lua: HIDE_SERVICES={ --非表示にしたいサービスを['ONID-TSID-SID']=true,のように指定 --['1-2345-6789']=true, } dofile(mg.script_name:gsub('[^\\/]*$','')..'util.lua') vtag=GetVarInt(mg.request_info.query_string,'vtag') or -1 ct=CreateContentBuilder(GZIP_THRESHOLD_BYTE) ct:Append([=[

# リスト番組表

]=]) onid,tsid,sid=(mg.get_var(mg.request_info.query_string,'id') or ''):match('^(%d?%d?%d?%d?%d)%-(%d?%d?%d?%d?%d)%-(%d?%d?%d?%d?%d)$') onid=tonumber(onid) or 0 tsid=tonumber(tsid) or 0 sid=tonumber(sid) or 0 date=GetVarInt(mg.request_info.query_string,'date',-10000,0) or 0 --dateクエリは今日(0時区切り)を基準(=0)とする now=os.time() timezone=now-os.time(os.date('!*t',now)) baseDate=math.floor((now+9*3600)/(24*3600)) baseTime=baseDate*24*3600 if sid==0 then showServices={} for i,v in ipairs(SelectChDataList(edcb.GetChDataList())) do if not HIDE_SERVICES[''..v.onid..'-'..v.tsid..'-'..v.sid] then showServices[v.onid..'-'..v.tsid..'-'..v.sid]=true end end st={} edcb.htmlEscape=15 for i,v in ipairs(edcb.GetServiceList() or {}) do if showServices[''..v.onid..'-'..v.tsid..'-'..v.sid] then table.insert(st, v) end end SortServiceListInplace(st) ct:Append('
\n') else rt={} for i,v in ipairs(edcb.GetReserveData()) do rt[('%04X%04X%04X%04X'):format(v.onid, v.tsid, v.sid, v.eid)]=true end edcb.htmlEscape=15 --前後2週間の番組だけ取得する range={startTime=os.date('!*t',baseTime+(date-14)*24*3600),durationSecond=28*24*3600} et=edcb.EnumEventInfo({{onid=onid,tsid=tsid,sid=sid}},range) or {} for i,v in ipairs(edcb.EnumEventInfoArchive and edcb.EnumEventInfoArchive({{onid=onid,tsid=tsid,sid=sid}},range) or {}) do v.past=true table.insert(et, v) end table.sort(et, function(a,b) return (a.startTime and os.time(a.startTime) or 0)<(b.startTime and os.time(b.startTime) or 0) end) ct:Append('
\n') ct:Append('
\n') for i,v in ipairs(et) do sub=v.eventGroupInfo and #v.eventGroupInfo.eventDataList==1 and ( v.eventGroupInfo.eventDataList[1].onid~=v.onid or v.eventGroupInfo.eventDataList[1].tsid~=v.tsid or v.eventGroupInfo.eventDataList[1].sid~=v.sid or v.eventGroupInfo.eventDataList[1].eid~=v.eid) if not sub then if v.startTime and os.time(v.startTime)+timezone <= now+9*3600 and #et>i and et[i+1].startTime and os.time(et[i+1].startTime)+timezone > now+9*3600 then v.now=true end cont=v.contentInfoList and #v.contentInfoList>0 and math.floor(v.contentInfoList[1].content_nibble/256)%16 or 16 ct:Append('
' ..(v.startTime and ('%02d/%02d%s %02d:%02d'):format(v.startTime.month, v.startTime.day, ({'日','月','火','水','木','金','土'})[v.startTime.wday], v.startTime.hour, v.startTime.min) or '不明') ..(not v.past and rt[('%04X%04X%04X%04X'):format(v.onid, v.tsid, v.sid, v.eid)] and ' 予' or '') ..' ' ..(v.shortInfo and v.shortInfo.event_name or ' ')..'' ..'
\n') end end ct:Append('
\n') if date<0 then ct:Append('
\n') end end ct:Append([=[
]=]) if sid==0 then ct:Append([=[
]=]) else ct:Append((vtag==0 and ' view.lua -nwtv0' ..(vtag==0 and '' or ' (video)')) end ct:Append([=[
]=]) ct:Finish() mg.write(ct:Pop(Response(200,'text/html','utf-8',ct.len)..(ct.gzip and 'Content-Encoding: gzip\r\n' or '')..'\r\n'))