@@ -266,7 +266,18 @@ def parse_video_info(video_id : String, player_response : Hash(String, JSON::Any
266
266
.try & .dig?(" videoActions" , " menuRenderer" , " topLevelButtons" )
267
267
268
268
if toplevel_buttons
269
- likes_button = toplevel_buttons.try & .as_a
269
+ # New Format as of december 2023
270
+ likes_button = toplevel_buttons.dig?(0 ,
271
+ " segmentedLikeDislikeButtonViewModel" ,
272
+ " likeButtonViewModel" ,
273
+ " likeButtonViewModel" ,
274
+ " toggleButtonViewModel" ,
275
+ " toggleButtonViewModel" ,
276
+ " defaultButtonViewModel" ,
277
+ " buttonViewModel"
278
+ )
279
+
280
+ likes_button ||= toplevel_buttons.try & .as_a
270
281
.find(& .dig?(" toggleButtonRenderer" , " defaultIcon" , " iconType" ).=== " LIKE" )
271
282
.try & .[" toggleButtonRenderer" ]
272
283
@@ -279,9 +290,10 @@ def parse_video_info(video_id : String, player_response : Hash(String, JSON::Any
279
290
)
280
291
281
292
if likes_button
293
+ likes_txt = likes_button.dig?(" accessibilityText" )
282
294
# Note: The like count from `toggledText` is off by one, as it would
283
295
# represent the new like count in the event where the user clicks on "like".
284
- likes_txt = (likes_button[" defaultText" ]? || likes_button[" toggledText" ]?)
296
+ likes_txt || = (likes_button[" defaultText" ]? || likes_button[" toggledText" ]?)
285
297
.try & .dig?(" accessibility" , " accessibilityData" , " label" )
286
298
likes = likes_txt.as_s.gsub(/\D / , " " ).to_i64? if likes_txt
287
299
0 commit comments