mirror of
https://github.com/arthur-pbty/xiao.git
synced 2026-06-06 06:10:49 +02:00
Fix meme descriptions and thumbnails
This commit is contained in:
@@ -54,11 +54,23 @@ module.exports = class KnowYourMemeCommand extends Command {
|
||||
async fetchMeme(location) {
|
||||
const { text } = await request.get(`https://knowyourmeme.com${location}`);
|
||||
const $ = cheerio.load(text);
|
||||
const thumbnail = $('a[class="photo left wide"]').first().attr('href')
|
||||
|| $('a[class="photo left "]').first().attr('href')
|
||||
|| null;
|
||||
return {
|
||||
name: $('h1').first().text().trim(),
|
||||
url: `https://knowyourmeme.com${location}`,
|
||||
description: $('.bodycopy').children().eq(1).text(),
|
||||
thumbnail: $('a[class="photo left wide"]').first().attr('href') || null
|
||||
description: this.getMemeDescription($),
|
||||
thumbnail
|
||||
};
|
||||
}
|
||||
|
||||
getMemeDescription($) {
|
||||
const children = $('.bodycopy').first().children();
|
||||
for (let i = 0; i < children.length; i++) {
|
||||
const child = children.eq(i);
|
||||
if (child.text() === 'About') return children.eq(i + 1).text();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
};
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "xiao",
|
||||
"version": "92.2.0",
|
||||
"version": "92.2.1",
|
||||
"description": "Your personal server companion.",
|
||||
"main": "Xiao.js",
|
||||
"scripts": {
|
||||
|
||||
Reference in New Issue
Block a user