Skip to content

Commit

Permalink
Merge pull request #181 from HackSoc/remove-youtube-likes
Browse files Browse the repository at this point in the history
Remove like/dislike from LinkInfo YouTube integration
  • Loading branch information
alanbriolat committed Feb 14, 2022
2 parents 1d8c10b + 636739d commit 892c9e6
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 12 deletions.
9 changes: 1 addition & 8 deletions src/csbot/plugins/youtube.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ class Youtube(Plugin):
'api_key': ['YOUTUBE_DATA_API_KEY'],
}

RESPONSE = '"{title}" [{duration}] (by {uploader} at {uploaded}) | Views: {views} [{likes}]'
RESPONSE = '"{title}" [{duration}] (by {uploader} at {uploaded}) | Views: {views}'
CMD_RESPONSE = RESPONSE + ' | {link}'

async def get_video_json(self, id):
Expand Down Expand Up @@ -130,13 +130,6 @@ async def _yt(self, url):
except KeyError:
vid_info["views"] = "N/A"

try:
likes = int(json["statistics"]["likeCount"])
dislikes = int(json["statistics"]["dislikeCount"])
vid_info["likes"] = "+{:,}/-{:,}".format(likes, dislikes)
except KeyError:
vid_info["likes"] = "N/A"

return vid_info

@Plugin.integrate_with('linkinfo')
Expand Down
8 changes: 4 additions & 4 deletions tests/test_plugin_youtube.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,15 @@
"youtube_fItlK6L-khc.json",
{'link': 'http://youtu.be/fItlK6L-khc', 'uploader': 'BruceWillakers',
'uploaded': '2014-08-29', 'views': '28,843', 'duration': '21:00',
'likes': '+1,192/-13', 'title': 'Trouble In Terrorist Town | Hiding in Fire'}
'title': 'Trouble In Terrorist Town | Hiding in Fire'}
),

# Unicode
(
"vZ_YpOvRd3o",
200,
"youtube_vZ_YpOvRd3o.json",
{'title': "Oh! it's just me! / Фух! Это всего лишь я!", 'likes': '+12,571/-155',
{'title': "Oh! it's just me! / Фух! Это всего лишь я!",
'duration': '00:24', 'uploader': 'ignoramusky', 'uploaded': '2014-08-26',
'views': '6,054,406', 'link': 'http://youtu.be/vZ_YpOvRd3o'}
),
Expand All @@ -36,7 +36,7 @@
"sw4hmqVPe0E",
200,
"youtube_sw4hmqVPe0E.json",
{'title': "Sky News Live", 'likes': '+2,195/-586',
{'title': "Sky News Live",
'duration': 'LIVE', 'uploader': 'Sky News', 'uploaded': '2015-03-24',
'views': '2,271,999', 'link': 'http://youtu.be/sw4hmqVPe0E'}
),
Expand All @@ -46,7 +46,7 @@
"539OnO-YImk",
200,
"youtube_539OnO-YImk.json",
{'title': 'sharpest Underwear kitchen knife in the world', 'likes': '+52,212/-2,209',
{'title': 'sharpest Underwear kitchen knife in the world',
'duration': '12:24', 'uploader': '圧倒的不審者の極み!', 'uploaded': '2018-07-14',
'views': '2,710,723', 'link': 'http://youtu.be/539OnO-YImk'}
),
Expand Down

0 comments on commit 892c9e6

Please sign in to comment.