(block)
| 9 | } |
| 10 | |
| 11 | function parseFeed(block) { |
| 12 | const feed = block.content, |
| 13 | match = /^(\[(.+?)\]\((.+?)\)\s*\nSCHEDULED: <([\d-]+) \w+ ([\d:]+)) \.\+(\d+)(\w)>\n(?:<!-{2} REGEXP: \/(.+?)\/ -{2}>\n)?(?:<!-{2} WINDOW: (\d+) -{2}>\n)?$/.exec(feed + "\n"); |
| 14 | |
| 15 | const date = new Date(match[4] + " " + match[5]), |
| 16 | title = match[2], |
| 17 | url = match[3], |
| 18 | interval = match[6], |
| 19 | unit = match[7], |
| 20 | intervalMultiplier = { h: 3600, d: 3600*24, w: 3600*24*7, m: 3600*24*30, y: 3600*24*365 }[unit], |
| 21 | [re, selector] = (match[8] ?? "(.+)/$1").split("/"), |
| 22 | window = +(match[9] ?? "0") * 1000; |
| 23 | |
| 24 | return { |
| 25 | block, title, url, date, |
| 26 | interval: interval * intervalMultiplier * 1000, |
| 27 | toReplace: match[1], re: new RegExp(re), selector, |
| 28 | window, |
| 29 | }; |
| 30 | } |
| 31 | |
| 32 | async function refreshFeeds({ forceRefresh = false } = {}) { |
| 33 | // Parse feeds. |
nothing calls this directly
no outgoing calls
no test coverage detected