From 6eed4b31087393dc484f8acf68883acb8eccc4c7 Mon Sep 17 00:00:00 2001 From: Thea <147770166+Thea2002@users.noreply.github.com> Date: Sat, 2 Nov 2024 14:17:42 +0100 Subject: [PATCH 1/6] Update feed.yml --- .github/workflows/feed.yml | 112 +++++++++++++++++++++++++++++-------- 1 file changed, 88 insertions(+), 24 deletions(-) diff --git a/.github/workflows/feed.yml b/.github/workflows/feed.yml index c1fc708..b94479c 100644 --- a/.github/workflows/feed.yml +++ b/.github/workflows/feed.yml @@ -1,24 +1,88 @@ -name: Feed Cron - -on: - schedule: - - cron: "0 * * * *" # UTC - workflow_dispatch: - -jobs: - get-feed: - runs-on: ubuntu-latest - env: - NOTION_KEY: ${{ secrets.NOTION_KEY }} - NOTION_READER_DATABASE_ID: ${{ secrets.NOTION_READER_DATABASE_ID }} - NOTION_FEEDER_DATABASE_ID: ${{ secrets.NOTION_FEEDER_DATABASE_ID }} - steps: - - name: Setup Node - uses: actions/setup-node@v2 - with: - node-version: 14 - - - name: Update Notion Feed - run: | - curl -o bundle.cjs https://raw.githubusercontent.com/watsuyo/notion-rss-reader/bundle/dist/bundle.cjs - node bundle.cjs +Großartig, dass du das Repository geforked hast! Jetzt kannst du den Code anpassen und ausführen: + +1. **Klonen deines geforkten Repositories**: + ```bash + git clone https://github.com/Thea2002/notion-rss-reader.git + cd notion-rss-reader + ``` + +2. **Erforderliche Bibliotheken installieren**: + ```bash + npm install @notionhq/client rss-parser + ``` + +3. **Code einfügen**: Öffne die Datei `index.js` (erstelle sie, falls sie nicht existiert) und füge den folgenden Code ein: + + ```javascript + 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 are concatenated into 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); + ``` + +4. **Skript ausführen**: + ```bash + node index.js + ``` + +Das Skript ruft die RSS-Feeds ab und fügt die Einträge in deine Notion-Datenbanken ein. Wenn du auf Probleme stößt oder weitere Fragen hast, bin ich hier, um zu helfen! From 09cad3320c6c611eb9ce822d76af9a98aa2f3b8f Mon Sep 17 00:00:00 2001 From: Thea <147770166+Thea2002@users.noreply.github.com> Date: Sat, 2 Nov 2024 14:23:13 +0100 Subject: [PATCH 2/6] Create index.js --- index.js | 64 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 64 insertions(+) create mode 100644 index.js diff --git a/index.js b/index.js new file mode 100644 index 0000000..0f59b90 --- /dev/null +++ b/index.js @@ -0,0 +1,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); From adf82ed31bed7508b168a837fde215c916924ebb Mon Sep 17 00:00:00 2001 From: Thea <147770166+Thea2002@users.noreply.github.com> Date: Sat, 2 Nov 2024 14:28:23 +0100 Subject: [PATCH 3/6] Update build.js --- build.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/build.js b/build.js index aff47cd..8a81d41 100644 --- a/build.js +++ b/build.js @@ -1,8 +1,8 @@ -import { build } from 'esbuild' +import { build } from 'esbuild'; build({ entryPoints: ['src/index.ts'], bundle: true, platform: 'node', outfile: 'dist/bundle.cjs', -}).catch(() => process.exit(1)) +}).catch(() => process.exit(1)); From 811e92d20d07f1fdd939a78fd4931fac844f241d Mon Sep 17 00:00:00 2001 From: Thea <147770166+Thea2002@users.noreply.github.com> Date: Sat, 2 Nov 2024 14:29:32 +0100 Subject: [PATCH 4/6] Delete build.js --- build.js | 8 -------- 1 file changed, 8 deletions(-) delete mode 100644 build.js diff --git a/build.js b/build.js deleted file mode 100644 index 8a81d41..0000000 --- a/build.js +++ /dev/null @@ -1,8 +0,0 @@ -import { build } from 'esbuild'; - -build({ - entryPoints: ['src/index.ts'], - bundle: true, - platform: 'node', - outfile: 'dist/bundle.cjs', -}).catch(() => process.exit(1)); From ff9789d6fc99e159659f5f0600924a542da4214d Mon Sep 17 00:00:00 2001 From: Thea <147770166+Thea2002@users.noreply.github.com> Date: Sat, 2 Nov 2024 14:30:19 +0100 Subject: [PATCH 5/6] Create build.js --- build.js | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 build.js diff --git a/build.js b/build.js new file mode 100644 index 0000000..8a81d41 --- /dev/null +++ b/build.js @@ -0,0 +1,8 @@ +import { build } from 'esbuild'; + +build({ + entryPoints: ['src/index.ts'], + bundle: true, + platform: 'node', + outfile: 'dist/bundle.cjs', +}).catch(() => process.exit(1)); From 73b0dfafdcbc4ec2804fa0a6ff56e1ad8a7903f8 Mon Sep 17 00:00:00 2001 From: Thea <147770166+Thea2002@users.noreply.github.com> Date: Sat, 2 Nov 2024 14:40:16 +0100 Subject: [PATCH 6/6] feed.yml --- .github/workflows/feed.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/feed.yml b/.github/workflows/feed.yml index b94479c..0862e62 100644 --- a/.github/workflows/feed.yml +++ b/.github/workflows/feed.yml @@ -1,4 +1,4 @@ -Großartig, dass du das Repository geforked hast! Jetzt kannst du den Code anpassen und ausführen: +Repository geforked hast! Jetzt kannst du den Code anpassen und ausführen: 1. **Klonen deines geforkten Repositories**: ```bash