-- vim:set ft=lua: dofile(mg.script_name:gsub('[^\\/]*$','')..'epg.lua') baseDate=math.floor((now+timezone-MARGIN_HOUR*3600)/24/3600) Hour=math.floor((((now+timezone)%(24*3600))/3600)-MARGIN_HOUR)%24 baseTime=(baseDate*24+Hour)*3600 post=AssertPost() rt={} for i,v in ipairs(edcb.GetReserveData()) do rt[v.onid..'-'..v.tsid..'-'..v.sid..'-'..v.eid]=v.reserveID end preset=mg.get_var(mg.request_info.query_string, 'preset') Olympic=mg.get_var(mg.request_info.query_string, 'Olympic') _preset=nil presetList={} for v in edcb.GetPrivateProfile('search','list','',ini):gmatch('[^,]+') do if v==preset then _preset=preset..'_Search' end presetList[#presetList+1]=v end if not _preset then --未登録 preset=nil end if preset then key={ andKey=edcb.GetPrivateProfile(_preset,'andKey','',ini), notKey=edcb.GetPrivateProfile(_preset,'notKey','',ini), regExpFlag=tonumber(edcb.GetPrivateProfile(_preset,'regExpFlag',false,ini))~=0, titleOnlyFlag=tonumber(edcb.GetPrivateProfile(_preset,'titleOnlyFlag',false,ini))~=0, aimaiFlag=tonumber(edcb.GetPrivateProfile(_preset,'aimaiFlag',false,ini))~=0, notContetFlag=tonumber(edcb.GetPrivateProfile(_preset,'notContetFlag',false,ini))~=0, notDateFlag=tonumber(edcb.GetPrivateProfile(_preset,'notDateFlag',false,ini))~=0, freeCAFlag=tonumber(edcb.GetPrivateProfile(_preset,'freeCAFlag',0,ini)), chkRecEnd=tonumber(edcb.GetPrivateProfile(_preset,'chkRecEnd',false,ini))~=0, chkRecDay=tonumber(edcb.GetPrivateProfile(_preset,'chkRecDay',0,ini)), chkRecNoService=tonumber(edcb.GetPrivateProfile(_preset,'chkRecNoService',false,ini))~=0, chkDurationMin=tonumber(edcb.GetPrivateProfile(_preset,'chkDurationMin',0,ini)), chkDurationMax=tonumber(edcb.GetPrivateProfile(_preset,'chkDurationMax',0,ini)), days=tonumber(edcb.GetPrivateProfile(_preset,'days',0,ini)), contentList={}, serviceList={}, dateList={}, lock=tonumber(edcb.GetPrivateProfile(_preset,'lock',false,ini))~=0, } for i=0,1000 do v=tonumber(edcb.GetPrivateProfile(_preset,'contentList'..i,0,ini)) if v==0 then break end table.insert(key.contentList, {content_nibble=v}) end for i=0,1000 do v=edcb.GetPrivateProfile(_preset,'serviceList'..i,0,ini) if v==0 then break end m={string.match(v, '^(%d+)%-(%d+)%-(%d+)$')} if #m==3 then table.insert(key.serviceList, {onid=0+m[1], tsid=0+m[2], sid=0+m[3]}) end end for v in string.gmatch(edcb.GetPrivateProfile(_preset,'dateList','',ini), '[^,]+') do m={string.match(v, '^(.-)%-(%d+):(%d+)%-(.-)%-(%d+):(%d+)$')} if #m==6 then dateInfo={ startDayOfWeek=({['日']=0,['月']=1,['火']=2,['水']=3,['木']=4,['金']=5,['土']=6})[m[1]], endDayOfWeek=({['日']=0,['月']=1,['火']=2,['水']=3,['木']=4,['金']=5,['土']=6})[m[4]] } if dateInfo.startDayOfWeek and dateInfo.endDayOfWeek then dateInfo.startHour=0+m[2] dateInfo.startMin=0+m[3] dateInfo.endHour=0+m[5] dateInfo.endMin=0+m[6] table.insert(key.dateList, dateInfo) end end end elseif post then key=getSearchKey(post) elseif Olympic then key={ andKey='(オ|パラ)リンピック|五輪|FIFAワールドカップ', notKey='', regExpFlag=true, titleOnlyFlag=true, chkDurationMin=10, contentList={{content_nibble=262}}, serviceList={}, days=3 } for i,v in ipairs(edcb.GetChDataList()) do if v.searchFlag then table.insert(key.serviceList, v) end end end if not key then key={} end edcb.htmlEscape=15 b=edcb.SearchEpg(key) table.sort(b, function(a,b) if os.time(a.startTime)==os.time(b.startTime) then return a.sid < b.sid else return os.time(a.startTime) < os.time(b.startTime) end end) st={} for i,v in ipairs(b)do _endTime=os.time(v.startTime)+(v.durationSecond or 0) if baseTime-timezone<_endTime and (i==1 or v.eid~=b[i-1].eid) then if not lastendTime or lastendTime<_endTime then lastendTime=_endTime end for j=1, #st+1 do if st[j] then w=st[j][#st[j]] startTime=os.time(w.startTime) endTime=w.durationSecond and startTime+w.durationSecond or startTime+10*3600 else st[j]={} end if #st[j]==0 or startTime\n' ..'
\n' ..'
\n' ..'
\n' ..'
\n' ..'
\n' ..'
\n' ct.menu='
' ..'
\n' ctt={'
' ..'
\n' ..'
\n' ..'
\n'} for i=Hour,Hour+interval-1 do j=i%24 table.insert(ctt, '
`'..(j==4 and os.date('!*t', ((baseDate*24)+i)*3600).day..'日' or '')..(j<4 and j+24 or j)..'時`
\n') end table.insert(ctt, '
\n') for i,v in ipairs(st) do table.insert(ctt, '
') lastPx=0 total=0 for j,w in ipairs(v) do startTime=os.time(w.startTime) startPx=math.min(math.floor((startTime+timezone-baseTime)/60)*ONE_MIN_PX, ONE_MIN_PX*60*interval) endTime=w.durationSecond and startTime+w.durationSecond or startTime+10*3600 --終了時間未定 endPx=math.min(math.floor((endTime+timezone-baseTime)/60)*ONE_MIN_PX, ONE_MIN_PX*60*interval) if startPx-lastPx>0 then table.insert(ctt, '
\n') total=total+startPx-lastPx lastPx=startPx end if endPx-lastPx>2 then op={ service_name=SERVICE[('%04X%04X%04X'):format(w.onid, w.tsid, w.sid)] or '', url='epginfo.html?onid='..w.onid..'&tsid='..w.tsid..'&sid='..w.sid..(w.past and '&startTime='..startTime+timezone or '&eid='..w.eid) } table.insert(ctt, epgcell(w, op, (i==1 and 'id="id'..j..'" ' or nil), true)) total=total+endPx-lastPx lastPx=endPx end end if total
\n') end table.insert(ctt, '
\n') end ct.main='
\n' ..(sidePanel and sidePanelTemplate() or '') table.insert(ctt, '
\n
\n' ..'\n' ..'\n' ..'\n' ..'\n' ..'\n') ctt[1]=ct.main..ctt[1] ct.main=table.concat(ctt) ct=template(ct) mg.write(ct:Pop(Response(200,'text/html','utf-8',ct.len)..(ct.gzip and 'Content-Encoding: gzip\r\n' or '')..'\r\n'))