跳到正文
GitHub·· 7 天前AI 评分22

francois-feed:基于 Gemini API 的轻量级 RSS 生成器

phine-apps/francois-feed

AI 导读

francois-feed 是一个由 Gemini API 驱动的轻量级 RSS 生成器,可根据自定义提示词生成 RSS 2.0 feed,并输出到 stdout、本地文件或更新 GitHub Gist。

正文

A lightweight RSS feed generator powered by Gemini API. It generates an RSS 2.0 feed based on a custom prompt and can update a GitHub Gist or save to a local file.

Features

  • AI-Powered: Uses Gemini 3.8 Flash (with Gemini 2.5 Flash for search grounding) to generate relevant and structured RSS content.
  • Flexible Output: Supports stdout, local file output, and GitHub Gist updates.
  • Fast & Modern: Built with Python and managed by uv for high performance and reproducible environments.
  • CI/CD Ready: Integrated with GitHub Actions for daily automated updates.

Setup

Prerequisites

  • uv (recommended)
  • Gemini API Key (get one here)
  • GitHub Gist (if using Gist update feature)
  • GitHub Token (Personal Access Token with gist scope)

Note

This project runs comfortably within the Gemini API Free Tier. For detailed pricing and quota information, please refer to the Gemini API Pricing page.

Installation

git clone https://github.com/phine-apps/francois-feed.git
cd francois-feed
uv sync

Environment Variables

A .env.example template is included in the repository. Copy it and fill in your values:

cp .env.example .env

Caution

Never commit your .env file. It is excluded by .gitignore, but always double-check before pushing.

Set the following environment variables in your .env:

Required

  • GEMINI_API_KEY: Your Gemini API key.
  • RSS_CONFIG_PROMPT: Instructions for the AI on what content to generate.
  • GH_TOKEN: GitHub Personal Access Token with gist scope (required for -g).

Optional

  • GIST_ID: GitHub Gist ID to update (can also be passed via -g).
  • GEMINI_SEARCH_MODEL: Gemini model for query planning and web search (defaults to gemini-2.5-flash).
  • GEMINI_GEN_MODEL: Gemini model for RSS XML generation (defaults to gemini-3.8-flash).
  • GEMINI_MODEL: Legacy single-model override fallback for both search and generation.
  • TZ: Timezone used for date calculations and logging (defaults to OS system timezone, e.g., Asia/Tokyo).
  • ENABLE_MEDIA_THUMBNAILS: Set to true to fetch og:image from source URLs and embed <media:thumbnail> tags (defaults to false).

Configuration Example

For the RSS_CONFIG_PROMPT environment variable, you can use a prompt like this:

Generate an RSS feed covering:
1. Global News: Top 3 international headlines (e.g., from Reuters or AP).
2. Tech Trends: Latest updates in Web Development and open-source projects.
3. Productivity: A practical tip for remote work or time management.
4. Science & Environment: Brief news on space exploration or climate research.

Format: Use professional tone. Summaries should be 200-300 characters long.

Usage

Run the script using uv:

# Preview to stdout
uv run main.py

# Output to a local file
uv run main.py -o daily.rss

# Update a GitHub Gist
uv run main.py -g your_gist_id_here

Tip

To get a Gist ID, create a new Gist at gist.github.com with a file named my_rss.xml containing some dummy content (e.g., "dummy"). The ID is the alphanumeric string at the end of the Gist's URL.

You can also set environment variables in a .env file for local development. uv will automatically load them if configured, or you can use export $(cat .env | xargs) before running.

CLI Options

  • -h, --help: Show help message.
  • -o, --output OUTPUT: Path to save the generated RSS xml.
  • -g, --gist GIST: GitHub Gist ID to update.
  • --no-dedup: Disable deduplication against previous results.

GitHub Actions (Automation)

The project includes a workflow in .github/workflows/daily_rss.yml that runs daily. To use it, configure the following:

Secrets

The following should be configured as GitHub Secrets:

  • GEMINI_API_KEY
  • RSS_CONFIG_PROMPT
  • GH_TOKEN
  • GIST_ID (Passed to the script via the -g flag in the workflow)

Variables

  • SCHEDULE_HOUR_JST: The hour (0-23) in Japan Standard Time at which you want the feed to be generated.

Optional Variables / Secrets

  • ENABLE_MEDIA_THUMBNAILS: Set to true to enable thumbnail extraction in the daily workflow.
  • GEMINI_SEARCH_MODEL: Custom Gemini model for search grounding (e.g., gemini-2.5-flash).
  • GEMINI_GEN_MODEL: Custom Gemini model for RSS generation (e.g., gemini-3.8-flash or gemini-3.1-pro).

Adding to RSS Readers

The following RSS readers have been verified to work correctly with Gist's raw URLs:

  • Feeder (Android)
  • FocusReader (Android)
  • NetNewsWire (macOS)
  1. Get the Raw URL: Open your Gist and click the "Raw" button.
  2. Remove Commit Hash: The URL will look like .../raw/long-hash/my_rss.xml. Remove the long-hash/ part to get the latest version.
    • Correct Persistent URL: https://gist.githubusercontent.com/user/id/raw/my_rss.xml
  3. Add to Reader: Open your app, search for this URL, and add it.

Note

Some RSS readers may fail to read this URL directly. If you encounter issues, consider using one of the recommended apps above.

License

This project is licensed under the MIT License - see the LICENSE file for details.

来源:GitHub · github.com