Last active
June 25, 2024 22:24
-
-
Save styblope/8acb7a0d4f51a344175c0ee1bf2573a4 to your computer and use it in GitHub Desktop.
Read a day task from soarscore.com
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
---@diagnostic disable: lowercase-global | |
COMPETITION = "az-cup-2024-zbraslavice-2024" | |
CLASS = "club" | |
function parse_tasks(doc) | |
for c in string.gmatch(doc, "href=\"(%S+"..CLASS.."%S+%.tsk)\"") do | |
return c | |
end | |
return nil | |
end | |
request = xcsoar.http.Request:new("https://soarscore.com/competitions/"..COMPETITION.."/") | |
response = request:perform() | |
if (response.status == 200) then | |
task_url = parse_tasks(response.body) | |
if task_url then | |
print("Fetching task: "..task_url) | |
request = xcsoar.http.Request:new(task_url) | |
response = request:perform() | |
if response.status == 200 then | |
xcsoar.task.load_task(response.body) | |
alert("Day task loaded for \n"..COMPETITION..'/'..CLASS) | |
end | |
else | |
-- alert("No day task found for \n"..COMPETITION..'/'..CLASS) | |
error("No day task found for \n"..COMPETITION..'/'..CLASS) | |
end | |
else | |
-- alert("Competition not found") | |
error("Competition not found") | |
end | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment