Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove like/dislike from LinkInfo YouTube integration #181

Merged
merged 2 commits into from
Feb 14, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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