Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Transform XML feeds to JSON
JavaScript
Failed to load latest commit information.
bin Emit newline separated JSON
example Simplify
lib Parse link
test Parse link
.gitignore Add CLI
.travis.yml Node v0.11.x
LICENSE Review and tidy
README.md Save some memory
index.js Save some memory
package.json Parse link
repl.js
spin.js Parse link

README.md

pickup - transform feeds

The pickup Node package provides a Transform stream from RSS 2.0 (including iTunes namespace extensions) and Atom 1.0 formatted XML to newline separated JSON strings or objects.

Build Status

Usage

Command-line

If you haven't yet, you should first install json—a command for working with JSON on the command-line:

$ npm install -g json

Now you can pipe pickup to json:

$ export URL=5by5.tv/rss
$ curl -sS $URL | pickup | json -ga title | head -n 5

Library

Transform from stdin to stdout

var pickup = require('pickup')

process.stdin
  .pipe(pickup())
  .pipe(process.stdout)

You can run this example from the command-line:

$ curl -sS $URL | node example/stdin.js | json -ga

Proxy server

var http = require('http')
var pickup = require('pickup')

http.createServer(function (req, res) {
  http.get('http:/'.concat(req.url), function (feed) {
    feed.pipe(pickup()).pipe(res)
  })
}).listen(8080)

To try the proxy server:

$ node example/proxy.js &
$ curl -sS http://localhost:8080/$URL | json -ga

types

opts()

The options Object is passed to the Transform stream constructor. pickup adds eventMode to the standard stream options, analogue to objectMode it configures the readable state of the stream. Consider using it in memory restricted situations.

  • eventMode Boolean defaults to false, if true readable state buffers are not filled and no 'data', but 'feed' and 'entry' events are emitted.

str()

String or undefined

feed()

  • author str()
  • copyright str()
  • id str()
  • image str()
  • language str()
  • link str()
  • payment str()
  • subtitle str()
  • summary str()
  • title str()
  • ttl str()
  • updated str()

enclosure()

  • href str()
  • length str()
  • type str()

entry()

  • author str()
  • enclosure enclosure() or undefined
  • duration str()
  • id str()
  • image str()
  • link str()
  • subtitle str()
  • summary str()
  • title str()
  • updated str()

Event:'feed'

feed()

Emitted when the meta information of the feed gets available.

Event:'entry'

entry()

Emitted for each entry.

exports

pickup exports a function that returns a Transform stream which emits newline separated JSON strings, in objectMode the 'data' event contains entry() or feed() objects. As per XML's structure the last 'data' event usually contains the feed() object. In eventMode neither 'readable' nor 'data' events are emitted, instead 'feed' and 'entry' events are fired.

Installation

With npm do:

$ npm install pickup

To use the CLI (as above):

$ npm install -g pickup

Contribute

Please create an issue if you encounter a feed that pickup fails to parse.

License

MIT License

Something went wrong with that request. Please try again.