1
0
mirror of https://github.com/yt-dlp/yt-dlp.git synced 2025-12-30 19:41:27 +00:00

[ie/youtube] Make short views type an extractor argument

- Add `short_views_type` as an extractor argument to address [#13122](https://github.com/yt-dlp/yt-dlp/issues/13122#issuecomment-2862720272)
This commit is contained in:
Rico van Zelst
2025-05-08 15:01:34 +02:00
parent ebb4c3ed9a
commit 2bee48cffd
4 changed files with 5 additions and 4 deletions

View File

@@ -337,7 +337,6 @@ class InfoExtractor:
duration: Length of the video in seconds, as an integer or float.
view_count: How many users have watched the video on the platform.
concurrent_view_count: How many users are currently watching the video on the platform.
engaged_view_count: How many engaged users have watched the video on the platform.
like_count: Number of positive ratings of the video
dislike_count: Number of negative ratings of the video
repost_count: Number of reposts of the video

View File

@@ -3999,6 +3999,8 @@ class YoutubeIE(YoutubeBaseInfoExtractor):
'toggleButtonViewModel', 'toggleButtonViewModel', 'defaultButtonViewModel',
'buttonViewModel', 'accessibilityText', {parse_count}), get_all=False)
short_views_type = self._configuration_arg('short_views_type', ['engaged'])[0].lower()
vcr = traverse_obj(vpir, ('viewCount', 'videoViewCountRenderer'))
if vcr:
vc = self._get_count(vcr, 'viewCount')
@@ -4007,8 +4009,7 @@ class YoutubeIE(YoutubeBaseInfoExtractor):
info['concurrent_view_count'] = vc
elif info.get('view_count') is None:
info['view_count'] = vc
elif get_first(microformats, 'isShortsEligible'):
info['engaged_view_count'] = info['view_count']
elif get_first(microformats, 'isShortsEligible') and short_views_type == 'seen':
info['view_count'] = vc
vsir = get_first(contents, 'videoSecondaryInfoRenderer')