Skip to content

Commit

Permalink
[YouTube] Support no longer supporting dislikes
Browse files Browse the repository at this point in the history
  • Loading branch information
pzygielo committed Dec 22, 2021
1 parent 24355a0 commit d8c020c
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 4 deletions.
6 changes: 6 additions & 0 deletions services/youtube/youtube-base.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,12 @@ const schema = Joi.object({
Joi.object({
viewCount: nonNegativeInteger,
subscriberCount: nonNegativeInteger,
}),
Joi.object({
viewCount: nonNegativeInteger,
likeCount: nonNegativeInteger,
commentCount: nonNegativeInteger,
favoriteCount: nonNegativeInteger,
})
),
})
Expand Down
9 changes: 6 additions & 3 deletions services/youtube/youtube-likes.service.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion services/youtube/youtube-likes.tester.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'],
Expand Down

0 comments on commit d8c020c

Please sign in to comment.