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

34 байти вилучено ,  17 квітня 2024
нема опису редагування
Немає опису редагування
Немає опису редагування
Рядок 10: Рядок 10:
     }
     }


    -- Log the input variables for debugging
     mw.log("Season index: ", season)
     mw.log("Season index: ", season)
     mw.log("Player name: ", player)
     mw.log("Player name: ", player)


     local season_title = season_titles[tonumber(season)]
     local season_title = season_titles[tonumber(season)]
    if not season_title then
        mw.log("Error: Invalid season number provided.")
        return "Invalid season number"
    end
     mw.log("Season page title: ", season_title)
     mw.log("Season page title: ", season_title)


     local title = mw.title.makeTitle(0, season_title)
     local title = mw.title.makeTitle(0, season_title)
     local content = title:getContent()
     local content = title:getContent()
     if not content then
     if not content then
         mw.log("Error: Content not found for the season page.")
         mw.log("Error: Content not found for the season page.")
         return "Season page not found"
         return "Season page not found"
     end
     end
    mw.log("Page content loaded, length: ", string.len(content))


     local rating_section = mw.ustring.match(content, "== Рейтинг ==.-{| class=\"wikitable sortable\"(.-)|}")
     local rating_section = mw.ustring.match(content, "== Рейтинг ==.-{| class=\"wikitable sortable\"(.-)|}")
Рядок 34: Рядок 31:
         return "Rating section not found"
         return "Rating section not found"
     end
     end
    mw.log("Rating section extracted, length: ", string.len(rating_section))


     local pattern = "|%s*%[%[" .. mw.ustring.gsub(player, "([%(%)%.%-%+])", "%%%1") .. "|[^%]]+%]%]%s*|%s*(%d+)%s*|"
     local pattern = "|%s*%[%[" .. mw.ustring.gsub(player, "([%(%)%.%-%+])", "%%%1") .. "|[^%]]+%]%]%s*|%s*(%d+)%s*|"