- Change default DeepSeek model from deepseek-chat to deepseek-reasoner
- Apply consistent double quotes, line endings, and import organization
- Add # noqa comments for flake8 compliance
- Update documentation and configuration files
💘 Generated with Crush
Assisted-by: Deepseek V3.2 (Thinking) via Crush <crush@charm.land>
|
||
|---|---|---|
| src | ||
| templates | ||
| .crush.json | ||
| .env.example | ||
| .gitignore | ||
| AGENTS.md | ||
| deepseek_newsletter.py | ||
| default.yaml | ||
| LICENSE | ||
| README.md | ||
| requirements.txt | ||
| themes.yaml | ||
News.Abolish.Capital Summary Tool
A Python tool that generates analytical newsletters from Lemmy posts using the DeepSeek API. The tool applies a Materialist Dialectical World View to analyze news through the lens of historical materialism, class struggle, and structural power dynamics.
Features
- Lemmy Integration: Fetches posts from a Lemmy instance local feed
- AI-Powered Analysis: Uses DeepSeek API to generate insightful newsletters
- Thematic Categorization: Configurable theme system for organizing articles by topic
- Flexible Output: Generates markdown newsletters with timestamped filenames
- Command-line Interface: Extensive options for customization
- Environment Configuration: Supports
.envfiles for API keys and settings - Theme Analysis: AI-assisted theme configuration suggestions
Installation
Prerequisites
- Python 3.x
- DeepSeek API key (get one here)
Install Dependencies
pip install requests html2text PyYAML
Or using requirements.txt:
pip install -r requirements.txt
Or create a virtual environment:
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
pip install -r requirements.txt
Quick Start
-
Clone the repository
git clone https://forge.redwizard.party/RedWizard/news-summary-bot.git cd news-summary-bot -
Configure environment
cp .env.example .env # Edit .env and add your DeepSeek API key -
Run the newsletter generator
python deepseek_newsletter.py
The script will fetch the latest weekly articles from abolish.capital and generate a newsletter in deepseek_newsletter_YYYYMMDD_HHMMSS.md.
Configuration
Environment Variables
Create a .env file based on .env.example:
# DeepSeek API key (required)
DEEPSEEK_API_KEY=sk-your-key-here
# Lemmy instance credentials (required)
LEMMY_INSTANCE_URL=https://lemmy.example.com
LEMMY_USERNAME=your_username
LEMMY_PASSWORD=your_password
Note: Most other settings (sort type, model parameters, etc.) are now configured in default.yaml.
Theme Configuration
Edit themes.yaml to customize article categorization:
categories: Maps RSS feed categories to display namesthemes: Array of themes with associated keywords for categorizationdefault_theme: Fallback theme for uncategorized articles
Example theme configuration:
{
"themes": [
{
"name": "Labor & Economy",
"keywords": ["worker", "union", "strike", "wages", "billionaire"]
},
{
"name": "Imperialism & Foreign Policy",
"keywords": ["war", "sanctions", "intervention", "military", "NATO"]
}
]
}
Usage
Basic Commands
# Generate weekly newsletter with default settings
python deepseek_newsletter.py
# Generate daily newsletter
python deepseek_newsletter.py --sort TopDay
# Generate newsletter with custom output file
python deepseek_newsletter.py --output newsletter.md
# Dry run (see prompt without API call)
python deepseek_newsletter.py --dry-run
# Limit to 10 articles and fetch full content
python deepseek_newsletter.py --max-articles 10 --fetch-content
# Analyze themes and suggest config updates
python deepseek_newsletter.py --analyze-themes
Command Line Arguments
| Argument | Description | Default |
|---|---|---|
--rss-source |
RSS feed URL or local file | abolish.capital TopWeek |
--sort |
Sort period (TopWeek, TopDay, TopMonth, etc.) | TopWeek |
--output, -o |
Output file path | auto-generated |
--model |
DeepSeek model | deepseek-reasoner |
--temperature |
Generation temperature | 0.7 |
--max-tokens |
Max response tokens | 4000 |
--timeout |
API timeout (seconds) | 60 |
--dry-run |
Print prompt without API call | false |
--api-key |
DeepSeek API key | from env var |
--max-articles |
Limit articles processed | 0 (all) |
--fetch-content |
Fetch full article content | false |
--analyze-themes |
Analyze themes and suggest updates | false |
Sorting Options
Available sort periods for RSS feeds:
TopHour,TopSixHour,TopTwelveHourTopDay,TopWeek,TopMonth,TopYearTopAll,TopThreeMonths,TopSixMonths,TopNineMonthsActive,Hot,New,OldMostComments,NewComments,Controversial,Scaled
Output Format
Newsletters are generated in markdown format with the following structure:
- Title & Introduction: Compelling title and overview of major themes
- Top Stories: 3-5 most significant developments with analysis
- Thematic Analysis: Articles grouped by interconnected themes
- Publication Spotlight: Patterns in coverage across publications
- Systemic Patterns: Broader patterns revealing capitalist contradictions
- Conclusion & Outlook: Summary and watchlist for coming period
Example output file: deepseek_newsletter_20251229_220542.md
Analytical Perspective
The newsletter generator applies a Materialist Dialectical World View, analyzing news through:
- Historical Materialism: Understanding events through material conditions
- Class Struggle: Analyzing power dynamics between social classes
- Structural Analysis: Connecting surface events to systemic forces
- Contradiction Analysis: Identifying tensions within capitalist society
The tone is rigorous yet accessible, avoiding both academic jargon and simplistic rhetoric.
Troubleshooting
Common Issues
API Timeout
# Increase timeout
python deepseek_newsletter.py --timeout 120
# Limit articles to reduce prompt size
python deepseek_newsletter.py --max-articles 15
SSL Certificate Errors The script includes fallback logic for expired certificates. Some sites may still fail.
403 Forbidden Errors Many news sites block automated requests. This is expected behavior.
Missing Dependencies
pip install requests html2text PyYAML
Debug Mode
# See detailed output
python deepseek_newsletter.py --dry-run
# Check environment variables
cat .env
Project Structure
summary-of-week/
├── deepseek_newsletter.py # Main script
├── requirements.txt # Python dependencies
├── config.json # Theme configuration
├── config.sample.json # Example configuration
├── .env.example # Environment template
├── .gitignore # Git ignore rules
├── LICENSE # MIT License
├── AGENTS.md # Agent documentation
└── README.md # This file
License
ANTI-CAPITALIST SOFTWARE LICENSE - see LICENSE file for details.
Contributing
- Fork the repository
- Create a feature branch
- Make changes
- Test with
--dry-run - Submit a pull request
Acknowledgments
- abolish.capital for the RSS feed
- DeepSeek for the AI API
- The Python community for feedparser, requests, and html2text libraries