michaelnisi / pickup

Transform XML feeds
MIT License
21 stars 1 forks source link

No distinction between entries and feeds in the CLI output #11

Open chocolateboy opened 6 years ago

chocolateboy commented 6 years ago

It would be nice if there was a way to directly distinguish between feed records and entry records in the output of the CLI command. Currently, they are both emitted as objects with largely overlapping fields. In practice, the feed record always appears to be emitted last, so this can be used to distinguish them, but that's hacky and defeats the purpose of the streaming API. It would be nice if there was a direct way e.g. a type field:

{
    "id": "http://liftoff.msfc.nasa.gov/2003/05/30.html#item572",
    "summary": "Sky watchers in partial eclipse of the Sun on Saturday, May 31st.",
    "type": "entry"
}
{
    "language": "en-us",
    "link": "http://liftoff.msfc.nasa.gov/",
    "summary": "Liftoff to Space Exploration.",
    "title": "Liftoff News",
    "type": "feed"
}
michaelnisi commented 5 years ago

Your request is justified, of course. I’m open for a PR.

🎉 The good news is that the REPL, which I’m using for exploring feeds or when working on Pickup, can do just that now.

$ ./repl.js

Just the feed.

read(get('https://rss.art19.com/call-your-girlfriend'), Feed)

Entries only.

read(get('https://rss.art19.com/call-your-girlfriend'), Entry)

Just entry titles.

read(get('https://rss.art19.com/call-your-girlfriend'), Entry, 'title')

Limiting the number of items.

read(get('https://rss.art19.com/call-your-girlfriend'), Entry, 3)

Combined, the summary of three entries.

read(get('https://rss.art19.com/call-your-girlfriend'), Entry, 'summary', 3)