Module:Sandbox/InvalidData/AichanRepeat
可在Module:Sandbox/InvalidData/AichanRepeat/doc创建此模块的帮助文档
local srcFileName = 'InvalidData/preferdata.json'
local p = {}
function p.getList()
return mw.text.jsonDecode(mw.title.new(srcFileName,'User'):getContent())['aichan']
end
function p.main()
local prefList = p.getList()
local allList = {}
local repList = {}
local repTimes = 0
local repSongs = 0
local songNumber = 0
for i = 1,#prefList,1 do
local tempPref1 = prefList[i]['prefer']
for j = 1,#tempPref1,1 do
local tempPref2 = tempPref1[j]
for k = 1,#tempPref2,1 do
local curSong = tempPref2[k]
if allList[curSong] then -- when repeat
repTimes = repTimes + 1
if repList[curSong] then -- when not first repeat
repList[curSong] = repList[curSong] + 1
else -- when first repeat
repList[curSong] = 1
repSongs = repSongs + 1
end
else -- when not repeat
songNumber = songNumber + 1
allList[songNumber] = curSong
end
end
end
end
local wikiText = "* 出现了'''" .. repTimes .. "'''次/'''" .. repSongs .. "'''首重复曲目"
return wikiText
end
return p