From 19b56b1975eeee95ded6813e9869913a74371d3c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Piotrek=20=C5=BBygie=C5=82o?= Date: Wed, 22 Dec 2021 19:08:34 +0100 Subject: [PATCH] Remove YT dislikes --- services/youtube/youtube-likes.service.js | 40 +---------------------- services/youtube/youtube-likes.tester.js | 15 +-------- 2 files changed, 2 insertions(+), 53 deletions(-) diff --git a/services/youtube/youtube-likes.service.js b/services/youtube/youtube-likes.service.js index 4f4ab7fdfd0f0..820093e2d5b8f 100644 --- a/services/youtube/youtube-likes.service.js +++ b/services/youtube/youtube-likes.service.js @@ -1,24 +1,9 @@ -import Joi from 'joi' -import { metric } from '../text-formatters.js' import { documentation, YouTubeVideoBase } from './youtube-base.js' -const documentationWithDislikes = ` - ${documentation} -

- When enabling the withDislikes option, 👍 corresponds to the number - of likes of a given video, 👎 corresponds to the number of dislikes. -

-` - -const queryParamSchema = Joi.object({ - withDislikes: Joi.equal(''), -}).required() - export default class YouTubeLikes extends YouTubeVideoBase { static route = { base: 'youtube/likes', pattern: ':videoId', - queryParamSchema, } static get examples() { @@ -26,16 +11,8 @@ export default class YouTubeLikes extends YouTubeVideoBase { statistics: { likeCount: 7 }, id: 'abBdk8bSPKU', }) - const previewVotes = this.render( - { - statistics: { likeCount: 10236, dislikeCount: 396 }, - id: 'pU9Q6oiQNd0', - }, - { withDislikes: '' } - ) // link[] is not allowed in examples delete previewLikes.link - delete previewVotes.link return [ { title: 'YouTube Video Likes', @@ -43,30 +20,15 @@ export default class YouTubeLikes extends YouTubeVideoBase { staticPreview: previewLikes, documentation, }, - { - title: 'YouTube Video Likes and Dislikes', - namedParams: { videoId: 'pU9Q6oiQNd0' }, - staticPreview: previewVotes, - queryParams: { - withDislikes: null, - }, - documentation: documentationWithDislikes, - }, ] } static render({ statistics, id }, queryParams) { - let renderedBadge = super.renderSingleStat({ + const renderedBadge = super.renderSingleStat({ statistics, statisticName: 'like', id, }) - if (queryParams && typeof queryParams.withDislikes !== 'undefined') { - renderedBadge = { - ...renderedBadge, - message: `${metric(statistics.likeCount)} 👍`, - } - } return renderedBadge } } diff --git a/services/youtube/youtube-likes.tester.js b/services/youtube/youtube-likes.tester.js index 4584446fb8a55..366690aa03e16 100644 --- a/services/youtube/youtube-likes.tester.js +++ b/services/youtube/youtube-likes.tester.js @@ -1,4 +1,3 @@ -import Joi from 'joi' import { createServiceTester } from '../tester.js' import { noToken } from '../test-helpers.js' import { isMetric } from '../test-validators.js' @@ -16,21 +15,9 @@ t.create('video like count') link: ['https://www.youtube.com/video/pU9Q6oiQNd0'], }) -t.create('video vote count') - .skipWhen(noYouTubeToken) - .get('/pU9Q6oiQNd0.json?withDislikes') - .expectBadge({ - label: 'likes', - message: Joi.string().regex( - /^([1-9][0-9]*[kMGTPEZY]?|[1-9]\.[1-9][kMGTPEZY]) 👍$/ - ), - color: 'red', - link: ['https://www.youtube.com/video/pU9Q6oiQNd0'], - }) - t.create('video not found') .skipWhen(noYouTubeToken) - .get('/doesnotexist.json?withDislikes') + .get('/doesnotexist.json') .expectBadge({ label: 'youtube', message: 'video not found',