mirror of
https://github.com/yt-dlp/yt-dlp.git
synced 2024-11-20 05:47:24 +01:00
simplify statements in traversal
This commit is contained in:
parent
88de6d0c2d
commit
8779a8897c
@ -356,7 +356,7 @@ def _real_extract(self, url):
|
|||||||
'channel': channel,
|
'channel': channel,
|
||||||
'channel_id': channel_id,
|
'channel_id': channel_id,
|
||||||
'channel_url': f'{uploader_url}/channels/{channel_id}-{channel}',
|
'channel_url': f'{uploader_url}/channels/{channel_id}-{channel}',
|
||||||
'genres': traverse_obj(attrs, ('data-genres', {str}, {lambda x: x.split(',') if x else []}), default=[]),
|
'genres': traverse_obj(attrs, ('data-genres', {str_or_none}, {str.split(sep=',')}), default=[]),
|
||||||
'season_id': traverse_obj(attrs, ('data-season-id', {str_or_none})),
|
'season_id': traverse_obj(attrs, ('data-season-id', {str_or_none})),
|
||||||
'season_name': traverse_obj(attrs, ('data-season-name', {str})),
|
'season_name': traverse_obj(attrs, ('data-season-name', {str})),
|
||||||
'uploader': uploader,
|
'uploader': uploader,
|
||||||
@ -366,10 +366,10 @@ def _real_extract(self, url):
|
|||||||
'duration': traverse_obj(attrs, ('data-video-duration', {str_to_int})),
|
'duration': traverse_obj(attrs, ('data-video-duration', {str_to_int})),
|
||||||
'description': traverse_obj(attrs, ('data-video-description', {str})),
|
'description': traverse_obj(attrs, ('data-video-description', {str})),
|
||||||
'availability': self._availability(needs_premium=(attrs.get('data-access-type') == 'premium')),
|
'availability': self._availability(needs_premium=(attrs.get('data-access-type') == 'premium')),
|
||||||
'tags': traverse_obj(attrs, ('data-video-tags', {str}, {lambda x: x.split(',') if x else []}), default=[]),
|
'tags': traverse_obj(attrs, ('data-video-tags', {str_or_none}, {str.split(sep=',')}), default=[]),
|
||||||
'timestamp': traverse_obj(attrs, ('data-video-publish-date', {lambda x: parse_iso8601(x, ' ')})),
|
'timestamp': traverse_obj(attrs, ('data-video-publish-date', {parse_iso8601(delimiter=' ')})),
|
||||||
'age_limit': (traverse_obj(attrs, ('data-adult', {lambda x: 18 if x == 'true' else 0}))
|
'age_limit': (traverse_obj(attrs, ('data-adult', {lambda x: 18 if x == 'true' else 0}))
|
||||||
or traverse_obj(attrs, ('data-content-rating-option', {lambda x: remove_end(x, ' or more')}, {str_to_int}))),
|
or traverse_obj(attrs, ('data-content-rating-option', {remove_end(end=' or more')}, {str_to_int}))),
|
||||||
'__post_extractor': self.extract_comments(video_id),
|
'__post_extractor': self.extract_comments(video_id),
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -541,16 +541,16 @@ def _real_extract(self, url):
|
|||||||
'title': attrs.get('data-video-title'),
|
'title': attrs.get('data-video-title'),
|
||||||
'live_status': 'is_live',
|
'live_status': 'is_live',
|
||||||
'formats': formats,
|
'formats': formats,
|
||||||
'genres': traverse_obj(attrs, ('data-genres', {str}, {lambda x: x.split(',') if x else []}), default=[]),
|
'genres': traverse_obj(attrs, ('data-genres', {str_or_none}, {str.split(sep=',')}), default=[]),
|
||||||
'uploader': uploader,
|
'uploader': uploader,
|
||||||
'uploader_id': traverse_obj(attrs, ('data-video-user-id', {str_or_none})),
|
'uploader_id': traverse_obj(attrs, ('data-video-user-id', {str_or_none})),
|
||||||
'uploader_url': uploader_url,
|
'uploader_url': uploader_url,
|
||||||
'thumbnail': traverse_obj(attrs, ('data-video-image-url', {url_or_none})),
|
'thumbnail': traverse_obj(attrs, ('data-video-image-url', {url_or_none})),
|
||||||
'description': traverse_obj(attrs, ('data-video-description', {str})),
|
'description': traverse_obj(attrs, ('data-video-description', {str})),
|
||||||
'availability': self._availability(needs_premium=(attrs.get('data-access-type') == 'premium')),
|
'availability': self._availability(needs_premium=(attrs.get('data-access-type') == 'premium')),
|
||||||
'tags': traverse_obj(attrs, ('data-video-tags', {str}, {lambda x: x.split(',') if x else []}), default=[]),
|
'tags': traverse_obj(attrs, ('data-video-tags', {str_or_none}, {str.split(sep=',')}), default=[]),
|
||||||
'age_limit': (traverse_obj(attrs, ('data-adult', {lambda x: 18 if x == 'true' else 0}))
|
'age_limit': (traverse_obj(attrs, ('data-adult', {lambda x: 18 if x == 'true' else 0}))
|
||||||
or traverse_obj(attrs, ('data-content-rating-option', {lambda x: remove_end(x, ' or more')}, {str_to_int}))),
|
or traverse_obj(attrs, ('data-content-rating-option', {remove_end(end=' or more')}, {str_to_int}))),
|
||||||
'like_count': int_or_none(stream_meta.get('like')),
|
'like_count': int_or_none(stream_meta.get('like')),
|
||||||
'dislike_count': int_or_none(stream_meta.get('dislike')),
|
'dislike_count': int_or_none(stream_meta.get('dislike')),
|
||||||
'timestamp': parse_iso8601(stream_meta.get('start_time')),
|
'timestamp': parse_iso8601(stream_meta.get('start_time')),
|
||||||
|
Loading…
Reference in New Issue
Block a user