diff --git a/lib/v2/kemono/index.js b/lib/v2/kemono/index.js index 4ff8be8f5..303dac7d9 100644 --- a/lib/v2/kemono/index.js +++ b/lib/v2/kemono/index.js @@ -92,6 +92,26 @@ module.exports = async (ctx) => { item.guid = item.link.replace('kemono.su', 'kemono.party'); item.pubDate = parseDate(content('.timestamp').attr('datetime')); + // find the first attachment with a file extension we + // want, and set it as the enclosure + content('.post__attachment-link[href][download]').each(function () { + const extension = content(this).attr('download').replace(/.*\./, '').toLowerCase(); + const mimeType = + { + m4a: 'audio/mp4', + mp3: 'audio/mpeg', + mp4: 'video/mp4', + }[extension] || null; + if (mimeType === null) { + return; + } + + item.enclosure_url = content(this).attr('href'); + item.enclosure_type = mimeType; + + return false; + }); + return item; }) )