node-rss icon indicating copy to clipboard operation
node-rss copied to clipboard

Enclosure Item looks for "size" and not length.

Open rv-kip opened this issue 10 years ago • 2 comments

If I do a passthrough of this RSS enclosure element:

<enclosure url="http://example.com/file.mp3" length="5242880" type="audio/mpeg"/>

using this code:

    if (item.enclosures && Array.isArray(item.enclosures)){
        item.enclosures.forEach(function(enclosure){
            if (enclosure.type === 'audio/mpeg') {
                itemOptions.enclosure = enclosure;
            }
         }
    }

I get

<enclosure url="http://example.com/file.mp3" length="0" type="audio/mpeg"/>

"size" isn't the normal field name: https://en.wikipedia.org/wiki/RSS_enclosure

rv-kip avatar Jan 31 '15 01:01 rv-kip

+1 same here. It should be replace with 'length'

beatrizdemiguelperez avatar Feb 17 '21 16:02 beatrizdemiguelperez

Small workaround to fix this, as it looks like PRs are not frequently merged to this repo: You can set the enclosure as custom_element.

custom_elements: [
  {
    enclosure: {
      _attr: {url: i.mediaUrl, length: i.byteSize, type: i.mimeType},
    }
  }
]

danielbuechele avatar May 15 '23 22:05 danielbuechele