mirror of
https://github.com/yt-dlp/yt-dlp.git
synced 2024-11-02 14:37:21 +00:00
[ie] lambda
=>partial_application
cleanup
Authored by: grqz
This commit is contained in:
parent
44518dcbda
commit
61dcaf74ba
|
@ -478,7 +478,7 @@ def test_subs_list_to_dict(self):
|
|||
{'url': 'https://example.com/subs/en', 'name': 'en'},
|
||||
], [..., {
|
||||
'id': 'name',
|
||||
'ext': ['url', {lambda x: determine_ext(x, default_ext=None)}],
|
||||
'ext': ['url', {determine_ext(default_ext=None)}],
|
||||
'url': 'url',
|
||||
}, all, {subs_list_to_dict(ext='ext')}]) == {
|
||||
'de': [{'url': 'https://example.com/subs/de.ass', 'ext': 'ass'}],
|
||||
|
|
|
@ -520,4 +520,4 @@ def _real_extract(self, url):
|
|||
|
||||
return self.playlist_from_matches(
|
||||
self._yield_items(webpage), uploader, f'Discography of {uploader}',
|
||||
getter=functools.partial(urljoin, url))
|
||||
getter=urljoin(url))
|
||||
|
|
|
@ -165,6 +165,6 @@ def _real_extract(self, url):
|
|||
'tags': traverse_obj(json_lds, (..., 'keywords', {lambda x: x.split(',')}, ...)),
|
||||
**traverse_obj(self._parse_vue_attributes('bpb-player', webpage, video_id), {
|
||||
'formats': (':sources', ..., {self._process_source}),
|
||||
'thumbnail': ('poster', {lambda x: urljoin(url, x)}),
|
||||
'thumbnail': ('poster', {urljoin(url)}),
|
||||
}),
|
||||
}
|
||||
|
|
|
@ -145,7 +145,7 @@ def _real_extract(self, url):
|
|||
tp_metadata = self._download_json(
|
||||
update_url_query(tp_url, {'format': 'preview'}), video_id, fatal=False)
|
||||
|
||||
seconds_or_none = lambda x: float_or_none(x, 1000)
|
||||
seconds_or_none = float_or_none(scale=1000)
|
||||
chapters = traverse_obj(tp_metadata, ('chapters', ..., {
|
||||
'start_time': ('startTime', {seconds_or_none}),
|
||||
'end_time': ('endTime', {seconds_or_none}),
|
||||
|
|
|
@ -62,7 +62,7 @@ def _real_extract(self, url):
|
|||
'title': ('broadcast_title', {str}),
|
||||
'duration': ('content_duration', {int_or_none}),
|
||||
'timestamp': ('broadcast_start_time', {parse_iso8601}),
|
||||
'thumbnail': ('preview_image_path', {lambda x: urljoin(url, x)}),
|
||||
'thumbnail': ('preview_image_path', {urljoin(url)}),
|
||||
}),
|
||||
'age_limit': {
|
||||
# assume Apple Store ratings: https://en.wikipedia.org/wiki/Mobile_software_content_rating_system
|
||||
|
|
|
@ -465,7 +465,7 @@ def _real_extract(self, url):
|
|||
**traverse_obj(data, {
|
||||
'title': ('title', {str}),
|
||||
'description': ('description', {str.strip}),
|
||||
'thumbnail': ('image', 'url', {url_or_none}, {functools.partial(update_url, query=None)}),
|
||||
'thumbnail': ('image', 'url', {url_or_none}, {update_url(query=None)}),
|
||||
'timestamp': ('publishedAt', {float_or_none(scale=1000)}),
|
||||
'media_type': ('media', 'clipType', {str}),
|
||||
'series': ('showName', {str}),
|
||||
|
|
|
@ -77,7 +77,7 @@ def _real_extract(self, url):
|
|||
'thumbnails': thumbnails,
|
||||
**traverse_obj(live_detail, {
|
||||
'title': ('liveTitle', {str}),
|
||||
'timestamp': ('openDate', {functools.partial(parse_iso8601, delimiter=' ')}),
|
||||
'timestamp': ('openDate', {parse_iso8601(delimiter=' ')}),
|
||||
'concurrent_view_count': ('concurrentUserCount', {int_or_none}),
|
||||
'view_count': ('accumulateCount', {int_or_none}),
|
||||
'channel': ('channel', 'channelName', {str}),
|
||||
|
|
|
@ -199,7 +199,7 @@ def _real_extract(self, url):
|
|||
'timestamp': ('data-publish-date', {parse_iso8601}),
|
||||
'thumbnail': (
|
||||
'data-poster-image-override', {json.loads}, 'big', 'uri', {url_or_none},
|
||||
{functools.partial(update_url, query='c=original')}),
|
||||
{update_url(query='c=original')}),
|
||||
'display_id': 'data-video-slug',
|
||||
}),
|
||||
**traverse_obj(video_data, {
|
||||
|
|
|
@ -12,6 +12,7 @@
|
|||
parse_iso8601,
|
||||
strip_or_none,
|
||||
try_get,
|
||||
urljoin,
|
||||
)
|
||||
|
||||
|
||||
|
@ -112,8 +113,7 @@ def _extract_series(self, url, webpage):
|
|||
m_paths = re.finditer(
|
||||
r'(?s)<p class="cne-thumb-title">.*?<a href="(/watch/.+?)["\?]', webpage)
|
||||
paths = orderedSet(m.group(1) for m in m_paths)
|
||||
build_url = lambda path: urllib.parse.urljoin(base_url, path)
|
||||
entries = [self.url_result(build_url(path), 'CondeNast') for path in paths]
|
||||
entries = [self.url_result(urljoin(base_url, path), 'CondeNast') for path in paths]
|
||||
return self.playlist_result(entries, playlist_title=title)
|
||||
|
||||
def _extract_video_params(self, webpage, display_id):
|
||||
|
|
|
@ -32,7 +32,7 @@ def _parse_episode(self, episode):
|
|||
VimeoIE, url_transparent=True,
|
||||
**traverse_obj(episode, {
|
||||
'id': ('id', {int}, {str_or_none}),
|
||||
'webpage_url': ('path', {lambda x: urljoin('https://laracasts.com', x)}),
|
||||
'webpage_url': ('path', {urljoin('https://laracasts.com')}),
|
||||
'title': ('title', {clean_html}),
|
||||
'season_number': ('chapter', {int_or_none}),
|
||||
'episode_number': ('position', {int_or_none}),
|
||||
|
|
|
@ -86,7 +86,7 @@ def _extract_formats(self, content_id, slug):
|
|||
|
||||
def _extract_video_metadata(self, episode):
|
||||
channel_url = traverse_obj(
|
||||
episode, (('channel_slug', 'class_slug'), {lambda x: urljoin('https://nebula.tv/', x)}), get_all=False)
|
||||
episode, (('channel_slug', 'class_slug'), {urljoin('https://nebula.tv/')}), get_all=False)
|
||||
return {
|
||||
'id': episode['id'].partition(':')[2],
|
||||
**traverse_obj(episode, {
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
import functools
|
||||
|
||||
from .common import InfoExtractor
|
||||
from .youtube import YoutubeIE
|
||||
from ..utils import (
|
||||
|
@ -83,7 +81,7 @@ def _real_extract(self, url):
|
|||
'timestamp': ('date_created', {unified_timestamp}),
|
||||
'uploader': ('user', 'name', {strip_or_none}),
|
||||
'uploader_id': ('user', 'username', {str}),
|
||||
'uploader_url': ('user', 'username', {functools.partial(urljoin, 'https://parler.com/')}),
|
||||
'uploader_url': ('user', 'username', {urljoin('https://parler.com/')}),
|
||||
'view_count': ('views', {int_or_none}),
|
||||
'comment_count': ('total_comments', {int_or_none}),
|
||||
'repost_count': ('echos', {int_or_none}),
|
||||
|
|
|
@ -198,6 +198,6 @@ def _real_extract(self, url):
|
|||
'dislike_count': ('down', {int}),
|
||||
'timestamp': ('created', {int}),
|
||||
'upload_date': ('created', {int}, {dt.date.fromtimestamp}, {lambda x: x.strftime('%Y%m%d')}),
|
||||
'thumbnail': ('thumb', {lambda x: urljoin('https://thumb.pr0gramm.com', x)}),
|
||||
'thumbnail': ('thumb', {urljoin('https://thumb.pr0gramm.com')}),
|
||||
}),
|
||||
}
|
||||
|
|
|
@ -187,4 +187,4 @@ def _real_extract(self, url):
|
|||
return self.playlist_from_matches(
|
||||
re.findall(r'<a [^>]*\bhref="(/arhiv/[^"]+)"', webpage),
|
||||
playlist_id, self._html_extract_title(webpage),
|
||||
getter=lambda x: urljoin('https://365.rtvslo.si', x), ie=RTVSLOIE)
|
||||
getter=urljoin('https://365.rtvslo.si'), ie=RTVSLOIE)
|
||||
|
|
|
@ -136,7 +136,7 @@ def _real_extract(self, url):
|
|||
'blocks', lambda _, v: v['name'] in ('meta-tags', 'video-player', 'video-info'), 'props', {dict})))
|
||||
|
||||
thumbnail = traverse_obj(
|
||||
info, (('image', 'poster'), {lambda x: urljoin('https://teamcoco.com/', x)}), get_all=False)
|
||||
info, (('image', 'poster'), {urljoin('https://teamcoco.com/')}), get_all=False)
|
||||
video_id = traverse_obj(parse_qs(thumbnail), ('id', 0)) or display_id
|
||||
|
||||
formats, subtitles = self._get_formats_and_subtitles(info, video_id)
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
|
||||
|
||||
def _fmt_url(url):
|
||||
return functools.partial(format_field, template=url, default=None)
|
||||
return format_field(template=url, default=None)
|
||||
|
||||
|
||||
class TelewebionIE(InfoExtractor):
|
||||
|
|
|
@ -278,7 +278,7 @@ def _real_extract(self, url):
|
|||
webpage)]
|
||||
|
||||
return self.playlist_from_matches(
|
||||
episode_paths, series_id, ie=VQQVideoIE, getter=functools.partial(urljoin, url),
|
||||
episode_paths, series_id, ie=VQQVideoIE, getter=urljoin(url),
|
||||
title=self._get_clean_title(traverse_obj(webpage_metadata, ('coverInfo', 'title'))
|
||||
or self._og_search_title(webpage)),
|
||||
description=(traverse_obj(webpage_metadata, ('coverInfo', 'description'))
|
||||
|
@ -328,7 +328,7 @@ def _extract_series(self, url, ie):
|
|||
or re.findall(r'<a[^>]+class="play-video__link"[^>]+href="(?P<path>[^"]+)', webpage))
|
||||
|
||||
return self.playlist_from_matches(
|
||||
episode_paths, series_id, ie=ie, getter=functools.partial(urljoin, url),
|
||||
episode_paths, series_id, ie=ie, getter=urljoin(url),
|
||||
title=self._get_clean_title(traverse_obj(webpage_metadata, ('coverInfo', 'title'))
|
||||
or self._og_search_title(webpage)),
|
||||
description=(traverse_obj(webpage_metadata, ('coverInfo', 'description'))
|
||||
|
|
|
@ -161,4 +161,4 @@ def _real_extract(self, url):
|
|||
return self.playlist_from_matches(
|
||||
self._entries(urljoin(url, episodes_carousel['loadMoreUrl']), playlist_id),
|
||||
playlist_id, traverse_obj(season_info, ('content', 0, 'title', {str})),
|
||||
getter=functools.partial(urljoin, url))
|
||||
getter=urljoin(url))
|
||||
|
|
|
@ -131,4 +131,4 @@ def _real_extract(self, url):
|
|||
|
||||
return self.playlist_from_matches(
|
||||
self._entries(url, podcast_id), podcast_id, title, description=description,
|
||||
ie=TheGuardianPodcastIE, getter=lambda x: urljoin('https://www.theguardian.com', x))
|
||||
ie=TheGuardianPodcastIE, getter=urljoin('https://www.theguardian.com'))
|
||||
|
|
|
@ -114,7 +114,7 @@ def _parse_video_info(self, video_info, video_id=None):
|
|||
'thumbnail': ('page_info', 'page_pic', {url_or_none}),
|
||||
'uploader': ('user', 'screen_name', {str}),
|
||||
'uploader_id': ('user', ('id', 'id_str'), {str_or_none}),
|
||||
'uploader_url': ('user', 'profile_url', {lambda x: urljoin('https://weibo.com/', x)}),
|
||||
'uploader_url': ('user', 'profile_url', {urljoin('https://weibo.com/')}),
|
||||
'view_count': ('page_info', 'media_info', 'online_users_number', {int_or_none}),
|
||||
'like_count': ('attitudes_count', {int_or_none}),
|
||||
'repost_count': ('reposts_count', {int_or_none}),
|
||||
|
|
|
@ -247,7 +247,7 @@ def _entries(self, url, pl_id, html=None, page_num=None):
|
|||
if not html:
|
||||
return
|
||||
for element in get_elements_html_by_class('video-title', html):
|
||||
if video_url := traverse_obj(element, ({extract_attributes}, 'href', {lambda x: urljoin(url, x)})):
|
||||
if video_url := traverse_obj(element, ({extract_attributes}, 'href', {urljoin(url)})):
|
||||
yield self.url_result(video_url)
|
||||
|
||||
if page_num is not None:
|
||||
|
|
|
@ -3637,7 +3637,7 @@ def _extract_comment(self, entities, parent=None):
|
|||
'author_is_verified': ('author', 'isVerified', {bool}),
|
||||
'author_url': ('author', 'channelCommand', 'innertubeCommand', (
|
||||
('browseEndpoint', 'canonicalBaseUrl'), ('commandMetadata', 'webCommandMetadata', 'url'),
|
||||
), {lambda x: urljoin('https://www.youtube.com', x)}),
|
||||
), {urljoin('https://www.youtube.com')}),
|
||||
}, get_all=False),
|
||||
'is_favorited': (None if toolbar_entity_payload is None else
|
||||
toolbar_entity_payload.get('heartState') == 'TOOLBAR_HEART_STATE_HEARTED'),
|
||||
|
|
Loading…
Reference in a new issue