3415
редагувань
Admin (обговорення | внесок) Немає опису редагування |
Admin (обговорення | внесок) Немає опису редагування |
||
Рядок 5: | Рядок 5: | ||
local player = frame.args.player | local player = frame.args.player | ||
-- List of season titles corresponding to their URLs | |||
local season_titles = { | local season_titles = { | ||
"Перший_сезон", "Другий_сезон", "Третій_сезон", | "Перший_сезон", "Другий_сезон", "Третій_сезон", | ||
Рядок 14: | Рядок 15: | ||
end | end | ||
-- Fetch the page content using the correct 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() | ||
Рядок 20: | Рядок 22: | ||
end | end | ||
-- | -- Pattern to extract the ranking section and rank data | ||
local | local rating_section = mw.ustring.match(content, "== Рейтинг ==.-{| class=\"wikitable sortable\"(.-)|}") | ||
if | if not rating_section then | ||
return "Rating section not found" | |||
end | end | ||
local pattern = "|%s*%[%[" .. mw.ustring.gsub(player, "([%(%)%.%-%+])", "%%%1") .. "|[^%]]+%]%]%s*|%s*(%d+)%s*|" | 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 direct_pattern = "|%s*" .. mw.ustring.gsub(player, "([%(%)%.%-%+])", "%%%1") .. "%s*|%s*(%d+)%s*|" | ||
local | local rank = mw.ustring.match(rating_section, pattern) or mw.ustring.match(rating_section, direct_pattern) | ||
if not rank then | if not rank then | ||
return "Player not found in season rankings" | return "Player not found in season rankings" |