Skip to content

Latest commit

 

History

History
74 lines (54 loc) · 1.88 KB

README.md

File metadata and controls

74 lines (54 loc) · 1.88 KB

Libsyn Podcast Feed Parser

This package creates JavaScript objects from RSS feeds generated by the Libsyn podcasting service with information on the podcast and a list of most recent episodes, including their descriptions and the links to the audio files.

How it works

The package exposes a getPodcast function that uses isomorphic-fetch to request the Libsyn RSS feed at the URL provided to it. It then uses xml2js to wrangle the RSS response into something a bit more manageable.

The asynchronous function returns a Podcast object:

interface Podcast {
    meta: PodcastMeta;
    episodes: PodcastEpisode[];
}

The meta property contains information about the podcast:

interface PodcastMeta {
    title: string;
    description: string;
    imageURL: string;
}

While episodes is an array of objects with information about episodes in the feed (most recent first):

interface PodcastEpisode {
    title: string;
    publicationDate: Date;
    audioFileURL: string;
    description: string;
}

Usage

Install the package from this GitHub repository:

npm install git+https://github.com/sa-express-news/libsyn-parser.git

Import the getPodcast asynchronous function wherever you need to fetch a Libsyn podcast:

import { getPodcast } from 'libsyn-feed-parser';

Pass your Libsyn RSS feed URL to the function, then wait for it to return the podcast object:

try{
    const podcast = await getPodcast('https://expressbriefing.libsyn.com/rss/');

    console.log(podcast.meta.title);
}catch(error){
    // handle error
}

// or

getPodcast('https://expressbriefing.libsyn.com/rss/')
    .then(podcast){
        console.log(podcast.meta.title);
    }
    .catch(error){
        // handle error
    }