SC
sctech-tr/rsstools
tools for managing rss feeds in python
rsstools
A powerful Python tool for creating, editing, and managing RSS feeds with both programmatic and command-line interfaces.
Features
- Create new RSS feeds with all required elements
- Add, update, and remove items from feeds
- Load and save RSS feeds to XML files
- Validate feed structure and required elements
- Command-line interface for easy management
- Support for optional elements like author and publication date
Installation
Dependencies
First, ensure you have Python 3.7 or higher installed. This package requires the following dependencies:
click>=8.0.0
Installing via pip (recommended)
- Run this command:
pip install rsstoolsUsing via pyz
- Download the latest pyz from the releases tab.
- Make the file executable:
chmod +x rsstools.pyz- You can run it directly:
python rsstools.pyzIf you need to extract the contents:
unzip rsstools.pyz -d rsstools_extracted
cd rsstools_extractedInstalling from source
This package requires the following dependencies:
click>=8.0.0
- Clone the repository:
git clone https://github.com/sctech-tr/rsstools.git
cd rsstools- Install the package:
pip install .Usage
Command Line Interface
- Create a new RSS feed:
rsstools create -t "My Blog" -l "https://myblog.com" -d "My personal blog" -o feed.xml- Add an item to the feed:
rsstools add feed.xml \
-t "First Post" \
-l "https://myblog.com/first" \
-d "My first post" \
-a "John Doe" \
-p "2024-10-18T12:00:00"- List all items in a feed:
rsstools list feed.xml- Export items to JSON:
rsstools list feed.xml -o items.json- Update an item:
rsstools update feed.xml "https://myblog.com/first" -t "Updated Post Title"- Remove an item:
rsstools remove feed.xml "https://myblog.com/first"Python API
from rsstools import RSSFeedCreator
from datetime import datetime
# Create a new feed
feed = RSSFeedCreator(
title="My Blog",
link="https://myblog.com",
description="My personal blog about technology"
)
# Add an item
feed.add_item(
title="First Post",
link="https://myblog.com/first-post",
description="This is my first blog post",
author="John Doe",
pub_date=datetime.now()
)
# Save the feed
feed.save("blog_feed.xml")
# Load an existing feed
feed.load("blog_feed.xml")
# Update an item
feed.update_item(
guid="https://myblog.com/first-post",
title="Updated First Post"
)
# Remove an item
feed.remove_item(guid="https://myblog.com/first-post")
# Get all items
items = feed.get_items()Contributing
- Fork the repository
- Open a PR
License
This project is licensed under the GPL-3.0 License - see the LICENSE file for details.
Error Handling
The package uses custom exceptions (RSSToolsError) for error handling. Always wrap your code in try-except blocks when using the API:
from rsstools import RSSFeedCreator, RSSToolsError
try:
feed = RSSFeedCreator("My Blog", "https://myblog.com", "My blog description")
feed.save("feed.xml")
except RSSToolsError as e:
print(f"Error: {str(e)}")Common Issues and Solutions
- Invalid Feed Structure: Ensure your RSS feed follows the standard RSS 2.0 format.
- File Permissions: Make sure you have write permissions in the directory where you're saving the feed.
- Date Format: When using the CLI, provide dates in ISO format (YYYY-MM-DDTHH:MM:SS).
Getting Help
Use the --help flag with any command to see available options:
rsstools --help
rsstools create --help
rsstools add --helpOn this page
Languages
Python100.0%
Contributors
Latest Release
0.3.0October 18, 2024GNU General Public License v3.0
Created October 17, 2024
Updated November 30, 2024