Support implicit video media
This commit is contained in:
parent
56a2f6b266
commit
8bf7d4f792
|
@ -130,12 +130,26 @@ module.exports = function() {
|
|||
*/
|
||||
if(!post_media && !has_gif && !post.gallery_data && post.url != '') {
|
||||
try {
|
||||
let u = new URL(post.url)
|
||||
let url = replaceDomains(post.url)
|
||||
const u = new URL(url)
|
||||
if(config.valid_media_domains.includes(u.hostname)) {
|
||||
let ext = u.pathname.split('.')[1]
|
||||
if(ext === 'jpg' || ext === 'png') {
|
||||
const ext = u.pathname.split('.')[1]
|
||||
if(['jpg', 'png', 'jpeg', 'gif'].includes(ext)) {
|
||||
obj.images = {
|
||||
source: await downloadAndSave(post.url)
|
||||
source: await downloadAndSave(url)
|
||||
}
|
||||
}
|
||||
else if(['gifv', 'mp4'].includes(ext)) {
|
||||
if (obj.domain === 'i.imgur.com') {
|
||||
url = url.replace(/\.gifv$/, '.mp4');
|
||||
}
|
||||
obj.has_media = true
|
||||
obj.media = {
|
||||
source: await downloadAndSave(url)
|
||||
}
|
||||
if (post.preview && post.preview.images) {
|
||||
obj.media.height = post.preview.images[0].source.height;
|
||||
obj.media.width = post.preview.images[0].source.width;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue