-
Notifications
You must be signed in to change notification settings - Fork 134
Expand file tree
/
Copy pathindex.js
More file actions
64 lines (55 loc) · 1.51 KB
/
index.js
File metadata and controls
64 lines (55 loc) · 1.51 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
const { Client } = require('@notionhq/client');
const Parser = require('rss-parser');
const parser = new Parser();
const notion = new Client({ auth: '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' });
const readerDatabaseId = '13225bbf71c08112a0d6000ca2bf531c';
const feederDatabaseId = '13225bbf71c0818e8760000c9259a8b6';
const feeds = [
'https://obsidian.md/feed.xml',
'https://www.craft.do/feed/blog.xml',
'https://blog.logseq.com/rss/',
'https://forums.getdrafts.com/rss',
'https://community.bear.app/rss',
'https://www.redgregory.com/notion?format=rss',
'https://mythical.ink/de/blog',
'https://www.elderscrollsonline.com/en-us/rss'
];
async function fetchRSSFeeds() {
let allEntries = [];
for (const feed of feeds) {
const rss = await parser.parseURL(feed);
allEntries = allEntries.concat(rss.items);
}
return allEntries;
}
async function addEntriesToNotion(entries) {
for (const entry of entries) {
await notion.pages.create({
parent: { database_id: feederDatabaseId },
properties: {
Name: {
title: [
{
text: {
content: entry.title,
},
},
],
},
Link: {
url: entry.link,
},
Date: {
date: {
start: new Date(entry.pubDate).toISOString()
}
}
},
});
}
}
async function main() {
const rssEntries = await fetchRSSFeeds();
await addEntriesToNotion(rssEntries);
}
main().catch(console.error);