Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rss #19

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open

Rss #19

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
112 changes: 88 additions & 24 deletions .github/workflows/feed.yml
Original file line number Diff line number Diff line change
@@ -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
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!
4 changes: 2 additions & 2 deletions build.js
Original file line number Diff line number Diff line change
@@ -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));
64 changes: 64 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
@@ -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);