Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

react-native-rss-parser

Package Overview
Dependencies
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-native-rss-parser - npm Package Compare versions

Comparing version 1.0.1 to 1.1.0

parsers/itunes.js

37

model/rss.js

@@ -28,2 +28,24 @@ const model = module.exports = {};

},
itunes: {
author: [{
name: undefined
}],
block: undefined,
categories: [{
name: undefined,
subCategories:[{
name: undefined
}]
}],
image: undefined,
explicit: undefined,
complete: undefined,
newFeedUrl: undefined,
owner: {
name: undefined,
email: undefined,
},
subtitle: undefined,
summary: undefined,
},
items: [{

@@ -48,4 +70,17 @@ title: undefined,

mimeType: undefined
}]
}],
itunes: {
authors: [{
name: undefined,
}],
block: undefined,
duration: undefined,
explicit: undefined,
image: undefined,
isClosedCaptioned: undefined,
order: undefined,
subtitle: undefined,
summary: undefined,
}
}]
};

2

package.json
{
"name": "react-native-rss-parser",
"version": "1.0.1",
"version": "1.1.0",
"description": "React Native compatible package to parse RSS feeds",

@@ -5,0 +5,0 @@ "main": "index.js",

var utils = require('./utils');
var model = require('../model/rss');
var itunesParser = require('./itunes');

@@ -32,2 +33,3 @@ exports.parse = function(document) {

parsedFeed.image = getChannelImage(channelNode);
parsedFeed.itunes = itunesParser.parseChannel(channelNode);

@@ -110,3 +112,4 @@ return parsedFeed;

published: getItemPublished(item),
enclosures: getItemEnclosures(item)
enclosures: getItemEnclosures(item),
itunes: itunesParser.parseItem(item)
};

@@ -113,0 +116,0 @@ });

var utils = require('./utils');
var model = require('../model/rss');
var itunesParser = require('./itunes');

@@ -33,2 +34,3 @@ exports.parse = function(document) {

parsedFeed.image = getChannelImage(channelNode);
parsedFeed.itunes = itunesParser.parseChannel(channelNode);

@@ -128,3 +130,4 @@ return parsedFeed;

published: getItemPublished(item),
enclosures: getItemEnclosures(item)
enclosures: getItemEnclosures(item),
itunes: itunesParser.parseItem(item)
};

@@ -131,0 +134,0 @@ });

@@ -11,9 +11,15 @@ exports.getElements = function(node, tagName) {

exports.getChildElements = function(node, tagName) {
if (!node || !node.getElementsByTagName(tagName)) {
exports.getChildElements = function(node, tagName, namespace) {
if (!node) {
return [];
}
let elements = node.getElementsByTagName(tagName);
let elements = namespace ?
node.getElementsByTagNameNS(namespace, tagName) :
node.getElementsByTagName(tagName);
if (!elements) {
return [];
}
return Array.prototype.filter.call(elements, element =>

@@ -23,4 +29,4 @@ element.parentNode.nodeName === node.nodeName);

exports.getElementTextContentArray = function(node, tagName) {
const nodes = this.getChildElements(node, tagName);
exports.getElementTextContentArray = function(node, tagName, namespace) {
const nodes = this.getChildElements(node, tagName, namespace);

@@ -34,16 +40,6 @@ if (!nodes || nodes.length === 0) {

exports.getElementTextContent = function(node, tagName) {
const array = this.getElementTextContentArray(node, tagName);
exports.getElementTextContent = function(node, tagName, namespace) {
const array = this.getElementTextContentArray(node, tagName, namespace);
return array.length === 0 ? undefined : array[0];
}
exports.getElementAttributeContent = function(node, tagName, attribute) {
const nodes = this.getChildElements(node, tagName);
if (!nodes || nodes.length === 0) {
return undefined;
}
return nodes[0].getAttribute(attribute);
}

@@ -10,2 +10,3 @@ # react-native-rss-parser

* Atom 1.0 specification
* Itunes elements for both RSS 2.0 and Atom 1.0 feeds

@@ -36,46 +37,81 @@ ## Installation

{
type: undefined,
title: undefined,
type: undefined, // either `rss-v2` or `atom-v1`
title: undefined, // title of the channel
links: [{
url: undefined,
rel: undefined
url: undefined, // url of the channel
rel: undefined // type of url (eg. alternate)
}],
description: undefined,
language: undefined,
copyright: undefined,
description: undefined, // description of the channel
language: undefined, // language of the channel in `en-us`
copyright: undefined, // copyright information about the channel
authors: [{
name: undefined
name: undefined // channel author names
}],
lastUpdated: undefined,
lastPublished: undefined,
lastUpdated: undefined, // last updated date for the channel
lastPublished: undefined, // last published date for the channel
categories: [{
name: undefined
name: undefined // categories the channel belong too
}],
image: {
url: undefined,
title: undefined,
description: undefined,
width: undefined,
height: undefined
url: undefined, // channel image url
title: undefined, // channel image title
description: undefined, // channel image description
width: undefined, // channel image width (pixels)
height: undefined // channel image height (pixels)
},
items: [{
title: undefined,
itunes: { // itunes specific channel information
author: [{
name: undefined // channel author names
}],
block: undefined, // if `yes` then the entire podcast isn't shown in iTunes directory
categories: [{
name: undefined, // channel category names
subCategories:[{
name: undefined // sub category names
}]
}],
image: undefined, // channel image url
explicit: undefined, // `yes`/`no` to indicate if channel contains explicit content
complete: undefined, // `yes` indicates the feed won't publish any new items in the future
newFeedUrl: undefined, // a url pointing to the new feed location
owner: {
name: undefined, // owner name of the channel
email: undefined, // owner email address of the channel
},
subtitle: undefined, // sub title of the channel
summary: undefined, // summary of the channel
},
items: [{ // list of items in the feed
title: undefined, // item title
links: [{
url: undefined,
rel: undefined
url: undefined, // item link url
rel: undefined // type of item link
}],
description: undefined,
content: undefined,
description: undefined, // item description
content: undefined, // item HTML content
categories: [{
name: undefined
name: undefined // categories the item belongs too
}],
authors: [{
name: undefined
name: undefined // item author names
}],
published: undefined,
published: undefined, // item published date
enclosures: [{
url: undefined,
length: undefined,
mimeType: undefined
}]
url: undefined, // item media url
length: undefined, // item media length (bytes)
mimeType: undefined // item media mime type (eg audio/mpeg)
}],
itunes: { // itunes specific item information
authors: [{
name: undefined, // item author names
}],
block: undefined, // `yes` indicates the item won't be displayed in the iTunes directory
duration: undefined, // HH:MM:SS length of the item
explicit: undefined, // `yes`/`no` to indicate if item contains explicit content
image: undefined, // image url for the item
isClosedCaptioned: undefined, // `yes` indicates if the item contains closed captioning
order: undefined, // item order number
subtitle: undefined, // item subtitle
summary: undefined, // item summary
}
}]

@@ -82,0 +118,0 @@ }

var assert = require('assert');
var atomv1 = require('./samples/atomv1');
var atomv1WithItunes = require('./samples/atomv1-with-itunes');
var rssParser = require('../index');

@@ -28,2 +29,51 @@

});
describe('with itunes elements', function() {
it('should return itunes information for channel and item elements', function() {
return rssParser.parse(atomv1WithItunes.feed)
.then((result) => {
assert.notEqual(result.itunes, undefined);
assert.equal(result.itunes.authors.length, 1);
assert.equal(result.itunes.authors[0].name, 'John Doe');
assert.equal(result.itunes.block, 'no');
assert.equal(result.itunes.categories.length, 3);
assert.equal(result.itunes.categories[0].name, 'Technology');
assert.equal(result.itunes.categories[0].subCategories.length, 1);
assert.equal(result.itunes.categories[0].subCategories[0].name, 'Gadgets');
assert.equal(result.itunes.categories[1].name, 'TV & Film');
assert.equal(result.itunes.categories[1].subCategories.length, 0);
assert.equal(result.itunes.categories[2].name, 'Arts');
assert.equal(result.itunes.categories[2].subCategories.length, 1);
assert.equal(result.itunes.categories[2].subCategories[0].name, 'Food');
assert.equal(result.itunes.complete, 'yes');
assert.equal(result.itunes.explicit, 'no');
assert.equal(result.itunes.image, 'http://example.com/podcasts/everything/AllAboutEverything.jpg');
assert.equal(result.itunes.newFeedUrl, 'http://newlocation.com/example.rss');
assert.notEqual(result.itunes.owner, undefined);
assert.equal(result.itunes.owner.name, 'John Doe');
assert.equal(result.itunes.owner.email, 'john.doe@example.com');
assert.equal(result.itunes.subtitle, 'A show about everything');
assert.equal(result.itunes.summary, 'All About Everything is a show about everything. Each week we dive into any subject known to man and talk about it as much as we can. Look for our podcast in the Podcasts app or in the iTunes Store');
assert.equal(result.items.length, 2);
assert.equal(result.items[0].itunes.authors.length, 1);
assert.equal(result.items[0].itunes.authors[0].name, 'John Doe');
assert.equal(result.items[0].itunes.block, 'yes');
assert.equal(result.items[1].itunes.block, 'no');
assert.equal(result.items[0].itunes.image, 'http://example.com/podcasts/everything/AllAboutEverything/Episode1.jpg');
assert.equal(result.items[1].itunes.image, 'http://example.com/podcasts/everything/AllAboutEverything/Episode2.jpg');
assert.equal(result.items[0].itunes.duration, '07:04');
assert.equal(result.items[1].itunes.duration, '04:34');
assert.equal(result.items[0].itunes.explicit, 'yes');
assert.equal(result.items[1].itunes.explicit, 'no');
assert.equal(result.items[0].itunes.isClosedCaptioned, undefined);
assert.equal(result.items[1].itunes.isClosedCaptioned, 'yes');
assert.equal(result.items[0].itunes.order, '1');
assert.equal(result.items[1].itunes.order, '2');
assert.equal(result.items[0].itunes.subtitle, 'A short primer on table spices');
assert.equal(result.items[1].itunes.subtitle, 'Comparing socket wrenches is fun!');
assert.equal(result.items[0].itunes.summary, `This week we talk about <a href="https://itunes/apple.com/us/book/antique-trader-salt-pepper/id429691295?mt=11">salt and pepper shakers</a>, comparing and contrasting pour rates, construction materials, and overall aesthetics. Come and join the party!`);
assert.equal(result.items[1].itunes.summary, 'This week we talk about metric vs. Old English socket wrenches. Which one is better? Do you really need both? Get all of your answers here.');
});
});
});
});

@@ -6,2 +6,3 @@ var assert = require('assert');

var rssv2InvalidNoChannel = require('./samples/rssv2-invalid-no-channel');
var rssv2WithItunes = require('./samples/rssv2-with-itunes');
var rssParser = require('../index');

@@ -54,2 +55,52 @@

describe('with itunes elements', function() {
it('should return itunes information for channel and item elements', function() {
return rssParser.parse(rssv2WithItunes.feed)
.then((result) => {
assert.notEqual(result.itunes, undefined);
assert.equal(result.itunes.authors.length, 1);
assert.equal(result.itunes.authors[0].name, 'John Doe');
assert.equal(result.itunes.block, 'no');
assert.equal(result.itunes.categories.length, 3);
assert.equal(result.itunes.categories[0].name, 'Technology');
assert.equal(result.itunes.categories[0].subCategories.length, 1);
assert.equal(result.itunes.categories[0].subCategories[0].name, 'Gadgets');
assert.equal(result.itunes.categories[1].name, 'TV & Film');
assert.equal(result.itunes.categories[1].subCategories.length, 0);
assert.equal(result.itunes.categories[2].name, 'Arts');
assert.equal(result.itunes.categories[2].subCategories.length, 1);
assert.equal(result.itunes.categories[2].subCategories[0].name, 'Food');
assert.equal(result.itunes.complete, 'yes');
assert.equal(result.itunes.explicit, 'no');
assert.equal(result.itunes.image, 'http://example.com/podcasts/everything/AllAboutEverything.jpg');
assert.equal(result.itunes.newFeedUrl, 'http://newlocation.com/example.rss');
assert.notEqual(result.itunes.owner, undefined);
assert.equal(result.itunes.owner.name, 'John Doe');
assert.equal(result.itunes.owner.email, 'john.doe@example.com');
assert.equal(result.itunes.subtitle, 'A show about everything');
assert.equal(result.itunes.summary, 'All About Everything is a show about everything. Each week we dive into any subject known to man and talk about it as much as we can. Look for our podcast in the Podcasts app or in the iTunes Store');
assert.equal(result.items.length, 4);
assert.equal(result.items[0].itunes.authors.length, 1);
assert.equal(result.items[0].itunes.authors[0].name, 'John Doe');
assert.equal(result.items[0].itunes.block, 'yes');
assert.equal(result.items[1].itunes.block, 'no');
assert.equal(result.items[2].itunes.block, undefined);
assert.equal(result.items[0].itunes.image, 'http://example.com/podcasts/everything/AllAboutEverything/Episode1.jpg');
assert.equal(result.items[1].itunes.image, 'http://example.com/podcasts/everything/AllAboutEverything/Episode2.jpg');
assert.equal(result.items[0].itunes.duration, '07:04');
assert.equal(result.items[1].itunes.duration, '04:34');
assert.equal(result.items[0].itunes.explicit, 'yes');
assert.equal(result.items[1].itunes.explicit, 'no');
assert.equal(result.items[0].itunes.isClosedCaptioned, undefined);
assert.equal(result.items[2].itunes.isClosedCaptioned, 'Yes');
assert.equal(result.items[0].itunes.order, '1');
assert.equal(result.items[1].itunes.order, '2');
assert.equal(result.items[0].itunes.subtitle, 'A short primer on table spices');
assert.equal(result.items[1].itunes.subtitle, 'Comparing socket wrenches is fun!');
assert.equal(result.items[0].itunes.summary, `This week we talk about <a href="https://itunes/apple.com/us/book/antique-trader-salt-pepper/id429691295?mt=11">salt and pepper shakers</a>, comparing and contrasting pour rates, construction materials, and overall aesthetics. Come and join the party!`);
assert.equal(result.items[1].itunes.summary, 'This week we talk about metric vs. Old English socket wrenches. Which one is better? Do you really need both? Get all of your answers here.');
});
});
});
describe('invalid document', function() {

@@ -56,0 +107,0 @@ it('should reject promise', function() {

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc