-
Notifications
You must be signed in to change notification settings - Fork 4
Cookbook
shouya edited this page Mar 8, 2024
·
14 revisions
filters:
- remove_element:
- 'img[src$=".gif"]'
- ".ad, .banner"
- path: /hn-best.xml
source: https://news.ycombinator.com/best
note: Hacker News Top Links
filters:
- split:
title_selector: ".titleline > a"
link_selector: ".titleline > a"
description_selector: "tr.athing + tr"
- path: /inspect.xml
note: Utility for inspecting RSS feeds
filters:
- js: |
function update_post(feed, post) {
post.content = `<pre>${JSON.stringify(post, null, 2)}</pre>`;
return post;
}
Note you need to supply ?source=http://your-domain.com/feed.xml
in the query string if you omit the source
field in the endpoint definition.
filters:
- js: |
function find_magnet(text) {
const regex = /\b(?<info_hash>[0-9a-fA-F]{40})\b/g;
const match = regex.exec(text);
if (match === null) {
return null;
}
return `magnet:?xt=urn:btih:${match.groups.info_hash}`;
}
function update_post(feed, post) {
if (post.enclosures) {
return post;
}
if (post.description === null) {
return post;
}
const magnet = find_magnet(post.description);
if (magnet === null) {
return post;
}
post.enclosure = {
url: magnet,
mime_type: "application/x-bittorrent",
length: '1337'
};
return post;
}
- path: /reddit-comments.xml
source: https://www.reddit.com/r/selfhosted.rss
filters:
- js: |
function modify_post(feed, post) {
const comment_regex = /<a\b[^>]*href="(?<url>[^"]+)"[^>]*>\[comments\]<\/a>/;
const match = comment_regex.exec(post.content.value);
if (match === null) {
return post;
}
// redirect to old reddit
const url = match.groups.url.replace(/www\.reddit\.com/, "old.reddit.com");
post.links[0].href = url;
return post;
}
- full_text:
keep_element: .nestedlisting
append_mode: true
Note that you can leave out the source
field and supply any reddit's official rss via the ?source=
parameter. e.g. http://example.com/reddit-comments.xml?source=https://old.reddit.com/r/selfhosted/top/.rss.
https://github.com/ajayyy/DeArrow is a crowdsourced database providing de-clickbait-ed YouTube title and thumbnail. The following config demonstrate the use of fetch
API in modify_post
to replace the YouTube feed's title and thumbnail.
- path: /kurtzgesagt-dearrow.xml
source: https://www.youtube.com/feeds/videos.xml?channel_id=UCsXVk37bltHxD1rDPwtNM8Q
filters:
- modify_post: |
const video_id = post.id.split(':').pop();
let resp = await fetch(`https://sponsor.ajay.app/api/branding?videoID=${video_id}`);
if (resp.status == 200) {
let [{title}] = resp.json().titles;
post.title.value = title;
}
let thumbnail = post.extensions.media.group.filter(g => g.name == 'media:group')[0].children.thumbnail[0];
thumbnail.attrs.url = `https://dearrow-thumb.ajay.app/api/v1/getThumbnail?videoID=${video_id}`;
- path: /kurtzgesagt-dearrow.xml
source: https://www.youtube.com/feeds/videos.xml?channel_id=UCsXVk37bltHxD1rDPwtNM8Q
filters:
- modify_post: |
if (post.title.value.includes('#shorts')) {
return null;
}