3415
редагувань
Admin (обговорення | внесок) Немає опису редагування |
Admin (обговорення | внесок) Немає опису редагування |
||
Рядок 31: | Рядок 31: | ||
mw.log("Page content loaded, length: ", string.len(content)) | mw.log("Page content loaded, length: ", string.len(content)) | ||
mw.log("Page content preview: ", mw.ustring.sub(content, 1, 500)) | |||
local rating_section = mw.ustring.match(content, "== Рейтинг ==.-{| class=\"wikitable sortable\"(.-)|}") | local rating_section = mw.ustring.match(content, "== Рейтинг ==.-{| class=\"wikitable sortable\"(.-)|}") | ||
if not rating_section then | if not rating_section then | ||
mw.log("Error: Rating section not found within the page content.") | mw.log("Error: Rating section not found within the page content.") | ||
mw.log("Page content: ", content) | |||
return "Rating section not found" | return "Rating section not found" | ||
end | end | ||
mw.log("Rating section extracted, length: ", string.len(rating_section)) | mw.log("Rating section extracted, length: ", string.len(rating_section)) | ||
mw.log("Rating section preview: ", mw.ustring.sub(rating_section, 1, 500)) | |||
-- Adjusted to fetch the player's position (column 1 "№") instead of points | -- Adjusted to fetch the player's position (column 1 "№") instead of points | ||
local pattern = "|%s*(%d+)%s*|%s*%[%[" .. mw.ustring.gsub(player, "([%(%)%.%-%+])", "%%%1") .. "%]%]" | local pattern = "|%s*(%d+)%s*|%s*%[%[" .. mw.ustring.gsub(player, "([%(%)%.%-%+%[%]])", "%%%1") .. "%]%]" | ||
local direct_pattern = "|%s*(%d+)%s*|%s*" .. mw.ustring.gsub(player, "([%(%)%.%-%+])", "%%%1") .. "%s*" | local direct_pattern = "|%s*(%d+)%s*|%s*" .. mw.ustring.gsub(player, "([%(%)%.%-%+%[%]])", "%%%1") .. "%s*" | ||
local rank = mw.ustring.match(rating_section, pattern) or mw.ustring.match(rating_section, direct_pattern) | local rank = mw.ustring.match(rating_section, pattern) or mw.ustring.match(rating_section, direct_pattern) | ||
if not rank then | if not rank then | ||
mw.log("Error: Player not found in season rankings or regex failed.") | mw.log("Error: Player not found in season rankings or regex failed.") | ||
mw.log("Pattern used: ", pattern) | |||
mw.log("Direct pattern used: ", direct_pattern) | |||
return "--" | return "--" | ||
end | end |