Module:Setlist/AlbumSelector: Difference between revisions
Jump to navigation
Jump to search
(Created page with "local p = {} -- ВСПОМОГАТЕЛЬНАЯ ФУНКЦИЯ: Получение года из названия страницы function p.extractYear(title) -- ищет ".20XX" или ".19XX" в конце строки local year = mw.ustring.match(title, "%.([12]%d%d%d)$") return year and tonumber(year) end -- Определяет альбом по году для песен, входящих в Regional At Best и Vessel function p.detectAlbumByYear(ye...") |
(No difference)
|
Revision as of 16:21, 11 July 2025
Documentation for this module may be created at Module:Setlist/AlbumSelector/doc
local p = {}
-- ВСПОМОГАТЕЛЬНАЯ ФУНКЦИЯ: Получение года из названия страницы
function p.extractYear(title)
-- ищет ".20XX" или ".19XX" в конце строки
local year = mw.ustring.match(title, "%.([12]%d%d%d)$")
return year and tonumber(year)
end
-- Определяет альбом по году для песен, входящих в Regional At Best и Vessel
function p.detectAlbumByYear(year)
if not year then return "Vessel" end -- По умолчанию Vessel, если год не определен
if year <= 2012 then
return "Regional At Best"
else
return "Vessel"
end
end
-- Выбирает альбом для песни на основе данных и года страницы
function p.selectAlbum(songTitle, albums, year)
if not albums then
return { "Non-Album" }
end
-- Проверяем, входит ли песня одновременно в Regional At Best и Vessel
if #albums == 2 and
((albums[1] == "Regional At Best" and albums[2] == "Vessel") or
(albums[1] == "Vessel" and albums[2] == "Regional At Best")) then
local forcedAlbum = p.detectAlbumByYear(year)
return { forcedAlbum }
end
-- Для всех остальных песен возвращаем альбомы из data.songs
return albums
end
return p