5,478
edits
mNo edit summary |
mNo edit summary |
||
Line 65: | Line 65: | ||
local groups = {} | local groups = {} | ||
local | local songPages = {} | ||
local songPageNames = {} | |||
for _, result in ipairs(results) do | for _, result in ipairs(results) do | ||
local singers = mw.text.split(result.singers, ",") | local singers = mw.text.split(result.singers, ",") | ||
Line 84: | Line 85: | ||
if type ~= nil then | if type ~= nil then | ||
if not groups[result.song_title] then groups[result.song_title] = {} end | if not groups[result.song_title] then groups[result.song_title] = {} end | ||
songPageNames[result.song_title] = result.song_page | |||
table.insert(songPages) | |||
table.insert(groups[result.song_title], { album = result.album, type = type }) | table.insert(groups[result.song_title], { album = result.album, type = type }) | ||
end | end | ||
Line 90: | Line 92: | ||
local text = '{| class="wikitable sortable mw-collapsible"\n! Song !! Album !! Type\n' | local text = '{| class="wikitable sortable mw-collapsible"\n! Song !! Album !! Type\n' | ||
for song | for _, song in ipairs(songPages) do | ||
local rows = groups[song] | |||
local rowspan = #rows | local rowspan = #rows | ||
local head = table.remove(rows, 1) | local head = table.remove(rows, 1) | ||
text = text .. | text = text .. | ||
string.format('|-\n| rowspan=%d|[[%s|%s]] || [[%s]] || %s\n', rowspan, | string.format('|-\n| rowspan=%d|[[%s|%s]] || [[%s]] || %s\n', rowspan, songPageNames[song], song, head.album, head.type) | ||
for _, row in ipairs(rows) do | for _, row in ipairs(rows) do | ||
text = text .. | text = text .. |