From b0748e5e7c648a536ee9052262f9b40fdab94458 Mon Sep 17 00:00:00 2001 From: Logan Rockmore Date: Tue, 17 Dec 2019 21:01:04 -0700 Subject: [PATCH] =?UTF-8?q?feat:=20Add=20some=20error=20handling=20for=20w?= =?UTF-8?q?hen=20certain=20pieces=20of=20HTML=20a=E2=80=A6=20(#3594)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/routes/dribbble/utils.js | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/lib/routes/dribbble/utils.js b/lib/routes/dribbble/utils.js index ac96e50e24..069995907b 100644 --- a/lib/routes/dribbble/utils.js +++ b/lib/routes/dribbble/utils.js @@ -6,14 +6,18 @@ async function load(link) { const response = await got.get(link); const $ = cheerio.load(response.data); - const shotMedia = $('.media-shot').html(); - const shotDescription = $('.shot-desc').html(); + const shotMedia = $('.media-shot').html() || $('.main-shot').html() || ''; + const shotDescription = $('.shot-desc').html() || ''; + + const shotViews = $('.shot-views').text() || '0 views'; + const shotLikes = $('.shot-likes').text() || '0 likes'; + const shotSaves = $('.shot-saves').text() || '0 saves'; const description = `${shotMedia}
${shotDescription}
- ${$('.shot-views').text()}
- ${$('.shot-likes').text()}
- ${$('.shot-saves').text()}`; + ${shotViews}
+ ${shotLikes}
+ ${shotSaves}`; const pubDateString = $('.shot-date').text(); const pubDate = new Date(pubDateString).toUTCString();