| 123456789101112131415161718192021 |
- const XML = require('./xml')
- const request = require('request-promise-native')
- const getRss = async url => {
- // http://www.hellointernet.fm/podcast?format=rss
- url = new URL(url)
- if (url.protocol !== 'http:' && url.protocol !== 'https:') throw new Error('Unsupported protocol: ' + url.protocol)
- const xml = await request(url, {
- headers: {
- 'Accept': 'application/xml;application/rss+xml',
- 'User-Agent': 'rssunlimited.com'
- }
- })
- const data = XML.parse(xml)
- if (!data.rss) throw new Error('Response not an RSS feed.')
- return data
- }
- module.exports = {
- getRss
- }
|