node-rss
node-rss copied to clipboard
Enclosure Item looks for "size" and not length.
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
+1 same here. It should be replace with 'length'
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},
}
}
]