|
|
(未显示同一用户的59个中间版本) |
第1行: |
第1行: |
| local p={cfg=nil} | | local p = {} |
| local W=mw
| | function p.len(frame) |
| | | return #frame.args.a |
| local function opChain(tar)
| |
| local status,result=pcall(tar) | |
| if status then return result else return nil end
| |
| end | | end |
| | | function p.explode(frame) |
| local function LoadJson(filename)
| | return mw.dumpObject({mw.ustring.byte(frame.args.a,1,-1)}) |
| return W.text.jsonDecode(W.getCurrentFrame():expandTemplate{ title = filename })
| |
| end | | end |
|
| |
| local function cfgPush(key,val)
| |
| if val~=nil then
| |
| if p.cfg[key]==nil then
| |
| p.cfg[key]={}
| |
| end
| |
| p.cfg[key][#p.cfg[key]+1]=val
| |
| end
| |
| end
| |
|
| |
| local function NSBydFilter(info)
| |
| local NsBydSet={["tempestissimo"] = true}
| |
| if not NsBydSet[info["id"]] then
| |
| info["difficulties"][4] = nil
| |
| end
| |
| return info
| |
| end
| |
|
| |
| local function AudioFilter(info)
| |
| if opChain(function ()return info["difficulties"][4]["audioOverride"] end) then
| |
| local byd=info["difficulties"][4]
| |
| p.cfg["bydSongOverride"]={
| |
| title_localized=byd["title_localized"]["en"],
| |
| artist=byd["artist"],
| |
| bpm=byd["bpm"],
| |
| bpm_base=byd["bpm_base"],
| |
| bg=byd["bg"],
| |
| --duration=,
| |
| }
| |
| end
| |
| return info
| |
| end
| |
|
| |
| local function BGFilter(info)
| |
| assert(info["bg"] and info["side"],"'bg'字段必须存在")
| |
| local board={[0]="light",[1]="conflict"}
| |
| if info["bg"]=="" then info["bg"] = "base_"..board[info["side"]]
| |
| elseif info["difficulties"][3]["bg"] then-- aterlbus
| |
| p.cfg["bgOverride"]=info["difficulties"][3]["bg"]
| |
| end
| |
| return info
| |
| end
| |
|
| |
| local function TitleFilter(info)
| |
| assert(info["title_localized"]["en"],"'en'字段必须存在")
| |
| cfgPush("title",info["title_localized"]["en"])
| |
| cfgPush("title",info["title_localized"]["ja"])
| |
| cfgPush("title",info["title_localized"]["zh-Hans"])
| |
| return info
| |
| end
| |
|
| |
| local function JacketFilter(info)
| |
| if info["jacket_localized"] then-- solitarydream
| |
| cfgPush("jacketOverride","lang")
| |
| end
| |
| if info["difficulties"][1]["jacket_night"] then-- melodyoflove
| |
| cfgPush("jacketOverride","sunset")
| |
| end
| |
| if info["difficulties"][1]["jacketOverride"] then-- stager, avril, lanota2
| |
| cfgPush("jacketOverride","pstprs")
| |
| end
| |
| if opChain(function ()return info["difficulties"][4]["jacketOverride"] end) then
| |
| cfgPush("jacketOverride","byd")
| |
| end
| |
| return info
| |
| end
| |
|
| |
| function QuerySong(json,key,queryById,...)
| |
| local searcher
| |
| if queryById then
| |
| -- quon, ifi, aiueoon
| |
| searcher = function (x)return x['id']end
| |
| else
| |
| key = W.text.decode(key,true)
| |
| searcher = function (x)return W.ustring.gsub(x['title_localized']['en'],"^%l",W.ustring.upper)end
| |
| end
| |
| for _, song in ipairs(json["songs"]) do
| |
| if searcher(song) == key then
| |
| p.cfg = {}
| |
| for _, filter in ipairs({...}) do filter(song) end
| |
| song.__config=p.cfg
| |
| return song
| |
| end
| |
| end
| |
| end
| |
|
| |
| function p.GetSong(args)
| |
| local Mobile = QuerySong(LoadJson("Songlist"),args['曲名'],args['id'],BGFilter,TitleFilter,JacketFilter,AudioFilter)
| |
| local NS = QuerySong(LoadJson("Songlist NS"),args['曲名'],args['id'],NSBydFilter,BGFilter,TitleFilter,JacketFilter)
| |
| Mobile.__config.version=string.gmatch(
| |
| W.text.nowiki(W.getCurrentFrame():expandTemplate{ title = ":版本更新日志" }),
| |
| "(v%d%.%d+%.%d+) |" .. W.language.getContentLanguage():formatDate("Y%.n%.j","@"..Mobile["date"]) .. "%D")()
| |
| local main=Mobile or NS
| |
| if Mobile and NS then
| |
| --
| |
| end
| |
| return W.text.jsonEncode({Mobile=Mobile, NS=NS, args=args, err=(Mobile.__config.version==nil)},W.text.JSON_PRETTY)
| |
| end
| |
|
| |
| return p | | return p |