Module:Setlist/AlbumSelector: Difference between revisions

From TwentyOneWiki
Jump to navigation Jump to search
No edit summary
No edit summary
Line 1: Line 1:
-- Module:Setlist/AlbumSelector
local p = {}
local p = {}


-- Функция для определения альбома на основе года в заголовке страницы
-- Годы, при которых песня будет считаться из "Regional At Best"
function p.getAlbumForSong(frame)
local rabYears = {
    -- Получаем название текущей страницы
    ["2009"] = true, ["2010"] = true, ["2011"] = true, ["2012"] = true
     local pageTitle = mw.title.getCurrentTitle().text
}
 
-- Годы, при которых песня будет считаться из "Vessel"
local vesselYears = {
    ["2013"] = true, ["2014"] = true, ["2015"] = true, ["2016"] = true,
    ["2017"] = true, ["2018"] = true, ["2019"] = true, ["2020"] = true,
    ["2021"] = true, ["2022"] = true, ["2023"] = true, ["2024"] = true, ["2025"] = true
}
 
-- Перечень песен, которые одновременно находятся в RAB и Vessel
local conflictSongs = {
    ["Guns For Hands"] = true,
    ["Holding On To You"] = true,
    ["Ode To Sleep"] = true,
    ["Car Radio"] = true,
    ["Trees"] = true
}
 
-- Главная функция
function p.resolveAlbumList(songTitle)
     local page = mw.title.getCurrentTitle().text
    local year = string.match(page, '%.(%d%d%d%d)$')
      
      
     -- Извлекаем год из заголовка (ожидаем формат MM.YYYY, например, 03.2013)
     if not year then
    local year = pageTitle:match("%.%d%d%d%d$") or ""
        return nil -- год не указан — вернем nil, и основной модуль использует полные данные
    year = year:sub(2) -- Убираем точку, получаем только год (например, "2013")
     end
      
 
    -- Определяем списки годов для Regional At Best и Vessel
     local data = mw.loadData('Module:Setlist/Songs')
     local regionalAtBestYears = { ".2009", ".2010", ".2011", ".2012" }
     local original = data.songs[songTitle]
     local vesselYears = { ".2013", ".2014", ".2015", ".2016", ".2017", ".2018", ".2019", ".2020", ".2021", ".2022", ".2023", ".2024", ".2025" }
 
   
     if not original then
     -- Проверяем, входит ли год в Regional At Best
        return nil
    for _, y in ipairs(regionalAtBestYears) do
        if year == y then
            return "Regional At Best"
        end
     end
     end
   
 
     -- Проверяем, входит ли год в Vessel
     -- Фильтрация для конфликтных песен
     for _, y in ipairs(vesselYears) do
     if conflictSongs[songTitle] then
         if year == y then
         if rabYears[year] then
             return "Vessel"
            return {"Regional At Best"}
        elseif vesselYears[year] then
             return {"Vessel"}
        else
            return original
         end
         end
     end
     end
   
 
    -- Если год не найден, возвращаем Vessel по умолчанию
     return original
     return "Vessel"
end
end


return p
return p

Revision as of 19:18, 11 July 2025

Documentation for this module may be created at Module:Setlist/AlbumSelector/doc

-- Module:Setlist/AlbumSelector
local p = {}

-- Годы, при которых песня будет считаться из "Regional At Best"
local rabYears = {
    ["2009"] = true, ["2010"] = true, ["2011"] = true, ["2012"] = true
}

-- Годы, при которых песня будет считаться из "Vessel"
local vesselYears = {
    ["2013"] = true, ["2014"] = true, ["2015"] = true, ["2016"] = true,
    ["2017"] = true, ["2018"] = true, ["2019"] = true, ["2020"] = true,
    ["2021"] = true, ["2022"] = true, ["2023"] = true, ["2024"] = true, ["2025"] = true
}

-- Перечень песен, которые одновременно находятся в RAB и Vessel
local conflictSongs = {
    ["Guns For Hands"] = true,
    ["Holding On To You"] = true,
    ["Ode To Sleep"] = true,
    ["Car Radio"] = true,
    ["Trees"] = true
}

-- Главная функция
function p.resolveAlbumList(songTitle)
    local page = mw.title.getCurrentTitle().text
    local year = string.match(page, '%.(%d%d%d%d)$')
    
    if not year then
        return nil -- год не указан — вернем nil, и основной модуль использует полные данные
    end

    local data = mw.loadData('Module:Setlist/Songs')
    local original = data.songs[songTitle]

    if not original then
        return nil
    end

    -- Фильтрация для конфликтных песен
    if conflictSongs[songTitle] then
        if rabYears[year] then
            return {"Regional At Best"}
        elseif vesselYears[year] then
            return {"Vessel"}
        else
            return original
        end
    end

    return original
end

return p