Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Added itunes keyword support, and added lastBuildDate to valid date fields #31

Open
wants to merge 1 commit into from

2 participants

@blackgold9

No description provided.

@danmactough
Owner

lastBuildDate is incorrect (the parser converts element and attribute names to lowercase) and duplicative (look a few lines above your case identifier). With respect to the logic in the statement, I disagree with the advisability of adding lastbuilddate. This is not a reflection on you -- it's not possible to know why I wrote that section of code the way it's written because it's not documented or tested. But basically, if the 'lastbuilddate' is present, it gets assigned to the date variable. Then, if meta.date is not already set, the date variable gets assigned to meta.date, otherwise it's thrown away because there is a more preferred date. Well, not exactly thrown away -- it would be available as meta['rss:lastbuilddate']. And actually, in the case of the 'lastbuilddate' (an RSS element), the other meta.date alternatives shouldn't exist because they're Atom elements.

The keywords support looks fine, but please do three things:

  1. Rebase against the current master -- I just released a major change.
  2. Remove case('keywords'): -- There is no such element, as far as I'm aware.
  3. Make sure you .trim() the results of your split. For example:
keywordstring.split(',').map(function(kw){ return kw.trim(); });

And if you want to enhance that a little further, look at how I handle categories, and see if you can make sure that if both 'itunes:keywords' and 'media:keywords' contain keywords, one does not overwrite the other but rather adds to the array.

Thanks for the pull request! :+1:

p.s. To update your pull request without making a new one

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Oct 24, 2012
  1. @blackgold9
This page is out of date. Refresh to see the latest.
Showing with 9 additions and 0 deletions.
  1. +9 −0 main.js
View
9 main.js
@@ -521,6 +521,7 @@ FeedParser.prototype.handleMeta = function handleMeta (node, type, options) {
case('published'):
case('modified'):
case('updated'):
+ case('lastBuildDate'):
case('dc:date'):
var date = utils.get(el) ? new Date(el['#']) : null;
if (!date) break;
@@ -604,6 +605,14 @@ FeedParser.prototype.handleMeta = function handleMeta (node, type, options) {
if (utils.get(el['@'], 'uri'))
meta.generator += meta.generator ? ' (' + el['@'].uri + ')' : el['@'].uri;
break;
+ case('itunes:keywords'):
+ case('media:keywords'):
+ case('keywords'):
+ if(!meta.keywords) {
+ var keywordstring = utils.get(el);
+ meta.keywords = keywordstring.split(',');
+ }
+ break;
case('category'):
case('dc:subject'):
case('itunes:category'):
Something went wrong with that request. Please try again.