aboutsummaryrefslogtreecommitdiffstats
path: root/youtube/yt_data_extract
diff options
context:
space:
mode:
authorAstound <kirito@disroot.org>2024-01-22 06:35:46 +0800
committerAstound <kirito@disroot.org>2024-01-22 06:35:46 +0800
commit97972d6fa3bdbe4a02589345373c958e7b2f9c22 (patch)
treeba81cf0499716ee4a46e33988666105cd714882b /youtube/yt_data_extract
parent6ae20bb1f5edb99dc7739d3182713968380cd9c2 (diff)
downloadyt-local-97972d6fa3bdbe4a02589345373c958e7b2f9c22.tar.lz
yt-local-97972d6fa3bdbe4a02589345373c958e7b2f9c22.tar.xz
yt-local-97972d6fa3bdbe4a02589345373c958e7b2f9c22.zip
Fix like count extraction
Diffstat (limited to 'youtube/yt_data_extract')
-rw-r--r--youtube/yt_data_extract/watch_extraction.py32
1 files changed, 20 insertions, 12 deletions
diff --git a/youtube/yt_data_extract/watch_extraction.py b/youtube/yt_data_extract/watch_extraction.py
index b943d35..e09e2d3 100644
--- a/youtube/yt_data_extract/watch_extraction.py
+++ b/youtube/yt_data_extract/watch_extraction.py
@@ -140,11 +140,12 @@ def _extract_likes_dislikes(renderer_content):
['defaultText', 'accessibility', 'accessibilityData', 'label'],
['accessibility', 'label'],
['accessibilityData', 'accessibilityData', 'label'],
+ ['accessibilityText'],
))
# this count doesn't have all the digits, it's like 53K for instance
- dumb_count = extract_int(extract_str(deep_get(
- toggle_button_renderer, 'defaultText')))
+ dumb_count = extract_int(extract_str(multi_get(
+ toggle_button_renderer, ['defaultText', 'title'])))
# The accessibility text will be "No likes" or "No dislikes" or
# something like that, but dumb count will be 0
@@ -168,16 +169,23 @@ def _extract_likes_dislikes(renderer_content):
info['dislike_count'] = count
elif 'slimMetadataButtonRenderer' in button:
button_renderer = button['slimMetadataButtonRenderer']
- liberal_update(info, 'like_count', extract_button_count(deep_get(
- button_renderer, 'button',
- 'segmentedLikeDislikeButtonRenderer',
- 'likeButton', 'toggleButtonRenderer'
- )))
- liberal_update(info, 'dislike_count',extract_button_count(deep_get(
- button_renderer, 'button',
- 'segmentedLikeDislikeButtonRenderer',
- 'dislikeButton', 'toggleButtonRenderer'
- )))
+ liberal_update(info, 'like_count', extract_button_count(
+ multi_deep_get(button_renderer,
+ ['button', 'segmentedLikeDislikeButtonRenderer',
+ 'likeButton', 'toggleButtonRenderer'],
+ ['button', 'segmentedLikeDislikeButtonViewModel',
+ 'likeButtonViewModel', 'likeButtonViewModel',
+ 'toggleButtonViewModel', 'toggleButtonViewModel',
+ 'defaultButtonViewModel', 'buttonViewModel']
+ )
+ ))
+ '''liberal_update(info, 'dislike_count', extract_button_count(
+ deep_get(
+ button_renderer, 'button',
+ 'segmentedLikeDislikeButtonRenderer',
+ 'dislikeButton', 'toggleButtonRenderer'
+ )
+ ))'''
return info
def _extract_from_owner_renderer(renderer_content):