mirror of
https://github.com/yt-dlp/yt-dlp.git
synced 2024-11-24 07:40:30 +01:00
[extractor] Improve url_result
and related
This commit is contained in:
parent
396a76f7bf
commit
311b6615d8
@ -1120,39 +1120,39 @@ def raise_no_formats(self, msg, expected=False, video_id=None):
|
||||
|
||||
# Methods for following #608
|
||||
@staticmethod
|
||||
def url_result(url, ie=None, video_id=None, video_title=None, **kwargs):
|
||||
def url_result(url, ie=None, video_id=None, video_title=None, *, url_transparent=False, **kwargs):
|
||||
"""Returns a URL that points to a page that should be processed"""
|
||||
# TODO: ie should be the class used for getting the info
|
||||
video_info = {'_type': 'url',
|
||||
'url': url,
|
||||
'ie_key': ie}
|
||||
video_info.update(kwargs)
|
||||
if ie is not None:
|
||||
kwargs['ie_key'] = ie if isinstance(ie, str) else ie.ie_key()
|
||||
if video_id is not None:
|
||||
video_info['id'] = video_id
|
||||
kwargs['id'] = video_id
|
||||
if video_title is not None:
|
||||
video_info['title'] = video_title
|
||||
return video_info
|
||||
kwargs['title'] = video_title
|
||||
return {
|
||||
**kwargs,
|
||||
'_type': 'url_transparent' if url_transparent else 'url',
|
||||
'url': url,
|
||||
}
|
||||
|
||||
def playlist_from_matches(self, matches, playlist_id=None, playlist_title=None, getter=None, ie=None):
|
||||
urls = orderedSet(
|
||||
self.url_result(self._proto_relative_url(getter(m) if getter else m), ie)
|
||||
for m in matches)
|
||||
return self.playlist_result(
|
||||
urls, playlist_id=playlist_id, playlist_title=playlist_title)
|
||||
def playlist_from_matches(self, matches, playlist_id=None, playlist_title=None, getter=None, ie=None, **kwargs):
|
||||
urls = (self.url_result(self._proto_relative_url(m), ie)
|
||||
for m in orderedSet(map(getter, matches) if getter else matches))
|
||||
return self.playlist_result(urls, playlist_id, playlist_title, **kwargs)
|
||||
|
||||
@staticmethod
|
||||
def playlist_result(entries, playlist_id=None, playlist_title=None, playlist_description=None, **kwargs):
|
||||
def playlist_result(entries, playlist_id=None, playlist_title=None, playlist_description=None, *, multi_video=False, **kwargs):
|
||||
"""Returns a playlist"""
|
||||
video_info = {'_type': 'playlist',
|
||||
'entries': entries}
|
||||
video_info.update(kwargs)
|
||||
if playlist_id:
|
||||
video_info['id'] = playlist_id
|
||||
kwargs['id'] = playlist_id
|
||||
if playlist_title:
|
||||
video_info['title'] = playlist_title
|
||||
kwargs['title'] = playlist_title
|
||||
if playlist_description is not None:
|
||||
video_info['description'] = playlist_description
|
||||
return video_info
|
||||
kwargs['description'] = playlist_description
|
||||
return {
|
||||
**kwargs,
|
||||
'_type': 'multi_video' if multi_video else 'playlist',
|
||||
'entries': entries,
|
||||
}
|
||||
|
||||
def _search_regex(self, pattern, string, name, default=NO_DEFAULT, fatal=True, flags=0, group=None):
|
||||
"""
|
||||
|
Loading…
Reference in New Issue
Block a user