|
|
(未显示同一用户的132个中间版本) |
第1行: |
第1行: |
| local p = { | | local p = {} |
| plat={""," NS"}
| | function p.len(frame) |
| } | | return #frame.args.a |
| | |
| function LoadJson(filename) | |
| return mw.text.jsonDecode(mw.getCurrentFrame():expandTemplate{ title = filename })
| |
| end | | end |
| | | function p.explode(frame) |
| function QuerySong(json,index,queryById,...) | | return mw.dumpObject({mw.ustring.byte(frame.args.a,1,-1)}) |
| 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
| |
| for _, v in ipairs({...}) do
| |
| if type(v)~="function" then
| |
| error("You Input Illegal Filter Type")
| |
| end
| |
| r=v(r)
| |
| end
| |
| return r
| |
| end | | end |
|
| |
| function NSBydFilter(info)
| |
| local NsBydSet={["tempestissimo"] = true}
| |
| if info["difficulties"][4] and info["difficulties"][4]["ratingClass"]~=3 then
| |
| error("Do NS Have April Fool's Chart?")
| |
| end
| |
| if not NsBydSet[info["id"]] then
| |
| info["difficulties"][4] = nil
| |
| end
| |
| return info
| |
| end
| |
|
| |
| function p.GetSong(args)
| |
| local Mobile = QuerySong(LoadJson("Songlist"),args['曲名'],args['id'])
| |
| local NS = QuerySong(LoadJson("Songlist NS"),args['曲名'],args['id'],NSBydFilter)
| |
| return mw.text.jsonEncode({Mobile=Mobile, NS=NS, args=args},mw.text.JSON_PRESERVE_KEYS)
| |
| end
| |
|
| |
| return p | | return p |