5,478
edits
mNo edit summary |
mNo edit summary |
||
Line 65: | Line 65: | ||
local groups = {} | local groups = {} | ||
local | local songTitles = {} | ||
local | 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 84: | ||
if type ~= nil then | if type ~= nil then | ||
if not groups[result. | if not groups[result.song_title] then groups[result.song_title] = {} end | ||
songPageNames[result.song_title] = result.song_page | |||
table.insert( | table.insert(songTitles, result.song_title) | ||
table.insert(groups[result. | table.insert(groups[result.song_title], { album = result.album, type = type }) | ||
end | end | ||
end | end | ||
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 in ipairs( | for _, song in ipairs(songTitles) do | ||
local rows = groups[song] | 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, song, | 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 .. |