Asynchronous RSS/Atom feeds generation for Starlette, adapted from Django syndication feed framework.
This project has been quarantined.
PyPI Admins need to review this project before it can be restored. While in quarantine, the project is not installable by clients, and cannot be being modified by its maintainers.
Read more in the project in quarantine help article.
Project description
Starlette FeedGen
Asynchronous RSS/Atom feeds generation for Starlette, adapted from Django syndication feed framework.
Note that in version 0.1.4 and higher we support only Python 3.10+ and all library classes now provide asynchronous methods. If any of these does not meet your needs please consider using version 0.1.3 of the library.
Installation
pip install starlette-feedgen
Usage
Here's a simple example of handling route /feed using FeedEndpoint class.
from typing import NamedTuple
from starlette.applications import Starlette
from starlette_feedgen import FeedEndpoint
class FeedItem(NamedTuple):
title = 'Hello'
description = 'There'
link = 'http://example.com/article'
app = Starlette()
@app.route('/feed')
class Feed(FeedEndpoint):
title = 'Example RSS Feed'
description = 'With example item'
link = 'http://example.com'
async def get_items(self):
def item_generator():
yield FeedItem()
return item_generator()
Example RSS Output:
<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
<channel>
<title>Example RSS Feed</title>
<link>http://example.com</link>
<description>With example item</description>
<atom:link rel="self" href="/feed"></atom:link>
<lastBuildDate>Thu, 20 Oct 2022 12:46:17 +0000</lastBuildDate>
<item>
<title>Hello</title>
<link>http://example.com/article</link>
<description>There</description>
<guid>http://example.com/article</guid>
</item>
</channel>
</rss>
Note that FeedEndpoint creates a feed generator object Rss201rev2Feed under the hood.
You can explicitly import a feed generator class and work with it, for example:
import aiofiles
import asyncio
from starlette_feedgen.generator import Rss201rev2Feed
feed = Rss201rev2Feed(
title='Poynter E-Media Tidbits',
link='http://www.poynter.org/column.asp?id=31',
description='A group Weblog by the sharpest minds in online media/journalism/publishing.',
language='en',
)
feed.add_item(
title='Hello',
link='http://www.holovaty.com/test/',
description='Testing.'
)
async def write_to_file():
async with aiofiles.open('test.rss', 'w') as f:
await feed.write(f, 'utf-8')
asyncio.run(write_to_file())
RSS Output:
<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0"
xmlns:atom="http://www.w3.org/2005/Atom">
<channel>
<title>Poynter E-Media Tidbits</title>
<link>http://www.poynter.org/column.asp?id=31</link>
<description>A group Weblog by the sharpest minds in online media/journalism/publishing.</description>
<language>en</language>
<lastBuildDate>Thu, 20 Oct 2022 13:24:50 +0000</lastBuildDate>
<item>
<title>Hello</title>
<link>http://www.holovaty.com/test/</link>
<description>Testing.</description>
</item>
</channel>
</rss>
For definitions of the different versions of RSS, see: https://web.archive.org/web/20110718035220/http://diveintomark.org/archives/2004/02/04/incompatible-rss
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file starlette_feedgen-0.1.4.tar.gz.
File metadata
- Download URL: starlette_feedgen-0.1.4.tar.gz
- Upload date:
- Size: 13.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.2.2 CPython/3.10.8 Darwin/21.6.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4e6eec985629b1bb1b6e9a7c006c762425754a67e379a485f7ad08d4c751e2a5
|
|
| MD5 |
a94bc6ad4fc93c37bee239007234578a
|
|
| BLAKE2b-256 |
36a43d7fafc98402cdadaa0da978a3804ba17f28d039d65de98c22f857a77f4a
|
File details
Details for the file starlette_feedgen-0.1.4-py3-none-any.whl.
File metadata
- Download URL: starlette_feedgen-0.1.4-py3-none-any.whl
- Upload date:
- Size: 12.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.2.2 CPython/3.10.8 Darwin/21.6.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a071d6ffbf5e567420073a21f8b69d9fa7bc4843e15b12f847cdc2569d5ee7cd
|
|
| MD5 |
2c97894c39c76115eb934cf1a6fc1569
|
|
| BLAKE2b-256 |
10c0458fb7889c05cf55e60c5b4262320d48ed10d99242db8fb74555cb76fe61
|