mirror of
https://github.com/bitsocialnet/5chan.git
synced 2026-08-03 07:41:04 +02:00
add support for non-direct imgur links
This commit is contained in:
@@ -23,6 +23,31 @@ const getCommentMediaInfo = (comment) => {
|
||||
} else if (host.includes('streamable.com')) {
|
||||
const videoId = url.pathname.split('/')[1];
|
||||
scrapedThumbnailUrl = `https://cdn-cf-east.streamable.com/image/${videoId}.jpg`;
|
||||
|
||||
} else if (host.includes('imgur.com') && !host.startsWith('i.imgur')) {
|
||||
const imgId = url.pathname.split('/')[1];
|
||||
const formats = ['jpeg', 'jpg', 'png', 'mp4'];
|
||||
|
||||
for (const format of formats) {
|
||||
const directUrl = `https://i.imgur.com/${imgId}.${format}`;
|
||||
const imgurUrl = new URL(directUrl);
|
||||
const mime = extName(imgurUrl.pathname.toLowerCase().replace('/', ''))[0]?.mime;
|
||||
|
||||
if (mime?.startsWith('image')) {
|
||||
return {
|
||||
url: directUrl,
|
||||
type: 'image',
|
||||
};
|
||||
}
|
||||
|
||||
if (mime?.startsWith('video')) {
|
||||
return {
|
||||
url: directUrl,
|
||||
type: 'video',
|
||||
thumbnail: comment.thumbnailUrl,
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (canEmbed(url)) {
|
||||
|
||||
Reference in New Issue
Block a user