17.01.2022, 08:34
Here's an example that you can use a starting point. data variable should contain the ICS file contents that you get externally.
First the script parses ICS events into a table. Then it looks for an event with a matching date. summary variable is the summary field (kind of garbage in your case) of the found event or an empty string. Change 1/1/1 as needed and use 250 byte string as the data type of this object.
First the script parses ICS events into a table. Then it looks for an event with a matching date. summary variable is the summary field (kind of garbage in your case) of the found event or an empty string. Change 1/1/1 as needed and use 250 byte string as the data type of this object.
Code:
url = 'https://p35-caldav.icloud.com/published/2/MTQzMzA1NjcxOTE0MzMwNXFFkpAlN-RmUw02iYPAHdjXli1qufT3m2kVvFAFS2VXJLUhJ6r02NrhV15B8p_WoReJ0k5wrU4I1th5F6eq8UI'
data, err = require('socket.http').request(url)
if not data then
log('request failed', err)
return
end
data = data:split('\n')
events = {}
for _, line in ipairs(data) do
line = line:trim()
if line == 'BEGIN:VEVENT' then
event = {}
elseif line == 'END:VEVENT' then
events[ #events + 1 ] = event
event = nil
elseif event then
pos = line:find(':')
if pos then
key = line:sub(1, pos - 1)
value = line:sub(pos + 1)
event[ key ] = value
end
end
end
now = os.date('%Y%m%d')
summary = ''
for _, event in ipairs(events) do
if event['DTSTART;VALUE=DATE'] == now then
summary = event['SUMMARY']
break
end
end
grp.checkupdate('1/1/1', summary)