reesmichael1 / feed-nim

A feed parsing module for Nim

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Feed-Nim

A feed parsing module for Nim, which parses RSS, Atom, and JSONfeed syndication formats. This has been substantially re-written and expanded from Nim-RSS.

It has not been tested in the wild, and is mostly written by an inexperienced dope who barely understands Nim. It will probably break. Use at your own risk.

Intallation

nimble install feednim

Usage

loadAtom(filename: string): Atom Loads the Atom from the given filename
getAtom(url: string): Atom Gets the Atom from the specified url

loadRSS(filename: string): RSS Loads the RSS from the given filename
getRSS(url: string): RSS Gets the RSS from the specified url

loadJsonFeed(filename: string): JSONfeed Loads the JSONFeed from the given filename
getJsonFeed(url: string): JSONfeed Gets the JSONfeed from the specified url

Accessors

Feed-Nim will give a data tree which looks very similar to the data tree of the feed, and the nodes will mostly have the same names. For example an RSS feed 'title' node will be:

let feed = loadRSS("my_feed.xml")
feed.title # Will hold the title
(Bet you didn't see that coming!)

There are some exeptions, elements that can be repeated according to the specifications are pluralised as follows:

RSS: <item> is accessed as .items[index]
RSS and Atom: <category> is accessed as .categories[index]
Atom: <entry> is accessed as .entries[index]
Atom: <author> is accessed as .authors[index] (if you call just .author, you will return the first author of the sequence)
Atom: <contributor> is accessed as .contributors[index] (again, calling this singular will return the first in the sequence)

Some Atom nodes have the Nim keyword 'type' as an attribute. These have been changed as follows:

<link type=""> type is accesed with .linkType
<content type="">, <title type="">, and <subtitle type=""> types are accesed with .textType

Limitations

Feed-Nim does not implement the full specification of any of the feed types. Notably, in Atom, the common attributes 'xml:lang' and 'xml:base' are not implemented. All three formats are extensible, but there is no support for this (extensions should be ignored by Feed-Nim, but this is untested).

About

A feed parsing module for Nim

License:MIT License


Languages

Language:Nim 100.0%