Skip to content

Commit

Permalink
Support audio attachments
Browse files Browse the repository at this point in the history
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
}
  • Loading branch information
dariusk committed Jun 28, 2019
1 parent 4754a0d commit c3983fe
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion updateFeeds.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit c3983fe

Please sign in to comment.