8,957
edits
mNo edit summary Tag: Reverted |
No edit summary Tag: Reverted |
||
Line 1: | Line 1: | ||
local p = {} | |||
-- Функция для определения актуального альбома по названию страницы | |||
function p.getCurrentAlbum() | |||
local title = mw.title.getCurrentTitle().text or "" | |||
local year = mw.ustring.match(title, "%.(%d%d%d%d)$") | |||
year = tonumber(year) | |||
if year and year >= 2008 and year <= 2012 then | |||
return "Regional At Best" | |||
elseif year and year >= 2013 then | |||
return "Vessel" | |||
end | |||
return nil | |||
end | |||
local songs = { | local songs = { | ||
["Implicit Demand For Proof"] = {"Twenty One Pilots"}, | ["Implicit Demand For Proof"] = {"Twenty One Pilots"}, | ||
Line 112: | Line 127: | ||
} | } | ||
-- | -- Пример функции: возвращает песни, относящиеся к альбому для текущей страницы | ||
function p.getSongsForCurrentAlbum(frame) | |||
local album = p.getCurrentAlbum() | |||
local | if not album then | ||
local | return "Альбом не определён" | ||
end | |||
local result = {} | |||
for song, albums in pairs(songs) do | for song, albums in pairs(songs) do | ||
for _, a in ipairs(albums) do | |||
if a == album then | |||
table.insert(result, song) | |||
break | |||
end | end | ||
end | end | ||
end | end | ||
return table.concat(result, "<br>") | |||
return | |||
end | end | ||
return p | |||
return | |||