All Projects → lkiesow → Python Feedgen

lkiesow / Python Feedgen

Licence: other
Python module to generate ATOM feeds, RSS feeds and Podcasts.

Programming Languages

python
139335 projects - #7 most used programming language

Projects that are alternatives of or similar to Python Feedgen

Jquery Rss
An easy-to-use rss plugin for jquery with templating.
Stars: ✭ 443 (-11.58%)
Mutual labels:  rss, atom, feed
buran
Bidirectional, data-driven RSS/Atom feed consumer, producer and feeds aggregator
Stars: ✭ 27 (-94.61%)
Mutual labels:  atom, rss, feed
Feed Io
A PHP library to read and write feeds in JSONFeed, RSS or Atom format
Stars: ✭ 200 (-60.08%)
Mutual labels:  rss, atom, feed
Pluto
pluto gems - planet feed reader and (static) website generator - auto-build web pages from published web feeds
Stars: ✭ 174 (-65.27%)
Mutual labels:  rss, atom, feed
meta-extractor
Super simple and fast html page meta data extractor with low memory footprint
Stars: ✭ 38 (-92.42%)
Mutual labels:  atom, rss, feed
Feed Module
Everyone deserves RSS, ATOM and JSON feeds!
Stars: ✭ 182 (-63.67%)
Mutual labels:  rss, atom, feed
Hexo Generator Feed
Feed generator for Hexo.
Stars: ✭ 400 (-20.16%)
Mutual labels:  rss, atom, feed
Rss Atom Bundle
RSS and Atom Bundle for Symfony
Stars: ✭ 123 (-75.45%)
Mutual labels:  rss, atom, feed
vuepress-plugin-feed
RSS, Atom, and JSON feeds generator plugin for VuePress 1.x
Stars: ✭ 46 (-90.82%)
Mutual labels:  atom, rss, feed
feed2email
RSS/Atom feed updates in your email
Stars: ✭ 37 (-92.61%)
Mutual labels:  atom, rss, feed
Posidonlauncher
a one-page homescreen with a news feed
Stars: ✭ 163 (-67.47%)
Mutual labels:  rss, atom, feed
Picofeed
PHP library to parse and write RSS/Atom feeds
Stars: ✭ 439 (-12.38%)
Mutual labels:  rss, atom, feed
Feedparser
feedparser gem - (universal) web feed parser and normalizer (XML w/ Atom or RSS, JSON Feed, HTML w/ Microformats e.g. h-entry/h-feed or Feed.HTML, Feed.TXT w/ YAML, JSON or INI & Markdown, etc.)
Stars: ✭ 156 (-68.86%)
Mutual labels:  rss, atom, feed
feeds-to-pocket
Sends entries from RSS and Atom feeds to Pocket (https://getpocket.com)
Stars: ✭ 24 (-95.21%)
Mutual labels:  atom, rss, feed
Gofeed
Parse RSS, Atom and JSON feeds in Go
Stars: ✭ 1,762 (+251.7%)
Mutual labels:  rss, atom, feed
V2
Minimalist and opinionated feed reader
Stars: ✭ 3,239 (+546.51%)
Mutual labels:  rss, atom, feed
Discord feedbot
Moved to https://gitlab.com/ffreiheit/discord_feedbot
Stars: ✭ 67 (-86.63%)
Mutual labels:  rss, atom, feed
Feedbag
Ruby's favorite feed auto-discovery library/tool
Stars: ✭ 115 (-77.05%)
Mutual labels:  rss, atom, feed
laminas-feed
Consume and generate Atom and RSS feeds, and interact with Pubsubhubbub.
Stars: ✭ 97 (-80.64%)
Mutual labels:  atom, rss, feed
baRSS
Menu Bar RSS reader for macOS
Stars: ✭ 39 (-92.22%)
Mutual labels:  atom, rss, feed

============= Feedgenerator

.. image:: https://travis-ci.org/lkiesow/python-feedgen.svg?branch=master :target: https://travis-ci.org/lkiesow/python-feedgen :alt: Build Status

.. image:: https://coveralls.io/repos/github/lkiesow/python-feedgen/badge.svg?branch=master :target: https://coveralls.io/github/lkiesow/python-feedgen?branch=master :alt: Test Coverage Status

This module can be used to generate web feeds in both ATOM and RSS format. It has support for extensions. Included is for example an extension to produce Podcasts.

It is licensed under the terms of both, the FreeBSD license and the LGPLv3+. Choose the one which is more convenient for you. For more details have a look at license.bsd and license.lgpl.

More details about the project:

  • Repository <https://github.com/lkiesow/python-feedgen>_
  • Documentation <https://lkiesow.github.io/python-feedgen/>_
  • Python Package Index <https://pypi.python.org/pypi/feedgen/>_

Installation

Prebuild packages

If your distribution includes this project as package, like Fedora Linux does, you can simply use your package manager to install the package. For example::

$ dnf install python3-feedgen

Using pip

You can also use pip to install the feedgen module. Simply run::

$ pip install feedgen

Create a Feed

To create a feed simply instantiate the FeedGenerator class and insert some data:

.. code-block:: python

from feedgen.feed import FeedGenerator
fg = FeedGenerator()
fg.id('http://lernfunk.de/media/654321')
fg.title('Some Testfeed')
fg.author( {'name':'John Doe','email':'[email protected]'} )
fg.link( href='http://example.com', rel='alternate' )
fg.logo('http://ex.com/logo.jpg')
fg.subtitle('This is a cool feed!')
fg.link( href='http://larskiesow.de/test.atom', rel='self' )
fg.language('en')

Note that for the methods which set fields that can occur more than once in a feed you can use all of the following ways to provide data:

  • Provide the data for that element as keyword arguments
  • Provide the data for that element as dictionary
  • Provide a list of dictionaries with the data for several elements

Example:

.. code-block:: python

fg.contributor( name='John Doe', email='[email protected]' )
fg.contributor({'name':'John Doe', 'email':'[email protected]'})
fg.contributor([{'name':'John Doe', 'email':'[email protected]'}, ...])

Generate the Feed

After that you can generate both RSS or ATOM by calling the respective method:

.. code-block:: python

atomfeed = fg.atom_str(pretty=True) # Get the ATOM feed as string
rssfeed  = fg.rss_str(pretty=True) # Get the RSS feed as string
fg.atom_file('atom.xml') # Write the ATOM feed to a file
fg.rss_file('rss.xml') # Write the RSS feed to a file

Add Feed Entries

To add entries (items) to a feed you need to create new FeedEntry objects and append them to the list of entries in the FeedGenerator. The most convenient way to go is to use the FeedGenerator itself for the instantiation of the FeedEntry object:

.. code-block:: python

fe = fg.add_entry()
fe.id('http://lernfunk.de/media/654321/1')
fe.title('The First Episode')
fe.link(href="http://lernfunk.de/feed")

The FeedGenerator's method add_entry(...) will generate a new FeedEntry object, automatically append it to the feeds internal list of entries and return it, so that additional data can be added.


Extensions

The FeedGenerator supports extensions to include additional data into the XML structure of the feeds. Extensions can be loaded like this:

.. code-block:: python

fg.load_extension('someext', atom=True, rss=True)

This example would try to load the extension “someext” from the file ext/someext.py. It is required that someext.py contains a class named “SomextExtension” which is required to have at least the two methods extend_rss(...) and extend_atom(...). Although not required, it is strongly suggested to use BaseExtension from ext/base.py as superclass.

load_extension('someext', ...) will also try to load a class named “SomextEntryExtension” for every entry of the feed. This class can be located either in the same file as SomextExtension or in ext/someext_entry.py which is suggested especially for large extensions.

The parameters atom and rss control if the extension is used for ATOM and RSS feeds respectively. The default value for both parameters is True, meaning the extension is used for both kinds of feeds.

Example: Producing a Podcast

One extension already provided is the podcast extension. A podcast is an RSS feed with some additional elements for ITunes.

To produce a podcast simply load the podcast extension:

.. code-block:: python

from feedgen.feed import FeedGenerator
fg = FeedGenerator()
fg.load_extension('podcast')
...
fg.podcast.itunes_category('Technology', 'Podcasting')
...
fe = fg.add_entry()
fe.id('http://lernfunk.de/media/654321/1/file.mp3')
fe.title('The First Episode')
fe.description('Enjoy our first episode.')
fe.enclosure('http://lernfunk.de/media/654321/1/file.mp3', 0, 'audio/mpeg')
...
fg.rss_str(pretty=True)
fg.rss_file('podcast.xml')

If the FeedGenerator class is used to load an extension, it is automatically loaded for every feed entry as well. You can, however, load an extension for a specific FeedEntry only by calling load_extension(...) on that entry.

Even if extensions are loaded, they can be temporarily disabled during the feed generation by calling the generating method with the keyword argument extensions set to False.

Custom Extensions

If you want to load custom extensions which are not part of the feedgen package, you can use the method register_extension instead. You can directly pass the classes for the feed and the entry extension to this method meaning that you can define them everywhere.


Testing the Generator

You can test the module by simply executing::

$ python -m feedgen

If you want to have a look at the code for this test to have a working code example for a whole feed generation process, you can find it in the __main__.py <https://github.com/lkiesow/python-feedgen/blob/master/feedgen/__main__.py>_.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].