Browse Source

Support audio attachments

Mastodon 2.9.2 now supports native audio attachments, so
any mp3 enclosures detected from a podcast-style feed
are converted to an audio attachment of the form
"attachment": {
  "type": "Document",
  "mediaType": "audio/mpeg",
  "url": "[URL of the mp3]",
  "name": null
}
private
Darius Kazemi 3 years ago
parent
commit
c3983fe4bc
  1. 11
      updateFeeds.js

11
updateFeeds.js

@ -223,7 +223,16 @@ function createMessage(text, name, domain, item, follower, guidNote) {
// add image attachment
let attachment;
console.log('NUM IMAGES',item.urls.length);
if (item.urls.length > 0) {
if (item.enclosure && item.enclosure.url && item.enclosure.url.includes('.mp3')) {
attachment = {
'type': 'Document',
'mediaType': 'audio/mpeg',
'url': item.enclosure.url,
'name': null
};
out.object.attachment = attachment;
}
else if (item.urls.length > 0) {
attachment = {
'type': 'Document',
'mediaType': 'image/png', // TODO: update the mediaType to match jpeg,gif,etc

Loading…
Cancel
Save