Last active
May 26, 2023 18:28
-
-
Save kenmickles/5193377 to your computer and use it in GitHub Desktop.
Generate an RSS feed for Henry Rollins' KCRW radio show
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
request = require('request') | |
cheerio = require('cheerio') | |
builder = require('xmlbuilder') | |
podcast = require('podcast') | |
_ = require('underscore') | |
# scrape website for latest episode number | |
request 'http://www.kcrw.com/music/programs/hr', (err, resp, body) -> | |
$ = cheerio.load(body) | |
episodes = [] | |
latest_episode = parseInt $('.big-piece .duration').text().replace(/KCRW Broadcast /, '') | |
episode_count = 6 # the last 6 episodes seem to be downloadable | |
fetched_episode_count = 0 | |
# fetch JSON for each available episode | |
for i in [0..5] | |
number = latest_episode - i | |
request { url: "http://www.kcrw.com/music/shows/henry-rollins/kcrw-broadcast-#{number}/player.json", json: true }, (err, resp, episode) -> | |
return if resp.statusCode != 200 | |
# downloadable episode | |
episodes.push(episode) if episode.media.length > 0 | |
# print the feed when we hit the last episode | |
fetched_episode_count += 1 | |
print_feed(episodes) if fetched_episode_count == episode_count | |
# print RSS feed to console | |
print_feed = (episodes) -> | |
episodes = _.sortBy(episodes, (e) -> e.date).reverse() | |
feed = new podcast | |
title: 'Henry Rollins - KCRW' | |
description: 'Henry Rollins hosts a great mix of all kinds from all over from all time.' | |
itunesImage: 'http://www.kcrw.com/music/shows/henry-rollins/@@images/square_image' | |
site_url: 'http://www.kcrw.com/music/shows/henry-rollins' | |
author: 'Henry Rollins' | |
for ep in episodes | |
feed.item | |
title: ep.title | |
description: ep.description | |
guid: ep.uuid | |
date: new Date(ep.airdate) | |
enclosure: {url: ep.media[0].url} | |
itunesImage: ep.image | |
itunesDuration: ep.duration | |
console.log feed.xml(indent: true) |
@pantos27 You can grab the feed here: http://37i.net/rollins.xml
This doesn't appear to be working any longer. At least the link to the feed. What do I need to do to get this code to work?
I just used the above link to add the KCRW Henry Rollins show to Apple Podcasts, and it works really well. Thanks so much, I’m so happy you’ve created this.
Link works fine today for me in Overcast app…let’s me add the 6 episodes as podcasts.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hey, nice work.
Been looking to get his show on rss and couldn't find it.
Do you have a link to share?