]> jfr.im git - yt-dlp.git/commitdiff
[extractor] Extract `average_rating` from JSON-LD
authorpukkandan <redacted>
Tue, 23 Nov 2021 07:41:28 +0000 (13:11 +0530)
committerpukkandan <redacted>
Tue, 23 Nov 2021 07:44:06 +0000 (13:14 +0530)
Eg: Crunchyroll

yt_dlp/extractor/common.py

index 1565ba5c373c3253d814f73a688f664c2ed6ea6f..fc28bca2e1ac6555b33fbd06e2ee590e3e77a58e 100644 (file)
@@ -1452,6 +1452,9 @@ def extract_video_object(e):
                 item_type = e.get('@type')
                 if expected_type is not None and expected_type != item_type:
                     continue
+                rating = traverse_obj(e, ('aggregateRating', 'ratingValue'), expected_type=float_or_none)
+                if rating is not None:
+                    info['average_rating'] = rating
                 if item_type in ('TVEpisode', 'Episode'):
                     episode_name = unescapeHTML(e.get('name'))
                     info.update({