[cleanup, utils] Don't use kwargs for format_field

This commit is contained in:
pukkandan 2022-06-18 07:30:12 +05:30
parent e121e3cee7
commit a70635b8a1
No known key found for this signature in database
GPG key ID: 7EEE9E1E817D0A39
25 changed files with 32 additions and 32 deletions

View file

@ -90,7 +90,7 @@ class ArnesIE(InfoExtractor):
'timestamp': parse_iso8601(video.get('creationTime')), 'timestamp': parse_iso8601(video.get('creationTime')),
'channel': channel.get('name'), 'channel': channel.get('name'),
'channel_id': channel_id, 'channel_id': channel_id,
'channel_url': format_field(channel_id, template=f'{self._BASE_URL}/?channel=%s'), 'channel_url': format_field(channel_id, None, f'{self._BASE_URL}/?channel=%s'),
'duration': float_or_none(video.get('duration'), 1000), 'duration': float_or_none(video.get('duration'), 1000),
'view_count': int_or_none(video.get('views')), 'view_count': int_or_none(video.get('views')),
'tags': video.get('hashtags'), 'tags': video.get('hashtags'),

View file

@ -41,7 +41,7 @@ class AWAANBaseIE(InfoExtractor):
'id': video_id, 'id': video_id,
'title': title, 'title': title,
'description': video_data.get('description_en') or video_data.get('description_ar'), 'description': video_data.get('description_en') or video_data.get('description_ar'),
'thumbnail': format_field(img, template='http://admin.mangomolo.com/analytics/%s'), 'thumbnail': format_field(img, None, 'http://admin.mangomolo.com/analytics/%s'),
'duration': int_or_none(video_data.get('duration')), 'duration': int_or_none(video_data.get('duration')),
'timestamp': parse_iso8601(video_data.get('create_time'), ' '), 'timestamp': parse_iso8601(video_data.get('create_time'), ' '),
'is_live': is_live, 'is_live': is_live,

View file

@ -1050,7 +1050,7 @@ class InfoExtractor:
self._sleep(timeout, video_id) self._sleep(timeout, video_id)
def report_warning(self, msg, video_id=None, *args, only_once=False, **kwargs): def report_warning(self, msg, video_id=None, *args, only_once=False, **kwargs):
idstr = format_field(video_id, template='%s: ') idstr = format_field(video_id, None, '%s: ')
msg = f'[{self.IE_NAME}] {idstr}{msg}' msg = f'[{self.IE_NAME}] {idstr}{msg}'
if only_once: if only_once:
if f'WARNING: {msg}' in self._printed_messages: if f'WARNING: {msg}' in self._printed_messages:
@ -1096,7 +1096,7 @@ class InfoExtractor:
self.get_param('ignore_no_formats_error') or self.get_param('wait_for_video')): self.get_param('ignore_no_formats_error') or self.get_param('wait_for_video')):
self.report_warning(msg) self.report_warning(msg)
return return
msg += format_field(self._login_hint(method), template='. %s') msg += format_field(self._login_hint(method), None, '. %s')
raise ExtractorError(msg, expected=True) raise ExtractorError(msg, expected=True)
def raise_geo_restricted( def raise_geo_restricted(

View file

@ -94,7 +94,7 @@ class FlickrIE(InfoExtractor):
owner = video_info.get('owner', {}) owner = video_info.get('owner', {})
uploader_id = owner.get('nsid') uploader_id = owner.get('nsid')
uploader_path = owner.get('path_alias') or uploader_id uploader_path = owner.get('path_alias') or uploader_id
uploader_url = format_field(uploader_path, template='https://www.flickr.com/photos/%s/') uploader_url = format_field(uploader_path, None, 'https://www.flickr.com/photos/%s/')
return { return {
'id': video_id, 'id': video_id,

View file

@ -410,7 +410,7 @@ class InstagramIE(InstagramBaseIE):
if nodes: if nodes:
return self.playlist_result( return self.playlist_result(
self._extract_nodes(nodes, True), video_id, self._extract_nodes(nodes, True), video_id,
format_field(username, template='Post by %s'), description) format_field(username, None, 'Post by %s'), description)
video_url = self._og_search_video_url(webpage, secure=False) video_url = self._og_search_video_url(webpage, secure=False)

View file

@ -610,7 +610,7 @@ class IqIE(InfoExtractor):
preview_time = traverse_obj( preview_time = traverse_obj(
initial_format_data, ('boss_ts', (None, 'data'), ('previewTime', 'rtime')), expected_type=float_or_none, get_all=False) initial_format_data, ('boss_ts', (None, 'data'), ('previewTime', 'rtime')), expected_type=float_or_none, get_all=False)
if traverse_obj(initial_format_data, ('boss_ts', 'data', 'prv'), expected_type=int_or_none): if traverse_obj(initial_format_data, ('boss_ts', 'data', 'prv'), expected_type=int_or_none):
self.report_warning('This preview video is limited%s' % format_field(preview_time, template=' to %s seconds')) self.report_warning('This preview video is limited%s' % format_field(preview_time, None, ' to %s seconds'))
# TODO: Extract audio-only formats # TODO: Extract audio-only formats
for bid in set(traverse_obj(initial_format_data, ('program', 'video', ..., 'bid'), expected_type=str_or_none, default=[])): for bid in set(traverse_obj(initial_format_data, ('program', 'video', ..., 'bid'), expected_type=str_or_none, default=[])):

View file

@ -70,7 +70,7 @@ class JojIE(InfoExtractor):
r'(\d+)[pP]\.', format_url, 'height', default=None) r'(\d+)[pP]\.', format_url, 'height', default=None)
formats.append({ formats.append({
'url': format_url, 'url': format_url,
'format_id': format_field(height, template='%sp'), 'format_id': format_field(height, None, '%sp'),
'height': int(height), 'height': int(height),
}) })
if not formats: if not formats:

View file

@ -68,7 +68,7 @@ class KeezMoviesIE(InfoExtractor):
video_url, title, 32).decode('utf-8') video_url, title, 32).decode('utf-8')
formats.append({ formats.append({
'url': format_url, 'url': format_url,
'format_id': format_field(height, template='%dp'), 'format_id': format_field(height, None, '%dp'),
'height': height, 'height': height,
'tbr': tbr, 'tbr': tbr,
}) })

View file

@ -15,7 +15,7 @@ class LastFMPlaylistBaseIE(InfoExtractor):
for page_number in range(start_page_number, (last_page_number or start_page_number) + 1): for page_number in range(start_page_number, (last_page_number or start_page_number) + 1):
webpage = self._download_webpage( webpage = self._download_webpage(
url, playlist_id, url, playlist_id,
note='Downloading page %d%s' % (page_number, format_field(last_page_number, template=' of %d')), note='Downloading page %d%s' % (page_number, format_field(last_page_number, None, ' of %d')),
query={'page': page_number}) query={'page': page_number})
page_entries = [ page_entries = [
self.url_result(player_url, 'Youtube') self.url_result(player_url, 'Youtube')

View file

@ -34,7 +34,7 @@ class LineLiveBaseIE(InfoExtractor):
'timestamp': int_or_none(item.get('createdAt')), 'timestamp': int_or_none(item.get('createdAt')),
'channel': channel.get('name'), 'channel': channel.get('name'),
'channel_id': channel_id, 'channel_id': channel_id,
'channel_url': format_field(channel_id, template='https://live.line.me/channels/%s'), 'channel_url': format_field(channel_id, None, 'https://live.line.me/channels/%s'),
'duration': int_or_none(item.get('archiveDuration')), 'duration': int_or_none(item.get('archiveDuration')),
'view_count': int_or_none(item.get('viewerCount')), 'view_count': int_or_none(item.get('viewerCount')),
'comment_count': int_or_none(item.get('chatCount')), 'comment_count': int_or_none(item.get('chatCount')),

View file

@ -116,7 +116,7 @@ class MedalTVIE(InfoExtractor):
author = try_get( author = try_get(
hydration_data, lambda x: list(x['profiles'].values())[0], dict) or {} hydration_data, lambda x: list(x['profiles'].values())[0], dict) or {}
author_id = str_or_none(author.get('id')) author_id = str_or_none(author.get('id'))
author_url = format_field(author_id, template='https://medal.tv/users/%s') author_url = format_field(author_id, None, 'https://medal.tv/users/%s')
return { return {
'id': video_id, 'id': video_id,

View file

@ -118,7 +118,7 @@ class MindsIE(MindsBaseIE):
'timestamp': int_or_none(entity.get('time_created')), 'timestamp': int_or_none(entity.get('time_created')),
'uploader': strip_or_none(owner.get('name')), 'uploader': strip_or_none(owner.get('name')),
'uploader_id': uploader_id, 'uploader_id': uploader_id,
'uploader_url': format_field(uploader_id, template='https://www.minds.com/%s'), 'uploader_url': format_field(uploader_id, None, 'https://www.minds.com/%s'),
'view_count': int_or_none(entity.get('play:count')), 'view_count': int_or_none(entity.get('play:count')),
'like_count': int_or_none(entity.get('thumbs:up:count')), 'like_count': int_or_none(entity.get('thumbs:up:count')),
'dislike_count': int_or_none(entity.get('thumbs:down:count')), 'dislike_count': int_or_none(entity.get('thumbs:down:count')),

View file

@ -429,7 +429,7 @@ class PornHubIE(PornHubBaseIE):
default=None)) default=None))
formats.append({ formats.append({
'url': format_url, 'url': format_url,
'format_id': format_field(height, template='%dp'), 'format_id': format_field(height, None, '%dp'),
'height': height, 'height': height,
}) })

View file

@ -80,7 +80,7 @@ class RadLiveIE(InfoExtractor):
'release_timestamp': release_date, 'release_timestamp': release_date,
'channel': channel.get('name'), 'channel': channel.get('name'),
'channel_id': channel_id, 'channel_id': channel_id,
'channel_url': format_field(channel_id, template='https://rad.live/content/channel/%s'), 'channel_url': format_field(channel_id, None, 'https://rad.live/content/channel/%s'),
} }
if content_type == 'episode': if content_type == 'episode':

View file

@ -146,7 +146,7 @@ class RokfinIE(InfoExtractor):
for page_n in itertools.count(): for page_n in itertools.count():
raw_comments = self._download_json( raw_comments = self._download_json(
f'{_API_BASE_URL}comment?postId={video_id[5:]}&page={page_n}&size=50', f'{_API_BASE_URL}comment?postId={video_id[5:]}&page={page_n}&size=50',
video_id, note=f'Downloading viewer comments page {page_n + 1}{format_field(pages_total, template=" of %s")}', video_id, note=f'Downloading viewer comments page {page_n + 1}{format_field(pages_total, None, " of %s")}',
fatal=False) or {} fatal=False) or {}
for comment in raw_comments.get('content') or []: for comment in raw_comments.get('content') or []:
@ -318,7 +318,7 @@ class RokfinChannelIE(RokfinPlaylistBaseIE):
data_url = f'{_API_BASE_URL}post/search/{tab}?page={page_n}&size=50&creator={channel_id}' data_url = f'{_API_BASE_URL}post/search/{tab}?page={page_n}&size=50&creator={channel_id}'
metadata = self._download_json( metadata = self._download_json(
data_url, channel_name, data_url, channel_name,
note=f'Downloading video metadata page {page_n + 1}{format_field(pages_total, template=" of %s")}') note=f'Downloading video metadata page {page_n + 1}{format_field(pages_total, None, " of %s")}')
yield from self._get_video_data(metadata) yield from self._get_video_data(metadata)
pages_total = int_or_none(metadata.get('totalPages')) or None pages_total = int_or_none(metadata.get('totalPages')) or None
@ -369,7 +369,7 @@ class RokfinSearchIE(SearchInfoExtractor):
for page_number in itertools.count(1): for page_number in itertools.count(1):
search_results = self._run_search_query( search_results = self._run_search_query(
query, data={'query': query, 'page': {'size': 100, 'current': page_number}}, query, data={'query': query, 'page': {'size': 100, 'current': page_number}},
note=f'Downloading page {page_number}{format_field(total_pages, template=" of ~%s")}') note=f'Downloading page {page_number}{format_field(total_pages, None, " of ~%s")}')
total_pages = traverse_obj(search_results, ('meta', 'page', 'total_pages'), expected_type=int_or_none) total_pages = traverse_obj(search_results, ('meta', 'page', 'total_pages'), expected_type=int_or_none)
for result in search_results.get('results') or []: for result in search_results.get('results') or []:

View file

@ -44,7 +44,7 @@ class StoryFireBaseIE(InfoExtractor):
'timestamp': int_or_none(video.get('publishDate')), 'timestamp': int_or_none(video.get('publishDate')),
'uploader': video.get('username'), 'uploader': video.get('username'),
'uploader_id': uploader_id, 'uploader_id': uploader_id,
'uploader_url': format_field(uploader_id, template='https://storyfire.com/user/%s/video'), 'uploader_url': format_field(uploader_id, None, 'https://storyfire.com/user/%s/video'),
'episode_number': int_or_none(video.get('episodeNumber') or video.get('episode_number')), 'episode_number': int_or_none(video.get('episodeNumber') or video.get('episode_number')),
} }

View file

@ -38,7 +38,7 @@ class TrovoBaseIE(InfoExtractor):
return { return {
'uploader': streamer_info.get('nickName'), 'uploader': streamer_info.get('nickName'),
'uploader_id': str_or_none(streamer_info.get('uid')), 'uploader_id': str_or_none(streamer_info.get('uid')),
'uploader_url': format_field(username, template='https://trovo.live/%s'), 'uploader_url': format_field(username, None, 'https://trovo.live/%s'),
} }

View file

@ -470,7 +470,7 @@ class TwitterIE(TwitterBaseIE):
'uploader': uploader, 'uploader': uploader,
'timestamp': unified_timestamp(status.get('created_at')), 'timestamp': unified_timestamp(status.get('created_at')),
'uploader_id': uploader_id, 'uploader_id': uploader_id,
'uploader_url': format_field(uploader_id, template='https://twitter.com/%s'), 'uploader_url': format_field(uploader_id, None, 'https://twitter.com/%s'),
'like_count': int_or_none(status.get('favorite_count')), 'like_count': int_or_none(status.get('favorite_count')),
'repost_count': int_or_none(status.get('retweet_count')), 'repost_count': int_or_none(status.get('retweet_count')),
'comment_count': int_or_none(status.get('reply_count')), 'comment_count': int_or_none(status.get('reply_count')),

View file

@ -152,7 +152,7 @@ class VidioIE(VidioBaseIE):
'uploader': user.get('name'), 'uploader': user.get('name'),
'timestamp': parse_iso8601(video.get('created_at')), 'timestamp': parse_iso8601(video.get('created_at')),
'uploader_id': username, 'uploader_id': username,
'uploader_url': format_field(username, template='https://www.vidio.com/@%s'), 'uploader_url': format_field(username, None, 'https://www.vidio.com/@%s'),
'channel': channel.get('name'), 'channel': channel.get('name'),
'channel_id': str_or_none(channel.get('id')), 'channel_id': str_or_none(channel.get('id')),
'view_count': get_count('view_count'), 'view_count': get_count('view_count'),
@ -283,5 +283,5 @@ class VidioLiveIE(VidioBaseIE):
'uploader': user.get('name'), 'uploader': user.get('name'),
'timestamp': parse_iso8601(stream_meta.get('start_time')), 'timestamp': parse_iso8601(stream_meta.get('start_time')),
'uploader_id': username, 'uploader_id': username,
'uploader_url': format_field(username, template='https://www.vidio.com/@%s'), 'uploader_url': format_field(username, None, 'https://www.vidio.com/@%s'),
} }

View file

@ -100,7 +100,7 @@ class VidLiiIE(InfoExtractor):
uploader = self._search_regex( uploader = self._search_regex(
r'<div[^>]+class=["\']wt_person[^>]+>\s*<a[^>]+\bhref=["\']/user/[^>]+>([^<]+)', r'<div[^>]+class=["\']wt_person[^>]+>\s*<a[^>]+\bhref=["\']/user/[^>]+>([^<]+)',
webpage, 'uploader', fatal=False) webpage, 'uploader', fatal=False)
uploader_url = format_field(uploader, template='https://www.vidlii.com/user/%s') uploader_url = format_field(uploader, None, 'https://www.vidlii.com/user/%s')
upload_date = unified_strdate(self._html_search_meta( upload_date = unified_strdate(self._html_search_meta(
'datePublished', webpage, default=None) or self._search_regex( 'datePublished', webpage, default=None) or self._search_regex(

View file

@ -89,7 +89,7 @@ class VineIE(InfoExtractor):
username = data.get('username') username = data.get('username')
alt_title = format_field(username, template='Vine by %s') alt_title = format_field(username, None, 'Vine by %s')
return { return {
'id': video_id, 'id': video_id,

View file

@ -91,7 +91,7 @@ def _extract_moment(item, fatal=True):
uploader = try_get(item, lambda x: x['owner']['name'], compat_str) uploader = try_get(item, lambda x: x['owner']['name'], compat_str)
uploader_id = try_get(item, lambda x: x['owner']['userId']) uploader_id = try_get(item, lambda x: x['owner']['userId'])
uploader_url = format_field(uploader, template='https://www.younow.com/%s') uploader_url = format_field(uploader, None, 'https://www.younow.com/%s')
entry = { entry = {
'extractor_key': 'YouNowMoment', 'extractor_key': 'YouNowMoment',

View file

@ -3555,7 +3555,7 @@ class YoutubeIE(YoutubeBaseInfoExtractor):
'uploader_id': self._search_regex(r'/(?:channel|user)/([^/?&#]+)', owner_profile_url, 'uploader id') if owner_profile_url else None, 'uploader_id': self._search_regex(r'/(?:channel|user)/([^/?&#]+)', owner_profile_url, 'uploader id') if owner_profile_url else None,
'uploader_url': owner_profile_url, 'uploader_url': owner_profile_url,
'channel_id': channel_id, 'channel_id': channel_id,
'channel_url': format_field(channel_id, template='https://www.youtube.com/channel/%s'), 'channel_url': format_field(channel_id, None, 'https://www.youtube.com/channel/%s'),
'duration': duration, 'duration': duration,
'view_count': int_or_none( 'view_count': int_or_none(
get_first((video_details, microformats), (..., 'viewCount')) get_first((video_details, microformats), (..., 'viewCount'))
@ -3625,7 +3625,7 @@ class YoutubeIE(YoutubeBaseInfoExtractor):
if 'translated_subs' in self._configuration_arg('skip'): if 'translated_subs' in self._configuration_arg('skip'):
continue continue
trans_code += f'-{lang_code}' trans_code += f'-{lang_code}'
trans_name += format_field(lang_name, template=' from %s') trans_name += format_field(lang_name, None, ' from %s')
# Add an "-orig" label to the original language so that it can be distinguished. # Add an "-orig" label to the original language so that it can be distinguished.
# The subs are returned without "-orig" as well for compatibility # The subs are returned without "-orig" as well for compatibility
if lang_code == f'a-{orig_trans_code}': if lang_code == f'a-{orig_trans_code}':

View file

@ -58,7 +58,7 @@ class ZhihuIE(InfoExtractor):
'uploader': author.get('name'), 'uploader': author.get('name'),
'timestamp': int_or_none(zvideo.get('published_at')), 'timestamp': int_or_none(zvideo.get('published_at')),
'uploader_id': author.get('id'), 'uploader_id': author.get('id'),
'uploader_url': format_field(url_token, template='https://www.zhihu.com/people/%s'), 'uploader_url': format_field(url_token, None, 'https://www.zhihu.com/people/%s'),
'duration': float_or_none(video.get('duration')), 'duration': float_or_none(video.get('duration')),
'view_count': int_or_none(zvideo.get('play_count')), 'view_count': int_or_none(zvideo.get('play_count')),
'like_count': int_or_none(zvideo.get('liked_count')), 'like_count': int_or_none(zvideo.get('liked_count')),

View file

@ -1038,10 +1038,10 @@ class ExtractorError(YoutubeDLError):
self.exc_info = sys.exc_info() # preserve original exception self.exc_info = sys.exc_info() # preserve original exception
super().__init__(''.join(( super().__init__(''.join((
format_field(ie, template='[%s] '), format_field(ie, None, '[%s] '),
format_field(video_id, template='%s: '), format_field(video_id, None, '%s: '),
msg, msg,
format_field(cause, template=' (caused by %r)'), format_field(cause, None, ' (caused by %r)'),
'' if expected else bug_reports_message()))) '' if expected else bug_reports_message())))
def format_traceback(self): def format_traceback(self):