Skip to content
shouya edited this page Dec 24, 2023 · 14 revisions

Remove gifs or ad elements

filters:
  - remove_element:
      - 'img[src$=".gif"]'
      - ".ad, .banner"

Hacker News top links

- 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"

Inspect all fields in a post

  - 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.

Scan for magnet links and put into enclosure

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;
      }
Clone this wiki locally