Модуль:FetchData: відмінності між версіями

нема опису редагування
Немає опису редагування
Немає опису редагування
Рядок 5: Рядок 5:
     local player = frame.args.player
     local player = frame.args.player


     -- Determine the page title dynamically based on the season argument
     -- Adjusting page title retrieval based on season
     local season_titles = {
     local season_titles = {
         "Перший_сезон", "Другий_сезон", "Третій_сезон",
         "Перший_сезон", "Другий_сезон", "Третій_сезон",
Рядок 21: Рядок 21:
     end
     end


     -- Extract the "Рейтинг" section
     -- Improved pattern matching for player rank
     local rating_section = content:match("== Рейтинг ==.-{|")
    local pattern = "|%s*%[%[" .. mw.ustring.gsub(player, "([%(%)%.%-%+])", "%%%1") .. "|[^%]]+%]%]%s*|%s*(%d+)%s*|"
    local direct_pattern = "|%s*" .. mw.ustring.gsub(player, "([%(%)%.%-%+])", "%%%1") .. "%s*|%s*(%d+)%s*|"
   
    -- Attempt to find the player's data in the rating section
     local rating_section = mw.ustring.match(content, "== Рейтинг ==.-{| class=\"wikitable sortable\"(.-)|}")
     if not rating_section then
     if not rating_section then
         return "Rating section not found"
         return "Rating section not found"
     end
     end


    -- Lua patterns to match the player's data directly or linked
     local rank = mw.ustring.match(rating_section, pattern) or mw.ustring.match(rating_section, direct_pattern)
     local pattern = "|%s*%[%[" .. mw.ustring.gsub(player, "([%(%)%.%-%+])", "%%%1") .. "|[^%]]+%]%]%s*|%s*(%d+)%s*|"
    local direct_pattern = "|%s*" .. mw.ustring.gsub(player, "([%(%)%.%-%+])", "%%%1") .. "%s*|%s*(%d+)%s*|"
    local rank = rating_section:match(pattern) or rating_section:match(direct_pattern)
   
     if not rank then
     if not rank then
         return "Player not found in season rankings"
         return "Player not found in season rankings"