mirror of
https://github.com/yt-dlp/yt-dlp
synced 2024-12-28 22:24:34 +01:00
[cleanup] Fix flake8 and minor refactor
Issues fromab029d7e92
,1fb53b946c
This commit is contained in:
parent
709ee21417
commit
7a32c70d13
2 changed files with 20 additions and 29 deletions
|
@ -30,6 +30,7 @@ from ..utils import (
|
||||||
clean_html,
|
clean_html,
|
||||||
datetime_from_str,
|
datetime_from_str,
|
||||||
dict_get,
|
dict_get,
|
||||||
|
filter_dict,
|
||||||
float_or_none,
|
float_or_none,
|
||||||
format_field,
|
format_field,
|
||||||
get_first,
|
get_first,
|
||||||
|
@ -617,7 +618,7 @@ class YoutubeBaseInfoExtractor(InfoExtractor):
|
||||||
if auth is not None:
|
if auth is not None:
|
||||||
headers['Authorization'] = auth
|
headers['Authorization'] = auth
|
||||||
headers['X-Origin'] = origin
|
headers['X-Origin'] = origin
|
||||||
return {h: v for h, v in headers.items() if v is not None}
|
return filter_dict(headers)
|
||||||
|
|
||||||
def _download_ytcfg(self, client, video_id):
|
def _download_ytcfg(self, client, video_id):
|
||||||
url = {
|
url = {
|
||||||
|
@ -672,20 +673,10 @@ class YoutubeBaseInfoExtractor(InfoExtractor):
|
||||||
if next_continuation:
|
if next_continuation:
|
||||||
return next_continuation
|
return next_continuation
|
||||||
|
|
||||||
contents = []
|
return traverse_obj(renderer, (
|
||||||
for key in ('contents', 'items', 'rows'):
|
('contents', 'items', 'rows'), ..., 'continuationItemRenderer',
|
||||||
contents.extend(try_get(renderer, lambda x: x[key], list) or [])
|
('continuationEndpoint', ('button', 'buttonRenderer', 'command'))
|
||||||
|
), get_all=False, expected_type=cls._extract_continuation_ep_data)
|
||||||
for content in contents:
|
|
||||||
if not isinstance(content, dict):
|
|
||||||
continue
|
|
||||||
continuation_ep = try_get(
|
|
||||||
content, (lambda x: x['continuationItemRenderer']['continuationEndpoint'],
|
|
||||||
lambda x: x['continuationItemRenderer']['button']['buttonRenderer']['command']),
|
|
||||||
dict)
|
|
||||||
continuation = cls._extract_continuation_ep_data(continuation_ep)
|
|
||||||
if continuation:
|
|
||||||
return continuation
|
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def _extract_alerts(cls, data):
|
def _extract_alerts(cls, data):
|
||||||
|
@ -4553,7 +4544,7 @@ class YoutubeTabBaseInfoExtractor(YoutubeBaseInfoExtractor):
|
||||||
uploader['uploader_url'] = urljoin(
|
uploader['uploader_url'] = urljoin(
|
||||||
'https://www.youtube.com/',
|
'https://www.youtube.com/',
|
||||||
try_get(owner, lambda x: x['navigationEndpoint']['browseEndpoint']['canonicalBaseUrl'], str))
|
try_get(owner, lambda x: x['navigationEndpoint']['browseEndpoint']['canonicalBaseUrl'], str))
|
||||||
return {k: v for k, v in uploader.items() if v is not None}
|
return filter_dict(uploader)
|
||||||
|
|
||||||
def _extract_from_tabs(self, item_id, ytcfg, data, tabs):
|
def _extract_from_tabs(self, item_id, ytcfg, data, tabs):
|
||||||
playlist_id = title = description = channel_url = channel_name = channel_id = None
|
playlist_id = title = description = channel_url = channel_name = channel_id = None
|
||||||
|
|
Loading…
Reference in a new issue