Module:ArtistSong:修订间差异
Economy666(讨论 | 贡献) (byd信息) |
Economy666(讨论 | 贡献) (曲目按时间排序) |
||
第156行: | 第156行: | ||
if byd then | if byd then | ||
date = queryMO(id, 'bydDate') or queryNS(id, 'bydDate') | date = queryMO(id, 'bydDate') or queryNS(id, 'bydDate') | ||
if date then return date end | |||
end | |||
date = queryMO(id, 'date') or queryNS(id, 'date') | |||
if date then return date | |||
else return id end | |||
end | |||
local function songVer(id, byd) | |||
local date, ver | |||
if byd then | |||
ver = queryMO(id, 'bydVersion') or queryNS(id, 'bydVersion') | ver = queryMO(id, 'bydVersion') or queryNS(id, 'bydVersion') | ||
if | if ver then return ver end | ||
end | end | ||
ver = queryMO(id, 'version') or queryNS(id, 'version') | ver = queryMO(id, 'version') or queryNS(id, 'version') | ||
if | if ver then return ver | ||
else return id end | else return id end | ||
end | end | ||
第211行: | 第220行: | ||
table.sort(a2z, customSort) | table.sort(a2z, customSort) | ||
local function tableAppend(line,newStr) return line..'|'..newStr..'\n' end | |||
for _, name in pairs(a2z) do | for _, name in pairs(a2z) do | ||
local item = gl2[name] | local item = gl2[name] | ||
第239行: | 第249行: | ||
wikiText = wikiText .. '! style="width: 15%;"|发布时间\n' | wikiText = wikiText .. '! style="width: 15%;"|发布时间\n' | ||
wikiText = wikiText .. '! style="width: 20%;"|备注\n' | wikiText = wikiText .. '! style="width: 20%;"|备注\n' | ||
local function aslAppend(songid,date,byd) | |||
local theList={} | |||
theList.title = "[[" .. songTitle(songid,byd) .. "]]" | |||
theList.time = songid | |||
theList.bpm = songBPM(songid,byd) | |||
theList.pack = songPack(songid) .. "\n" | |||
theList.date = date .. '<br />('.. songVer(songid,byd) .. ')' .. "\n" | |||
return theList | |||
end | |||
local artistSongList = {} | |||
local listSort = {} | |||
if item.normal then | if item.normal then | ||
for _,songid in ipairs(item.normal) do | for _,songid in ipairs(item.normal) do | ||
local date = songDate(songid) | |||
local aslId = date..songid | |||
artistSongList[aslId]=aslAppend(songid, date) | |||
table.insert(listSort, aslId) | |||
end | end | ||
end | end | ||
if item.beyond then | if item.beyond then | ||
for _,songid in ipairs(item.beyond) do | for _,songid in ipairs(item.beyond) do | ||
local date = songDate(songid, 1) | |||
local aslId = date..songid..'byd' | |||
artistSongList[aslId]=aslAppend(songid, date, 1) | |||
table.insert(listSort, aslId) | |||
end | end | ||
end | end | ||
table.sort(listSort) | |||
for _,id in ipairs(listSort) do | |||
wikiText = tableAppend(wikiText, '-') | |||
wikiText = tableAppend(wikiText, artistSongList[id].title) | |||
wikiText = tableAppend(wikiText, artistSongList[id].time) | |||
wikiText = tableAppend(wikiText, artistSongList[id].bpm) | |||
wikiText = tableAppend(wikiText, artistSongList[id].pack) | |||
wikiText = tableAppend(wikiText, artistSongList[id].date) | |||
end | |||
wikiText = wikiText .. "|}\n" | wikiText = wikiText .. "|}\n" | ||
end | end | ||
return wikiText | return wikiText | ||
end | end | ||
return p | return p |
2024年7月6日 (六) 20:52的版本
可在Module:ArtistSong/doc创建此模块的帮助文档
p={}
local CAL = mw.loadJsonData 'User:Economy666/ComplexArtistsList.json'
local multiId = mw.loadJsonData 'Template:Transition.json'.multiId
local mad = require 'Module:AnotherData'
local data = require "Module:Arcaea Data"
local trans = mw.loadJsonData 'Template:Transition.json'
local CL = require 'Module:ConvertLink'
local queryMO = data.allSongInformation("id", "mobile")
local queryNS = data.allSongInformation("id", "ns")
local function readList()
local pickList = {}
local pickListBYD = {}
for _, song in ipairs(mad.listOf('songs', 'mobile')) do
local artist = song.artist
pickList[song.id] = song.artist
if song.difficulties[4] and (song.difficulties[4].artist or song.difficulties[4].title_localized) then
local bydArtist = song['difficulties'][4]['artist'] or song.artist
pickListBYD[song['id']] = bydArtist
end
end
for _, song in ipairs(mad.listOf('songs', 'ns')) do
if not pickList[song.id] and not multiId[song.id] then
pickList[song.id] = song.artist
if song.difficulties[4] and song.difficulties[4].artist or song.difficulties[4].title_localized then
local bydArtist = song['difficulties'][4]['artist'] or song.artist
pickListBYD[song['id']] = bydArtist
end
end
end
return pickList, pickListBYD
end
local function convertPick(pickList, pickListBYD)
convertList = {}
for _id,_ in pairs(pickList) do
local artist = pickList[_id]
if not convertList[artist] then convertList[artist] = {} end
if not convertList[artist].normal then convertList[artist]['normal'] = {} end
table.insert(convertList[artist]['normal'], _id)
end
for _id in pairs(pickListBYD) do
local artist = pickListBYD[_id]
if not convertList[artist] then convertList[artist] = {} end
if not convertList[artist].beyond then convertList[artist]['beyond'] = {} end
table.insert(convertList[artist]['beyond'], _id)
end
return convertList
end
local function genList(convertList)
local function cate(singleList, cArtist, artist)
local artist = artist or cArtist
if not singleList[artist] then singleList[artist] = {} end
if convertList[cArtist].beyond then
if not singleList[artist].beyond then singleList[artist]['beyond'] = {} end
for _,i in pairs(convertList[cArtist]['beyond']) do
table.insert(singleList[artist]['beyond'],i)
end
end
if convertList[cArtist].normal then
if not singleList[artist].normal then singleList[artist]['normal'] = {} end
for _,i in pairs(convertList[cArtist]['normal']) do
table.insert(singleList[artist]['normal'],i)
end
end
return singleList
end
local singleList = {}
for cArtist in pairs(convertList) do
if CAL[cArtist] then
local artistlist={}
for _,text in pairs(CAL[cArtist]) do
if text.link then
local artist = text['link']
if not artistlist[artist] then
singleList = cate(singleList, cArtist, artist)
artistlist[artist]=1
end
end
end
else
singleList = cate(singleList, cArtist)
end
end
return singleList
end
-- 排序
local function customSort(a, b)
local function isLetter(char)
return char:match("%a") ~= nil
end
local a1 = a:sub(1, 1)
local b1 = b:sub(1, 1)
local la1 = isLetter(a:sub(1, 1))
local lb1 = isLetter(b:sub(1, 1))
if la1 and not lb1 then
return true
elseif lb1 and not la1 then
return false
elseif string.lower(a1) == string.lower(b1) then
local la2 = isLetter(a:sub(2, 2))
local lb2 = isLetter(b:sub(2, 2))
if la2 and not lb2 then
return true
elseif lb2 and not la2 then
return false
else
return string.lower(a) < string.lower(b)
end
else
return string.lower(a) < string.lower(b)
end
return string.lower(a) < string.lower(b)
end
local function songTitle(id,byd)
local display
local title = queryMO(id, 'title') or queryNS(id, 'title')
if byd then
display = queryMO(id, 'bydSongName') or queryNS(id, 'bydSongName') or 'cant find BYD'
else
display = title
end
local res = trans.songNameToDisplayName[title]
if res then return res..'|'..display end
res = trans.sameName[title]
if res then return res[id]..'|'..display end
if title then return title..'|'..display
else return id end
end
local function songBPM(id, byd)
local bpm
if byd then
bpm = queryMO(id, 'bydBPM') or queryNS(id, 'bydBPM')
if bpm then return bpm end
end
bpm = queryMO(id, 'bpm') or queryNS(id, 'bpm')
if bpm then return bpm
else return id end
end
local function songDate(id, byd)
local date, ver
if byd then
date = queryMO(id, 'bydDate') or queryNS(id, 'bydDate')
if date then return date end
end
date = queryMO(id, 'date') or queryNS(id, 'date')
if date then return date
else return id end
end
local function songVer(id, byd)
local date, ver
if byd then
ver = queryMO(id, 'bydVersion') or queryNS(id, 'bydVersion')
if ver then return ver end
end
ver = queryMO(id, 'version') or queryNS(id, 'version')
if ver then return ver
else return id end
end
local function songPack(id)
local packid,plat,isNS
-- if queryNS(id, 'set') then
-- packid = queryNS(id, 'set')
-- plat = 'ns'
-- isNS = 1
if queryMO(id, 'set') then
packid = queryMO(id, 'set')
else
return id
end
local packName = trans.packName[packid] or mad.packQueryWrap(packid, plat).name
local packLink = CL.packLink(packName,1,isNS)
return packLink
end
function p.main(frame)
local rl, rlb = readList()
local cl = convertPick(rl, rlb)
local gl = genList(cl)
rl,rlb,cl = nil
local NotJaName = {['旅人E']='Tabibito E'}
local wikiText = ""
local a2z = {}
local gl2 = {}
for name in pairs(gl) do
local enName
if mw.ustring.match(name,'[一-龠ぁ-ゔァ-ヴー々〆〤ヶ]+') then
enName = frame.args[name .. '.enName'] or name--nil
gl2[enName] = gl[name]
gl2[enName].localName = name
if NotJaName[name] then
gl2[enName].notJa = 1
end
else
enName = name
gl2[enName] = gl[name]
end
gl2[enName].otherName = frame.args[name .. '.otherName'] or nil
table.insert(a2z,enName)
end
table.sort(a2z, customSort)
local function tableAppend(line,newStr) return line..'|'..newStr..'\n' end
for _, name in pairs(a2z) do
local item = gl2[name]
local displayName, usingName
if item.localName then
usingName = item.localName
if item.notJa then
displayName = usingName ..' (' .. name ..')'
else
displayName = '<span lang="ja">' .. usingName .. '</span>' ..' (' .. name ..')'
end
else
usingName = name
displayName = name
end
if item.otherName then
displayName = displayName .. ' (' .. item.otherName .. ')'
end
wikiText = wikiText .. '<span id="' .. usingName .. '" />\n'
wikiText = wikiText .. "==".. displayName .." ==\n"
wikiText = wikiText .. 'Span id: ' .. usingName .."\n"
wikiText = wikiText .. '{| class="wikitable" border="1" cellspacing="1" cellpadding="5" style="text-align:center;width: 80%"\n'
wikiText = wikiText .. '! style="width: 30.5%;"|曲目名称\n'
wikiText = wikiText .. '! style="width: 8%;"|时长\n'
wikiText = wikiText .. '! style="width: 8%;"|BPM\n'
wikiText = wikiText .. '! style="width: 18.5%;"|曲包\n'
wikiText = wikiText .. '! style="width: 15%;"|发布时间\n'
wikiText = wikiText .. '! style="width: 20%;"|备注\n'
local function aslAppend(songid,date,byd)
local theList={}
theList.title = "[[" .. songTitle(songid,byd) .. "]]"
theList.time = songid
theList.bpm = songBPM(songid,byd)
theList.pack = songPack(songid) .. "\n"
theList.date = date .. '<br />('.. songVer(songid,byd) .. ')' .. "\n"
return theList
end
local artistSongList = {}
local listSort = {}
if item.normal then
for _,songid in ipairs(item.normal) do
local date = songDate(songid)
local aslId = date..songid
artistSongList[aslId]=aslAppend(songid, date)
table.insert(listSort, aslId)
end
end
if item.beyond then
for _,songid in ipairs(item.beyond) do
local date = songDate(songid, 1)
local aslId = date..songid..'byd'
artistSongList[aslId]=aslAppend(songid, date, 1)
table.insert(listSort, aslId)
end
end
table.sort(listSort)
for _,id in ipairs(listSort) do
wikiText = tableAppend(wikiText, '-')
wikiText = tableAppend(wikiText, artistSongList[id].title)
wikiText = tableAppend(wikiText, artistSongList[id].time)
wikiText = tableAppend(wikiText, artistSongList[id].bpm)
wikiText = tableAppend(wikiText, artistSongList[id].pack)
wikiText = tableAppend(wikiText, artistSongList[id].date)
end
wikiText = wikiText .. "|}\n"
end
return wikiText
end
return p