mirror of
https://github.com/yt-dlp/yt-dlp.git
synced 2025-06-28 01:18:30 +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:
parent
ebb4c3ed9a
commit
2bee48cffd
@ -1806,6 +1806,7 @@ #### youtube
|
|||||||
* `visitor_data`: Overrides the Visitor Data used in Innertube API requests. This should be used with `player_skip=webpage,configs` and without cookies. Note: this may have adverse effects if used improperly. If a session from a browser is wanted, you should pass cookies instead (which contain the Visitor ID)
|
* `visitor_data`: Overrides the Visitor Data used in Innertube API requests. This should be used with `player_skip=webpage,configs` and without cookies. Note: this may have adverse effects if used improperly. If a session from a browser is wanted, you should pass cookies instead (which contain the Visitor ID)
|
||||||
* `po_token`: Proof of Origin (PO) Token(s) to use. Comma seperated list of PO Tokens in the format `CLIENT.CONTEXT+PO_TOKEN`, e.g. `youtube:po_token=web.gvs+XXX,web.player=XXX,web_safari.gvs+YYY`. Context can be either `gvs` (Google Video Server URLs) or `player` (Innertube player request)
|
* `po_token`: Proof of Origin (PO) Token(s) to use. Comma seperated list of PO Tokens in the format `CLIENT.CONTEXT+PO_TOKEN`, e.g. `youtube:po_token=web.gvs+XXX,web.player=XXX,web_safari.gvs+YYY`. Context can be either `gvs` (Google Video Server URLs) or `player` (Innertube player request)
|
||||||
* `player_js_variant`: The player javascript variant to use for signature and nsig deciphering. The known variants are: `main`, `tce`, `tv`, `tv_es6`, `phone`, `tablet`. Only `main` is recommended as a possible workaround; the others are for debugging purposes. The default is to use what is prescribed by the site, and can be selected with `actual`
|
* `player_js_variant`: The player javascript variant to use for signature and nsig deciphering. The known variants are: `main`, `tce`, `tv`, `tv_es6`, `phone`, `tablet`. Only `main` is recommended as a possible workaround; the others are for debugging purposes. The default is to use what is prescribed by the site, and can be selected with `actual`
|
||||||
|
* `short_views_type`: The type of views to use for a short its view count. The available types are: `engaged` (default) and `seen`.
|
||||||
|
|
||||||
#### youtubetab (YouTube playlists, channels, feeds, etc.)
|
#### youtubetab (YouTube playlists, channels, feeds, etc.)
|
||||||
* `skip`: One or more of `webpage` (skip initial webpage download), `authcheck` (allow the download of playlists requiring authentication when no initial webpage is downloaded. This may cause unwanted behavior, see [#1122](https://github.com/yt-dlp/yt-dlp/pull/1122) for more details)
|
* `skip`: One or more of `webpage` (skip initial webpage download), `authcheck` (allow the download of playlists requiring authentication when no initial webpage is downloaded. This may cause unwanted behavior, see [#1122](https://github.com/yt-dlp/yt-dlp/pull/1122) for more details)
|
||||||
|
@ -263,7 +263,7 @@ def expect_info_dict(self, got_dict, expected_dict):
|
|||||||
# NB: Keep in sync with the docstring of extractor/common.py
|
# NB: Keep in sync with the docstring of extractor/common.py
|
||||||
'id', 'ext', 'direct', 'display_id', 'title', 'alt_title', 'description', 'media_type',
|
'id', 'ext', 'direct', 'display_id', 'title', 'alt_title', 'description', 'media_type',
|
||||||
'uploader', 'uploader_id', 'uploader_url', 'channel', 'channel_id', 'channel_url', 'channel_is_verified',
|
'uploader', 'uploader_id', 'uploader_url', 'channel', 'channel_id', 'channel_url', 'channel_is_verified',
|
||||||
'channel_follower_count', 'comment_count', 'view_count', 'concurrent_view_count', 'engaged_view_count',
|
'channel_follower_count', 'comment_count', 'view_count', 'concurrent_view_count',
|
||||||
'like_count', 'dislike_count', 'repost_count', 'average_rating', 'age_limit', 'duration', 'thumbnail', 'heatmap',
|
'like_count', 'dislike_count', 'repost_count', 'average_rating', 'age_limit', 'duration', 'thumbnail', 'heatmap',
|
||||||
'chapters', 'chapter', 'chapter_number', 'chapter_id', 'start_time', 'end_time', 'section_start', 'section_end',
|
'chapters', 'chapter', 'chapter_number', 'chapter_id', 'start_time', 'end_time', 'section_start', 'section_end',
|
||||||
'categories', 'tags', 'cast', 'composers', 'artists', 'album_artists', 'creators', 'genres',
|
'categories', 'tags', 'cast', 'composers', 'artists', 'album_artists', 'creators', 'genres',
|
||||||
|
@ -337,7 +337,6 @@ class InfoExtractor:
|
|||||||
duration: Length of the video in seconds, as an integer or float.
|
duration: Length of the video in seconds, as an integer or float.
|
||||||
view_count: How many users have watched the video on the platform.
|
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.
|
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
|
like_count: Number of positive ratings of the video
|
||||||
dislike_count: Number of negative ratings of the video
|
dislike_count: Number of negative ratings of the video
|
||||||
repost_count: Number of reposts of the video
|
repost_count: Number of reposts of the video
|
||||||
|
@ -3999,6 +3999,8 @@ def process_language(container, base_url, lang_code, sub_name, query):
|
|||||||
'toggleButtonViewModel', 'toggleButtonViewModel', 'defaultButtonViewModel',
|
'toggleButtonViewModel', 'toggleButtonViewModel', 'defaultButtonViewModel',
|
||||||
'buttonViewModel', 'accessibilityText', {parse_count}), get_all=False)
|
'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'))
|
vcr = traverse_obj(vpir, ('viewCount', 'videoViewCountRenderer'))
|
||||||
if vcr:
|
if vcr:
|
||||||
vc = self._get_count(vcr, 'viewCount')
|
vc = self._get_count(vcr, 'viewCount')
|
||||||
@ -4007,8 +4009,7 @@ def process_language(container, base_url, lang_code, sub_name, query):
|
|||||||
info['concurrent_view_count'] = vc
|
info['concurrent_view_count'] = vc
|
||||||
elif info.get('view_count') is None:
|
elif info.get('view_count') is None:
|
||||||
info['view_count'] = vc
|
info['view_count'] = vc
|
||||||
elif get_first(microformats, 'isShortsEligible'):
|
elif get_first(microformats, 'isShortsEligible') and short_views_type == 'seen':
|
||||||
info['engaged_view_count'] = info['view_count']
|
|
||||||
info['view_count'] = vc
|
info['view_count'] = vc
|
||||||
|
|
||||||
vsir = get_first(contents, 'videoSecondaryInfoRenderer')
|
vsir = get_first(contents, 'videoSecondaryInfoRenderer')
|
||||||
|
Loading…
Reference in New Issue
Block a user