|
|
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 126: |
Line 111: |
| ["Johnny Boy (EP)"] = "Johnny Boy", | | ["Johnny Boy (EP)"] = "Johnny Boy", |
| } | | } |
|
| |
| -- Пример функции: возвращает песни, относящиеся к альбому для текущей страницы
| |
| function p.getSongsForCurrentAlbum(frame)
| |
| local album = p.getCurrentAlbum()
| |
| if not album then
| |
| return "Альбом не определён"
| |
| end
| |
| local result = {}
| |
| 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
| |
| return table.concat(result, "<br>")
| |
| end
| |
|
| |
| return p
| |