Code: Select all
if Error then
-- ERROR; QUEUE MESSAGES
Queue['FeedTitle'] = Error.Title
Queue['FeedLink'] = Error.Link
Queue['Item1Title'] = Error.Description
Queue['Item1Link'] = Error.Link
Queue['Item1Desc'] = ''
Queue['Item1End'] = ''
Queue['Item1Date'] = ''
Queue['Item1Unread'] = 0
for i = 2, MinItems do
Queue['Item'..i..'Title'] = ''
Queue['Item'..i..'Link'] = ''
Queue['Item'..i..'Desc'] = ''
Queue['Item'..i..'End'] = ''
Queue['Item'..i..'Date'] = ''
Queue['Item'..i..'Unread'] = 0
end
else
-- NO ERROR; QUEUE FEED
Queue['FeedTitle'] = Feed.Title
Queue['FeedLink'] = Feed.Link or ''
for i = 1, math.max(#Feed, MinItems) do
local Item = Feed[i] or {}
Queue['Item'..i..'Title'] = Item.Title or ''
Queue['Item'..i..'Link'] = Item.Link or Feed.Link or ''
Queue['Item'..i..'Desc'] = Item.Desc or ''
Queue['Item'..i..'Unread'] = Item.Unread or ''
Queue['Item'..i..'End'] = Item.End and os.date(Timestamp, Item.End) or "
Queue['Item'..i..'Date'] = Item.Date and os.date(Timestamp, Item.Date) or ''
-- print(Item.Title..Item.Date)
end
end
-- SET VARIABLES
local VariablePrefix = SELF:GetOption('VariablePrefix', '')
for k, v in pairs(Queue) do
SKIN:Bang('!SetVariable', VariablePrefix..k, v)
end
-- FINISH ACTION
local FinishAction = SELF:GetOption('FinishAction', '')
if FinishAction ~= '' then
SKIN:Bang(FinishAction)
end
return Error and Error.Description or 'Finished #'..f..' ('..Feed.MeasureName..'). Name: '..Feed.Title..'. Type: '..Feed.Type..'. Items: '..#Feed..'.'
end
-----------------------------------------------------------------------
-- EXTERNAL COMMANDS
function Refresh(a)
a = a and tonumber(a) or f
if a == f then
SKIN:Bang('!UpdateMeasure', SELF:GetName())
else
Input(a)
end
end
function Show(a)
f = tonumber(a)
SKIN:Bang('!UpdateMeasure', SELF:GetName())
end
function ShowNext()
f = (f % #Feeds) + 1
SKIN:Bang('!UpdateMeasure', SELF:GetName())
end
function ShowPrevious()
f = (f == 1) and #Feeds or (f - 1)
SKIN:Bang('!UpdateMeasure', SELF:GetName())
end
function MarkRead(a, b)
b = b and tonumber(b) or f
Feeds[b][a].Unread = 0
UserInput = true
SKIN:Bang('!UpdateMeasure', SELF:GetName())
end
function MarkUnread(a, b)
b = b and tonumber(b) or f
Feeds[b][a].Unread = 1
UserInput = true
SKIN:Bang('!UpdateMeasure', SELF:GetName())
end
function ToggleUnread(a, b)
b = b and tonumber(b) or f
Feeds[b][a].Unread = 1 - Feeds[b][a].Unread
UserInput = true
SKIN:Bang('!UpdateMeasure', SELF:GetName())
end
-----------------------------------------------------------------------
-- TYPES
function DefineTypes()
Types = {
RSS = {
MatchLink = '<link.->(.-)</link>',
MatchItem = '<item.-</item>',
MatchItemID = '<guid.->(.-)</guid>',
MatchItemLink = '<link.->(.-)</link>',
MatchItemDesc = '<description.->(.-)</description>',
MatchItemEnd = '<pubDate.->(.-)</pubDate>',
MatchItemDate = '<pubDate.->(.-)</pubDate>',
MergeItems = true,
ParseDate = function(s)
local Date = {}
local MatchTime = '%a%a%a, (%d%d) (%a%a%a) (%d%d%d%d) (%d%d)%:(%d%d)%:(%d%d) (.-)$'
local MatchDate = '%a%a%a, (%d%d) (%a%a%a) (%d%d%d%d)$'
if s:match(MatchTime) then
Date.day, Date.month, Date.year, Date.hour, Date.min, Date.sec, Date.Offset = s:match(MatchTime)
elseif s:match(MatchDate) then
Date.day, Date.month, Date.year = s:match(MatchDate)
end
return (Date.year and Date.month and Date.day) and Date or nil
end
},
Atom = {
MatchLink = '<link.-href=["\'](.-)["\']',
MatchItem = '<entry.-</entry>',
MatchItemID = '<id.->(.-)</id>',
MatchItemLink = '<link.-href=["\'](.-)["\']',
MatchItemDesc = '<summary.->(.-)</summary>',
MatchItemEnd = '<modified.->(.-)</modified>',
MatchItemDate = '<modified.->(.-)</modified>',
MergeItems = true,
ParseDate = function(s)
local Date = {}
local MatchTime = '(%d%d%d%d)%-(%d%d)%-(%d%d)T(%d%d)%:(%d%d)%:(%d%d)(.-)$'
local MatchDate = '(%d%d%d%d)%-(%d%d)%-(%d%d)$'
if s:match(MatchTime) then
Date.year, Date.month, Date.day, Date.hour, Date.min, Date.sec, Date.Offset = s:match(MatchTime)
elseif s:match(MatchDate) then
Date.year, Date.month, Date.day = s:match(MatchDate)
end
return Date
end
},
iCalendar = {
MatchLink = 'UID:(%S+)',
MatchItem = 'BEGIN:VEVENT.-END:VEVENT',
MatchItemID = 'UID:(%S+)',
MatchItemLink = 'UID:(%S+)',
MatchItemDesc = 'DESCRIPTION:(.-)\n',
MatchItemEnd = 'DTEND.-UID',
MatchItemDate = 'DTSTART.-UID',
MergeItems = false,
ParseDate = function(s)