• Stars
    star
    154
  • Rank 242,095 (Top 5 %)
  • Language
    TypeScript
  • License
    MIT License
  • Created about 11 years ago
  • Updated 4 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Podcast feed generator for Node.

Podcast RSS for Node Build Status Greenkeeper badge

Fast and simple Podcast RSS generator/builder for Node projects. Supports enclosures and GeoRSS.

Install

$ npm install podcast

Usage

Create a new feed

import { Podcast } from 'podcast';

const feed = new Podcast(feedOptions);

feedOptions

  • title string Title of your site or feed
  • description optional string A short description of the feed.
  • generator optional string Feed generator.
  • feedUrl url string Url to the rss feed.
  • siteUrl url string Url to the site that the feed is for.
  • imageUrl optional *url string Small image for feed readers to use.
  • docs optional url string Url to documentation on this feed.
  • author string Who owns this feed.
  • managingEditor optional string Who manages content in this feed.
  • webMaster optional string Who manages feed availability and technical support.
  • copyright optional string Copyright information for this feed.
  • language optional string The language of the content of this feed.
  • categories optional array of strings One or more categories this feed belongs to.
  • pubDate optional Date object or date string The publication date for content in the feed
  • ttl optional integer Number of minutes feed can be cached before refreshing from source.
  • itunesAuthor optional string (iTunes specific) author of the podcast
  • itunesSubtitle optional string (iTunes specific) subtitle for iTunes listing
  • itunesSummary optional string (iTunes specific) summary for iTunes listing
  • itunesOwner optional object (iTunes specific) owner of the podcast ( {name:String, email:String} )
  • itunesExplicit optional boolean (iTunes specific) specifies if the podcast contains explicit content
  • itunesCategory optional array of objects (iTunes specific) Categories for iTunes ( [{text:String, subcats:[{text:String, subcats:Array}]}] )
  • itunesImage optional string (iTunes specific) link to an image for the podcast
  • itunesType optional string (iTunes specific) type of podcast (episodic or serial)
  • customNamespaces optional object Put additional namespaces in element (without 'xmlns:' prefix)
  • customElements optional array Put additional elements in the feed (node-xml syntax)

Add items to a feed

An item can be used for a blog entry, project update, log entry, etc. Your RSS feed an have any number of items. Most feeds use 20 or fewer items.

feed.addItem(itemOptions);

itemOptions

  • title string Title of this particular item.
  • description string Content for the item. Can contain html but link and image urls must be absolute path including hostname.
  • url url string Url to the item. This could be a blog entry.
  • guid unique string A unique string feed readers use to know if an item is new or has already been seen. If you use a guid never change it. If you don't provide a guid then your item urls must be unique.
  • categories optional array of strings If provided, each array item will be added as a category element
  • author optional string If included it is the name of the item's creator. If not provided the item author will be the same as the feed author. This is typical except on multi-author blogs.
  • date Date object or date string The date and time of when the item was created. Feed readers use this to determine the sort order. Some readers will also use it to determine if the content should be presented as unread.
  • lat optional number The latitude coordinate of the item.
  • long optional number The longitude coordinate of the item.
  • enclosure optional object Attach a multimedia file to this item.
    • url string Url to the related file.
    • file optional string Path to the related file on the filesystem. Used to fill out size and mime information.
    • size optional number Number of bytes in the file. The length field will defualt to 0 if the size or file fields have not been set.
    • type optional string Mime type of the file. Will be guessed from the url if this parameter is not set.
  • content optional string Long html content for the episode
  • itunesAuthor optional string (iTunes specific) author of the podcast
  • itunesExplicit optional boolean (iTunes specific) specifies if the podcast contains explicit content
  • itunesSubtitle optional string (iTunes specific) subtitle for iTunes listing
  • itunesSummary optional string (iTunes specific) summary for iTunes listing
  • itunesDuration optional number (iTunes specific) duration of the podcast item in seconds
  • itunesImage optional string (iTunes specific) link to an image for the item
  • itunesSeason optional number (iTunes specific) season number (non-zero integer)
  • itunesEpisode optional number (iTunes specific) episode number (non-zero integer)
  • itunesTitle optional string (iTunes specific) episode title
  • itunesEpisodeType optional string (iTunes specific) the type of episode (full (default), trailer, bonus)
  • itunesNewFeedUrl optional string (iTunes specific) The new podcast RSS Feed URL.
  • customElements optional array Put additional elements in the item (node-xml syntax)

Feed XML

const xml = feed.buildXml(indent);

This returns the XML as a string.

indent optional string What to use as a tab. Defaults to no tabs (compressed). For example you can use '\t' for tab character, or ' ' for two-space tabs.

Example Usage

import { Podcast } from 'podcast';

/* lets create an rss feed */
const feed = new Podcast({
    title: 'title',
    description: 'description',
    feedUrl: 'http://example.com/rss.xml',
    siteUrl: 'http://example.com',
    imageUrl: 'http://example.com/icon.png',
    docs: 'http://example.com/rss/docs.html',
    author: 'Dylan Greene',
    managingEditor: 'Dylan Greene',
    webMaster: 'Dylan Greene',
    copyright: '2013 Dylan Greene',
    language: 'en',
    categories: ['Category 1','Category 2','Category 3'],
    pubDate: 'May 20, 2012 04:00:00 GMT',
    ttl: 60,
    itunesAuthor: 'Max Nowack',
    itunesSubtitle: 'I am a sub title',
    itunesSummary: 'I am a summary',
    itunesOwner: { name: 'Max Nowack', email: '[email protected]' },
    itunesExplicit: false,
    itunesCategory: [{
        text: 'Entertainment',
        subcats: [{
          text: 'Television'
        }]
    }],
    itunesImage: 'http://example.com/image.png'
});

/* loop over data and add to feed */
feed.addItem({
    title:  'item title',
    description: 'use this for the content. It can include html.',
    url: 'http://example.com/article4?this&that', // link to the item
    guid: '1123', // optional - defaults to url
    categories: ['Category 1','Category 2','Category 3','Category 4'], // optional - array of item categories
    author: 'Guest Author', // optional - defaults to feed author property
    date: 'May 27, 2012', // any format that js Date can parse.
    lat: 33.417974, //optional latitude field for GeoRSS
    long: -111.933231, //optional longitude field for GeoRSS
    enclosure : {url:'...', file:'path-to-file'}, // optional enclosure
    itunesAuthor: 'Max Nowack',
    itunesExplicit: false,
    itunesSubtitle: 'I am a sub title',
    itunesSummary: 'I am a summary',
    itunesDuration: 12345,
    itunesNewFeedUrl: 'https://newlocation.com/example.rss',
});

// cache the xml to send to clients
const xml = feed.buildXml();

Notes

  • You do not need to escape anything. This module will escape characters when necessary.
  • This module is very fast but you might as well cache the output of buildXml() and serve it until something changes.

Contributing

Contributions to the project are welcome. Feel free to fork and improve. I do my best accept pull requests in a timely manor, especially when tests and updated docs are included.

License

(The MIT License)

Copyright (c) 2018 Max Nowack [email protected]

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the 'Software'), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

More Repositories

1

node-eq3ble

node.js package to control an EQ3 bluetooth thermostat
JavaScript
22
star
2

meteor-querychain

This package enables chaining mongo cursors for Meteor
CoffeeScript
21
star
3

homebridge-eq3ble

Homebridge plugin to control EQ3 bluetooth thermostats
JavaScript
21
star
4

homebridge-dht-sensor

Homebridge plugin for DHT temperature and humidity sensors
JavaScript
14
star
5

deapl

Automatic translations with deepl.com and puppeteer
TypeScript
5
star
6

spaceshow

Wrapper for easily testing meteor apps with puppeteer
JavaScript
4
star
7

meteor-globals

Allows simple usage of meteor globals inside npm packages
JavaScript
4
star
8

meili-sync

Connector to sync mongodb documents into meilisearch
TypeScript
4
star
9

meteor-sync-eventemitter

Allows syncing event emitter events over multiple meteor servers.
JavaScript
3
star
10

node-billwerk

Node wrapper for the billwerk.com api
JavaScript
3
star
11

youtvfetcher

Fetches recorded shows from youtv.de
JavaScript
3
star
12

meteor-allowdeny-redisoplog

adds support for client side mutations in combination with cultofcoders:redis-oplog
JavaScript
3
star
13

proxifier

easy to use man-in-the-middle proxy
JavaScript
3
star
14

react-tracker-connect

react component decorator to connect reactive data with meteor tracker
JavaScript
2
star
15

spotify-radio-playlists

Scrape songs from radio stations and push to spotify playlists
JavaScript
2
star
16

meteor-reactive-cache

Utilities for caching reactive data in meteor
JavaScript
2
star
17

meteor-npm-package

Boilerplate for building/testing npm packages with meteor dependencies
JavaScript
2
star
18

CinemaxxReservations

class library to get the amount of reservations for a movie at cinemaxx
C#
2
star
19

meteor-ytpodcast

Meteor application to get youtube channels or playlists as podcast feed (rewrite of https://github.com/maxnowack/ytpodcast)
JavaScript
2
star
20

webscan

script to scan a network of webservers
Perl
2
star
21

elastic-sync

Connector to sync mongodb documents into a elasticsearch index
TypeScript
1
star
22

trueskill-api

Simple trueskill api in ruby
Ruby
1
star
23

electron-auth-with-meteor

Example electron app, to show how to authenticate in a window and send the meteor login token to another window
JavaScript
1
star
24

motorcycle

Software for controlling a motorcycle for kids
C++
1
star
25

PlaylistSaver

.NET console application to get and store playlists from radio stations
C#
1
star