|
|
(未显示同一用户的118个中间版本) |
第1行: |
第1行: |
| local p={byd=nil,cfg=nil} | | local p = {} |
| | | function p.len(frame) |
| local function LoadJson(filename)
| | return #frame.args.a |
| return mw.text.jsonDecode(mw.getCurrentFrame():expandTemplate{ title = filename })
| |
| end | | end |
| | | function p.explode(frame) |
| local function NSBydFilter(info)
| | return mw.dumpObject({mw.ustring.byte(frame.args.a,1,-1)}) |
| -- assert( | |
| -- p.byd==nil or p.byd["ratingClass"]==3,
| |
| -- "NS不会有愚人节谱"
| |
| -- )
| |
| local NsBydSet={["tempestissimo"] = true}
| |
| if not NsBydSet[info["id"]] then
| |
| info["difficulties"][4] = nil
| |
| end
| |
| return info
| |
| end | | end |
|
| |
| local function MobileBydFilter(info)
| |
| if p.byd then
| |
| if p.byd["title_localized"] then
| |
| info["title_localized"].append(p.byd["title_localized"]["en"])
| |
| p.cfg["bydNameOverride"]=true
| |
| end
| |
| if p.byd["audioOverride"] then
| |
| p.cfg["bydSongOverride"]={
| |
| artist=p.byd["artist"],
| |
| bpm=p.byd["bpm"],
| |
| bpm_base=p.byd["bpm_base"],
| |
| }
| |
| end
| |
| if p.byd["jacketOverride"] then
| |
| p.cfg["jacketOverride"].append("byd")
| |
| end
| |
| end
| |
| return info
| |
| end
| |
|
| |
| local function BGFilter(info)
| |
| assert(info["bg"],"'bg'字段必须存在")
| |
| local board={"light","conflict"}
| |
| info["bg"] = info["bg"]~="" and info["bg"] or "base_"..board[info["side"]]
| |
| return info
| |
| end
| |
|
| |
| local function NameAudioFilter(info)
| |
| assert(info["title_localized"]["en"],"'en'字段必须存在")
| |
| info["title_localized"]={
| |
| info["title_localized"]["en"],
| |
| info["title_localized"]["ja"],
| |
| info["title_localized"]["zh-Hans"]
| |
| }
| |
| return info
| |
| end
| |
|
| |
| local function JacketFilter(info)
| |
| local oType={}
| |
| if info["jacket_localized"] then-- solitarydream
| |
| oType.append("lang")
| |
| elseif info["difficulties"][1]["jacket_night"] then-- melodyoflove
| |
| oType.append("hour")
| |
| elseif info["difficulties"][1]["jacketOverride"] then-- stager, avril
| |
| oType.append("pstprs")
| |
| end
| |
| p.cfg["jacketOverride"]=oType
| |
| return info
| |
| end
| |
|
| |
| function QuerySong(json,index,queryById,...)
| |
| local r
| |
| if queryById then
| |
| for _, v in ipairs(json["songs"]) do
| |
| if v['id'] == index then
| |
| r = v
| |
| break
| |
| end
| |
| end
| |
| else
| |
| for _, v in ipairs(json["songs"]) do
| |
| if v['title_localized']['en'] == index then
| |
| r = v
| |
| break
| |
| end
| |
| end
| |
| end
| |
| p.byd=r["difficulties"][4]
| |
| r["__config"]={} --magic
| |
| p.cfg=r["__config"]
| |
| for _, v in ipairs({...}) do
| |
| assert(type(v)=="function","You Input Illegal Filter Type?")
| |
| if r~=nil then
| |
| r=v(r)
| |
| end
| |
| end
| |
| return r
| |
| end
| |
|
| |
| function p.GetSong(args)
| |
| local Mobile = QuerySong(LoadJson("Songlist"),args['曲名'],args['id'],BGFilter,NameAudioFilter,JacketFilter,MobileBydFilter)
| |
| local NS = QuerySong(LoadJson("Songlist NS"),args['曲名'],args['id'],BGFilter,NameAudioFilter,JacketFilter,NSBydFilter)
| |
| return mw.text.jsonEncode({Mobile=Mobile, NS=NS, args=args},mw.text.JSON_PRETTY)
| |
| end
| |
|
| |
| return p | | return p |