diff --git a/services/youtube/youtube-base.js b/services/youtube/youtube-base.js index cd2552802a18d..603a47139aa04 100644 --- a/services/youtube/youtube-base.js +++ b/services/youtube/youtube-base.js @@ -24,6 +24,12 @@ const schema = Joi.object({ Joi.object({ viewCount: nonNegativeInteger, subscriberCount: nonNegativeInteger, + }), + Joi.object({ + viewCount: nonNegativeInteger, + likeCount: nonNegativeInteger, + commentCount: nonNegativeInteger, + favoriteCount: nonNegativeInteger, }) ), }) diff --git a/services/youtube/youtube-likes.service.js b/services/youtube/youtube-likes.service.js index 94e2d7ae66264..6720e67113add 100644 --- a/services/youtube/youtube-likes.service.js +++ b/services/youtube/youtube-likes.service.js @@ -62,11 +62,14 @@ export default class YouTubeLikes extends YouTubeVideoBase { id, }) if (queryParams && typeof queryParams.withDislikes !== 'undefined') { + const likes = `${metric(statistics.likeCount)} 👍` + const dislikes = + statistics.dislikeCount !== undefined + ? `${metric(statistics.dislikeCount)} 👎` + : '' renderedBadge = { ...renderedBadge, - message: `${metric(statistics.likeCount)} 👍 ${metric( - statistics.dislikeCount - )} 👎`, + message: `${likes} ${dislikes}`, } } return renderedBadge diff --git a/services/youtube/youtube-likes.tester.js b/services/youtube/youtube-likes.tester.js index 8f6f8dc8fcac6..4584446fb8a55 100644 --- a/services/youtube/youtube-likes.tester.js +++ b/services/youtube/youtube-likes.tester.js @@ -22,7 +22,7 @@ t.create('video vote count') .expectBadge({ label: 'likes', message: Joi.string().regex( - /^([1-9][0-9]*[kMGTPEZY]?|[1-9]\.[1-9][kMGTPEZY]) 👍 ([1-9][0-9]*[kMGTPEZY]?|[1-9]\.[1-9][kMGTPEZY]) 👎$/ + /^([1-9][0-9]*[kMGTPEZY]?|[1-9]\.[1-9][kMGTPEZY]) 👍$/ ), color: 'red', link: ['https://www.youtube.com/video/pU9Q6oiQNd0'],