-- vim:set ft=lua: dofile(mg.script_name:gsub('[^\\/]*$','')..'util.lua') ct=CreateContentBuilder(GZIP_THRESHOLD_BYTE) ct:Append([=[

# 設定/プリセット

]=]) srvIni='EpgTimerSrv.ini' post=AssertPost() if post and not ALLOW_SETTING then post=nil ct:Append('
変更は許可されていません
\n') end if post then presetID=GetVarInt(post,'presetID') or 0 preset=nil itemList=edcb.EnumRecPresetInfo() for i,v in ipairs(itemList) do if v.id==presetID then if mg.get_var(post,'del') then --デフォルトは削除できない if presetID~=0 then presetID=nil table.remove(itemList,i) ct:Append('
削除しました
\n') end elseif mg.get_var(post,'addchg') then if mg.get_var(post,'add') then presetName=mg.get_var(post,'presetName') or '' if presetName:find('^%C+$') then presetID=nil preset={ name=presetName, recSetting={ recFolderList=v.recSetting.recFolderList, partialRecFolder=v.recSetting.partialRecFolder } } itemList[#itemList+1]=preset ct:Append('
追加しました
\n') end else presetID=nil preset=v ct:Append('
変更しました
\n') end end break end end if not presetID then --削除または追加または変更 if preset then --追加または変更 rs=preset.recSetting rs.noRecMode=GetVarInt(post,'recMode',0,4) or 1 rs.recMode=GetVarInt(post,'recEnabled')~=1 and 5 or rs.noRecMode rs.tuijyuuFlag=GetVarInt(post,'tuijyuuFlag')==1 rs.priority=GetVarInt(post,'priority',1,5) or 2 rs.pittariFlag=GetVarInt(post,'pittariFlag')==1 rs.suspendMode=GetVarInt(post,'suspendMode',0,4) or 0 rs.rebootFlag=GetVarInt(post,'rebootFlag')==1 rs.startMargin=GetVarInt(post,'useDefMarginFlag')~=1 and GetVarInt(post,'startMargin',-6*3600,6*3600) rs.endMargin=GetVarInt(post,'useDefMarginFlag')~=1 and GetVarInt(post,'endMargin',-6*3600,6*3600) rs.serviceMode=GetVarInt(post,'serviceMode')==1 and 0 or 1+16*(GetVarInt(post,'serviceMode_1',0,1) or 0)+32*(GetVarInt(post,'serviceMode_2',0,1) or 0) rs.continueRecFlag=GetVarInt(post,'continueRecFlag')==1 rs.tunerID=GetVarInt(post,'tunerID') or 0 rs.partialRecFlag=GetVarInt(post,'partialRecFlag',0,1) or 0 rs.batFilePath=(mg.get_var(post,'batFilePath') or ''):gsub('%c','') end saveID='' for i,v in ipairs(itemList) do --IDを振りなおす v.id=i-1 defName='REC_DEF' if v.id>0 then defName=defName..v.id saveID=saveID..v.id..',' end edcb.WritePrivateProfile(defName,'SetName',v.id>0 and v.name or 'デフォルト',srvIni) rs=v.recSetting edcb.WritePrivateProfile(defName,'RecMode',rs.recMode,srvIni) edcb.WritePrivateProfile(defName,'NoRecMode',rs.noRecMode,srvIni) edcb.WritePrivateProfile(defName,'Priority',rs.priority,srvIni) edcb.WritePrivateProfile(defName,'TuijyuuFlag',rs.tuijyuuFlag,srvIni) edcb.WritePrivateProfile(defName,'ServiceMode',rs.serviceMode,srvIni) edcb.WritePrivateProfile(defName,'PittariFlag',rs.pittariFlag,srvIni) edcb.WritePrivateProfile(defName,'BatFilePath',rs.batFilePath,srvIni) edcb.WritePrivateProfile(defName,'SuspendMode',rs.suspendMode,srvIni) edcb.WritePrivateProfile(defName,'RebootFlag',rs.rebootFlag,srvIni) edcb.WritePrivateProfile(defName,'UseMargineFlag',not not (rs.startMargin and rs.endMargin),srvIni) edcb.WritePrivateProfile(defName,'StartMargine',rs.startMargin or 0,srvIni) edcb.WritePrivateProfile(defName,'EndMargine',rs.endMargin or 0,srvIni) edcb.WritePrivateProfile(defName,'ContinueRec',rs.continueRecFlag,srvIni) edcb.WritePrivateProfile(defName,'PartialRec',rs.partialRecFlag,srvIni) edcb.WritePrivateProfile(defName,'TunerID',rs.tunerID,srvIni) defName=defName:gsub('EF','EF_FOLDER') edcb.WritePrivateProfile(defName,'Count',#rs.recFolderList,srvIni) for j,w in ipairs(rs.recFolderList) do edcb.WritePrivateProfile(defName,j-1,w.recFolder,srvIni) edcb.WritePrivateProfile(defName,'WritePlugIn'..(j-1),w.writePlugIn,srvIni) edcb.WritePrivateProfile(defName,'RecNamePlugIn'..(j-1),w.recNamePlugIn,srvIni) end defName=defName:gsub('ER','ER_1SEG') edcb.WritePrivateProfile(defName,'Count',#rs.partialRecFolder,srvIni) for j,w in ipairs(rs.partialRecFolder) do edcb.WritePrivateProfile(defName,j-1,w.recFolder,srvIni) edcb.WritePrivateProfile(defName,'WritePlugIn'..(j-1),w.writePlugIn,srvIni) edcb.WritePrivateProfile(defName,'RecNamePlugIn'..(j-1),w.recNamePlugIn,srvIni) end end edcb.WritePrivateProfile('SET','PresetID',saveID,srvIni) presetID=preset and preset.id or 0 end else presetID=GetVarInt(mg.request_info.query_string,'presetID') or 0 end edcb.htmlEscape=15 ct:Append([=[
]=]) if preset then ct:Append([=[
]=]..RecSettingTemplate(preset.recSetting,'setting_rec_preset_folder.html?presetID='..presetID)..[=[
この名前でプリセットを追加
プリセット「]=]..preset.name..[=[」を
]=]) 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'))