[extractor] Add `write_debug` and `get_param`

This commit is contained in:
pukkandan 2021-05-17 17:53:08 +05:30
parent 681de68e9d
commit a06916d98e
No known key found for this signature in database
GPG Key ID: 0F00D95A001F4698
52 changed files with 130 additions and 127 deletions

View File

@ -1332,6 +1332,7 @@ While these options still work, their use is not recommended since there are oth
--list-formats-as-table --compat-options -list-formats [Default] (Alias: --no-list-formats-old) --list-formats-as-table --compat-options -list-formats [Default] (Alias: --no-list-formats-old)
--sponskrub-args ARGS --ppa "sponskrub:ARGS" --sponskrub-args ARGS --ppa "sponskrub:ARGS"
--test Used by developers for testing extractors. Not intended for the end user --test Used by developers for testing extractors. Not intended for the end user
--youtube-print-sig-code Used for testing youtube signatures
#### Old aliases #### Old aliases
@ -1362,7 +1363,6 @@ These options may no longer work as intended
--no-call-home Default --no-call-home Default
--include-ads No longer supported --include-ads No longer supported
--no-include-ads Default --no-include-ads Default
--youtube-print-sig-code No longer supported
#### Removed #### Removed
These options were deprecated since 2014 and have now been entirely removed These options were deprecated since 2014 and have now been entirely removed

View File

@ -48,7 +48,6 @@ from .utils import (
date_from_str, date_from_str,
DateRange, DateRange,
DEFAULT_OUTTMPL, DEFAULT_OUTTMPL,
OUTTMPL_TYPES,
determine_ext, determine_ext,
determine_protocol, determine_protocol,
DOT_DESKTOP_LINK_TEMPLATE, DOT_DESKTOP_LINK_TEMPLATE,
@ -57,8 +56,8 @@ from .utils import (
DownloadError, DownloadError,
encode_compat_str, encode_compat_str,
encodeFilename, encodeFilename,
error_to_compat_str,
EntryNotInPlaylist, EntryNotInPlaylist,
error_to_compat_str,
ExistingVideoReached, ExistingVideoReached,
expand_path, expand_path,
ExtractorError, ExtractorError,
@ -77,6 +76,7 @@ from .utils import (
MaxDownloadsReached, MaxDownloadsReached,
network_exceptions, network_exceptions,
orderedSet, orderedSet,
OUTTMPL_TYPES,
PagedList, PagedList,
parse_filesize, parse_filesize,
PerRequestProxyHandler, PerRequestProxyHandler,
@ -84,11 +84,12 @@ from .utils import (
PostProcessingError, PostProcessingError,
preferredencoding, preferredencoding,
prepend_extension, prepend_extension,
process_communicate_or_kill,
random_uuidv4, random_uuidv4,
register_socks_protocols, register_socks_protocols,
RejectedVideoReached,
render_table, render_table,
replace_extension, replace_extension,
RejectedVideoReached,
SameFileError, SameFileError,
sanitize_filename, sanitize_filename,
sanitize_path, sanitize_path,
@ -109,7 +110,6 @@ from .utils import (
YoutubeDLCookieProcessor, YoutubeDLCookieProcessor,
YoutubeDLHandler, YoutubeDLHandler,
YoutubeDLRedirectHandler, YoutubeDLRedirectHandler,
process_communicate_or_kill,
) )
from .cache import Cache from .cache import Cache
from .extractor import ( from .extractor import (

View File

@ -1414,7 +1414,7 @@ class AdobePassIE(InfoExtractor):
authn_token = None authn_token = None
if not authn_token: if not authn_token:
# TODO add support for other TV Providers # TODO add support for other TV Providers
mso_id = self._downloader.params.get('ap_mso') mso_id = self.get_param('ap_mso')
if not mso_id: if not mso_id:
raise_mvpd_required() raise_mvpd_required()
username, password = self._get_login_info('ap_username', 'ap_password', mso_id) username, password = self._get_login_info('ap_username', 'ap_password', mso_id)

View File

@ -323,7 +323,7 @@ class AfreecaTVIE(InfoExtractor):
'url': file_url, 'url': file_url,
'format_id': 'http', 'format_id': 'http',
}] }]
if not formats and not self._downloader.params.get('ignore_no_formats'): if not formats and not self.get_param('ignore_no_formats'):
continue continue
self._sort_formats(formats) self._sort_formats(formats)
file_info = common_entry.copy() file_info = common_entry.copy()

View File

@ -1271,7 +1271,7 @@ class BBCIE(BBCCoUkIE):
entries = [] entries = []
for num, media_meta in enumerate(medias, start=1): for num, media_meta in enumerate(medias, start=1):
formats, subtitles = self._extract_from_media_meta(media_meta, playlist_id) formats, subtitles = self._extract_from_media_meta(media_meta, playlist_id)
if not formats and not self._downloader.params.get('ignore_no_formats'): if not formats and not self.get_param('ignore_no_formats'):
continue continue
self._sort_formats(formats) self._sort_formats(formats)

View File

@ -153,7 +153,7 @@ class BiliBiliIE(InfoExtractor):
# Bilibili anthologies are similar to playlists but all videos share the same video ID as the anthology itself. # Bilibili anthologies are similar to playlists but all videos share the same video ID as the anthology itself.
# If the video has no page argument, check to see if it's an anthology # If the video has no page argument, check to see if it's an anthology
if page_id is None: if page_id is None:
if not self._downloader.params.get('noplaylist'): if not self.get_param('noplaylist'):
r = self._extract_anthology_entries(bv_id, video_id, webpage) r = self._extract_anthology_entries(bv_id, video_id, webpage)
if r is not None: if r is not None:
self.to_screen('Downloading anthology %s - add --no-playlist to just download video' % video_id) self.to_screen('Downloading anthology %s - add --no-playlist to just download video' % video_id)
@ -299,7 +299,7 @@ class BiliBiliIE(InfoExtractor):
'tags': tags, 'tags': tags,
'raw_tags': raw_tags, 'raw_tags': raw_tags,
} }
if self._downloader.params.get('getcomments', False): if self.get_param('getcomments', False):
def get_comments(): def get_comments():
comments = self._get_all_comment_pages(video_id) comments = self._get_all_comment_pages(video_id)
return { return {

View File

@ -478,7 +478,7 @@ class BrightcoveNewIE(AdobePassIE):
container = source.get('container') container = source.get('container')
ext = mimetype2ext(source.get('type')) ext = mimetype2ext(source.get('type'))
src = source.get('src') src = source.get('src')
skip_unplayable = not self._downloader.params.get('allow_unplayable_formats') skip_unplayable = not self.get_param('allow_unplayable_formats')
# https://support.brightcove.com/playback-api-video-fields-reference#key_systems_object # https://support.brightcove.com/playback-api-video-fields-reference#key_systems_object
if skip_unplayable and (container == 'WVM' or source.get('key_systems')): if skip_unplayable and (container == 'WVM' or source.get('key_systems')):
num_drm_sources += 1 num_drm_sources += 1
@ -547,7 +547,7 @@ class BrightcoveNewIE(AdobePassIE):
error = errors[0] error = errors[0]
self.raise_no_formats( self.raise_no_formats(
error.get('message') or error.get('error_subcode') or error['error_code'], expected=True) error.get('message') or error.get('error_subcode') or error['error_code'], expected=True)
elif (not self._downloader.params.get('allow_unplayable_formats') elif (not self.get_param('allow_unplayable_formats')
and sources and num_drm_sources == len(sources)): and sources and num_drm_sources == len(sources)):
raise ExtractorError('This video is DRM protected.', expected=True) raise ExtractorError('This video is DRM protected.', expected=True)

View File

@ -147,7 +147,7 @@ class CeskaTelevizeIE(InfoExtractor):
is_live = item.get('type') == 'LIVE' is_live = item.get('type') == 'LIVE'
formats = [] formats = []
for format_id, stream_url in item.get('streamUrls', {}).items(): for format_id, stream_url in item.get('streamUrls', {}).items():
if (not self._downloader.params.get('allow_unplayable_formats') if (not self.get_param('allow_unplayable_formats')
and 'drmOnly=true' in stream_url): and 'drmOnly=true' in stream_url):
continue continue
if 'playerType=flash' in stream_url: if 'playerType=flash' in stream_url:

View File

@ -491,7 +491,7 @@ class InfoExtractor(object):
if not self._x_forwarded_for_ip: if not self._x_forwarded_for_ip:
# Geo bypass mechanism is explicitly disabled by user # Geo bypass mechanism is explicitly disabled by user
if not self._downloader.params.get('geo_bypass', True): if not self.get_param('geo_bypass', True):
return return
if not geo_bypass_context: if not geo_bypass_context:
@ -513,7 +513,7 @@ class InfoExtractor(object):
# Explicit IP block specified by user, use it right away # Explicit IP block specified by user, use it right away
# regardless of whether extractor is geo bypassable or not # regardless of whether extractor is geo bypassable or not
ip_block = self._downloader.params.get('geo_bypass_ip_block', None) ip_block = self.get_param('geo_bypass_ip_block', None)
# Otherwise use random IP block from geo bypass context but only # Otherwise use random IP block from geo bypass context but only
# if extractor is known as geo bypassable # if extractor is known as geo bypassable
@ -532,7 +532,7 @@ class InfoExtractor(object):
# Explicit country code specified by user, use it right away # Explicit country code specified by user, use it right away
# regardless of whether extractor is geo bypassable or not # regardless of whether extractor is geo bypassable or not
country = self._downloader.params.get('geo_bypass_country', None) country = self.get_param('geo_bypass_country', None)
# Otherwise use random country code from geo bypass context but # Otherwise use random country code from geo bypass context but
# only if extractor is known as geo bypassable # only if extractor is known as geo bypassable
@ -552,12 +552,13 @@ class InfoExtractor(object):
for _ in range(2): for _ in range(2):
try: try:
self.initialize() self.initialize()
self.write_debug('Extracting URL: %s' % url)
ie_result = self._real_extract(url) ie_result = self._real_extract(url)
if self._x_forwarded_for_ip: if self._x_forwarded_for_ip:
ie_result['__x_forwarded_for_ip'] = self._x_forwarded_for_ip ie_result['__x_forwarded_for_ip'] = self._x_forwarded_for_ip
subtitles = ie_result.get('subtitles') subtitles = ie_result.get('subtitles')
if (subtitles and 'live_chat' in subtitles if (subtitles and 'live_chat' in subtitles
and 'no-live-chat' in self._downloader.params.get('compat_opts', [])): and 'no-live-chat' in self.get_param('compat_opts', [])):
del subtitles['live_chat'] del subtitles['live_chat']
return ie_result return ie_result
except GeoRestrictedError as e: except GeoRestrictedError as e:
@ -572,9 +573,9 @@ class InfoExtractor(object):
raise ExtractorError('An extractor error has occurred.', cause=e) raise ExtractorError('An extractor error has occurred.', cause=e)
def __maybe_fake_ip_and_retry(self, countries): def __maybe_fake_ip_and_retry(self, countries):
if (not self._downloader.params.get('geo_bypass_country', None) if (not self.get_param('geo_bypass_country', None)
and self._GEO_BYPASS and self._GEO_BYPASS
and self._downloader.params.get('geo_bypass', True) and self.get_param('geo_bypass', True)
and not self._x_forwarded_for_ip and not self._x_forwarded_for_ip
and countries): and countries):
country_code = random.choice(countries) country_code = random.choice(countries)
@ -628,7 +629,7 @@ class InfoExtractor(object):
See _download_webpage docstring for arguments specification. See _download_webpage docstring for arguments specification.
""" """
if not self._downloader._first_webpage_request: if not self._downloader._first_webpage_request:
sleep_interval = float_or_none(self._downloader.params.get('sleep_interval_requests')) or 0 sleep_interval = float_or_none(self.get_param('sleep_interval_requests')) or 0
if sleep_interval > 0: if sleep_interval > 0:
self.to_screen('Sleeping %s seconds ...' % sleep_interval) self.to_screen('Sleeping %s seconds ...' % sleep_interval)
time.sleep(sleep_interval) time.sleep(sleep_interval)
@ -753,11 +754,11 @@ class InfoExtractor(object):
webpage_bytes = prefix + webpage_bytes webpage_bytes = prefix + webpage_bytes
if not encoding: if not encoding:
encoding = self._guess_encoding_from_content(content_type, webpage_bytes) encoding = self._guess_encoding_from_content(content_type, webpage_bytes)
if self._downloader.params.get('dump_intermediate_pages', False): if self.get_param('dump_intermediate_pages', False):
self.to_screen('Dumping request to ' + urlh.geturl()) self.to_screen('Dumping request to ' + urlh.geturl())
dump = base64.b64encode(webpage_bytes).decode('ascii') dump = base64.b64encode(webpage_bytes).decode('ascii')
self._downloader.to_screen(dump) self._downloader.to_screen(dump)
if self._downloader.params.get('write_pages', False): if self.get_param('write_pages', False):
basen = '%s_%s' % (video_id, urlh.geturl()) basen = '%s_%s' % (video_id, urlh.geturl())
if len(basen) > 240: if len(basen) > 240:
h = '___' + hashlib.md5(basen.encode('utf-8')).hexdigest() h = '___' + hashlib.md5(basen.encode('utf-8')).hexdigest()
@ -941,14 +942,22 @@ class InfoExtractor(object):
else: else:
self.report_warning(errmsg + str(ve)) self.report_warning(errmsg + str(ve))
def report_warning(self, msg, video_id=None): def report_warning(self, msg, video_id=None, *args, **kwargs):
idstr = '' if video_id is None else '%s: ' % video_id idstr = '' if video_id is None else '%s: ' % video_id
self._downloader.report_warning( self._downloader.report_warning(
'[%s] %s%s' % (self.IE_NAME, idstr, msg)) '[%s] %s%s' % (self.IE_NAME, idstr, msg), *args, **kwargs)
def to_screen(self, msg): def to_screen(self, msg, *args, **kwargs):
"""Print msg to screen, prefixing it with '[ie_name]'""" """Print msg to screen, prefixing it with '[ie_name]'"""
self._downloader.to_screen('[%s] %s' % (self.IE_NAME, msg)) self._downloader.to_screen('[%s] %s' % (self.IE_NAME, msg), *args, **kwargs)
def write_debug(self, msg, *args, **kwargs):
self._downloader.write_debug('[%s] %s' % (self.IE_NAME, msg), *args, **kwargs)
def get_param(self, name, default=None, *args, **kwargs):
if self._downloader:
return self._downloader.params.get(name, default, *args, **kwargs)
return default
def report_extraction(self, id_or_name): def report_extraction(self, id_or_name):
"""Report information extraction.""" """Report information extraction."""
@ -968,7 +977,7 @@ class InfoExtractor(object):
def raise_login_required( def raise_login_required(
self, msg='This video is only available for registered users', metadata_available=False): self, msg='This video is only available for registered users', metadata_available=False):
if metadata_available and self._downloader.params.get('ignore_no_formats_error'): if metadata_available and self.get_param('ignore_no_formats_error'):
self.report_warning(msg) self.report_warning(msg)
raise ExtractorError( raise ExtractorError(
'%s. Use --cookies, --username and --password or --netrc to provide account credentials' % msg, '%s. Use --cookies, --username and --password or --netrc to provide account credentials' % msg,
@ -977,13 +986,13 @@ class InfoExtractor(object):
def raise_geo_restricted( def raise_geo_restricted(
self, msg='This video is not available from your location due to geo restriction', self, msg='This video is not available from your location due to geo restriction',
countries=None, metadata_available=False): countries=None, metadata_available=False):
if metadata_available and self._downloader.params.get('ignore_no_formats_error'): if metadata_available and self.get_param('ignore_no_formats_error'):
self.report_warning(msg) self.report_warning(msg)
else: else:
raise GeoRestrictedError(msg, countries=countries) raise GeoRestrictedError(msg, countries=countries)
def raise_no_formats(self, msg, expected=False, video_id=None): def raise_no_formats(self, msg, expected=False, video_id=None):
if expected and self._downloader.params.get('ignore_no_formats_error'): if expected and self.get_param('ignore_no_formats_error'):
self.report_warning(msg, video_id) self.report_warning(msg, video_id)
else: else:
raise ExtractorError(msg, expected=expected, video_id=video_id) raise ExtractorError(msg, expected=expected, video_id=video_id)
@ -1038,7 +1047,7 @@ class InfoExtractor(object):
if mobj: if mobj:
break break
if not self._downloader.params.get('no_color') and compat_os_name != 'nt' and sys.stderr.isatty(): if not self.get_param('no_color') and compat_os_name != 'nt' and sys.stderr.isatty():
_name = '\033[0;34m%s\033[0m' % name _name = '\033[0;34m%s\033[0m' % name
else: else:
_name = name _name = name
@ -1072,7 +1081,7 @@ class InfoExtractor(object):
password = None password = None
netrc_machine = netrc_machine or self._NETRC_MACHINE netrc_machine = netrc_machine or self._NETRC_MACHINE
if self._downloader.params.get('usenetrc', False): if self.get_param('usenetrc', False):
try: try:
info = netrc.netrc().authenticators(netrc_machine) info = netrc.netrc().authenticators(netrc_machine)
if info is not None: if info is not None:
@ -1096,15 +1105,11 @@ class InfoExtractor(object):
value. value.
If there's no info available, return (None, None) If there's no info available, return (None, None)
""" """
if self._downloader is None:
return (None, None)
downloader_params = self._downloader.params
# Attempt to use provided username and password or .netrc data # Attempt to use provided username and password or .netrc data
if downloader_params.get(username_option) is not None: username = self.get_param(username_option)
username = downloader_params[username_option] if username is not None:
password = downloader_params[password_option] password = self.get_param(password_option)
else: else:
username, password = self._get_netrc_login_info(netrc_machine) username, password = self._get_netrc_login_info(netrc_machine)
@ -1117,12 +1122,10 @@ class InfoExtractor(object):
currently just uses the command line option currently just uses the command line option
If there's no info available, return None If there's no info available, return None
""" """
if self._downloader is None:
return None
downloader_params = self._downloader.params
if downloader_params.get('twofactor') is not None: tfa = self.get_param('twofactor')
return downloader_params['twofactor'] if tfa is not None:
return tfa
return compat_getpass('Type %s and press [Return]: ' % note) return compat_getpass('Type %s and press [Return]: ' % note)
@ -1683,12 +1686,12 @@ class InfoExtractor(object):
def _sort_formats(self, formats, field_preference=[]): def _sort_formats(self, formats, field_preference=[]):
if not formats: if not formats:
if self._downloader.params.get('ignore_no_formats_error'): if self.get_param('ignore_no_formats_error'):
return return
raise ExtractorError('No video formats found') raise ExtractorError('No video formats found')
format_sort = self.FormatSort() # params and to_screen are taken from the downloader format_sort = self.FormatSort() # params and to_screen are taken from the downloader
format_sort.evaluate_params(self._downloader.params, field_preference) format_sort.evaluate_params(self._downloader.params, field_preference)
if self._downloader.params.get('verbose', False): if self.get_param('verbose', False):
format_sort.print_verbose_info(self._downloader.write_debug) format_sort.print_verbose_info(self._downloader.write_debug)
formats.sort(key=lambda f: format_sort.calculate_preference(f)) formats.sort(key=lambda f: format_sort.calculate_preference(f))
@ -1728,7 +1731,7 @@ class InfoExtractor(object):
""" Either "http:" or "https:", depending on the user's preferences """ """ Either "http:" or "https:", depending on the user's preferences """
return ( return (
'http:' 'http:'
if self._downloader.params.get('prefer_insecure', False) if self.get_param('prefer_insecure', False)
else 'https:') else 'https:')
def _proto_relative_url(self, url, scheme=None): def _proto_relative_url(self, url, scheme=None):
@ -1922,7 +1925,7 @@ class InfoExtractor(object):
if '#EXT-X-FAXS-CM:' in m3u8_doc: # Adobe Flash Access if '#EXT-X-FAXS-CM:' in m3u8_doc: # Adobe Flash Access
return [], {} return [], {}
if (not self._downloader.params.get('allow_unplayable_formats') if (not self.get_param('allow_unplayable_formats')
and re.search(r'#EXT-X-SESSION-KEY:.*?URI="skd://', m3u8_doc)): # Apple FairPlay and re.search(r'#EXT-X-SESSION-KEY:.*?URI="skd://', m3u8_doc)): # Apple FairPlay
return [], {} return [], {}
@ -1935,7 +1938,7 @@ class InfoExtractor(object):
if re.match(r'^https?://', u) if re.match(r'^https?://', u)
else compat_urlparse.urljoin(m3u8_url, u)) else compat_urlparse.urljoin(m3u8_url, u))
split_discontinuity = self._downloader.params.get('hls_split_discontinuity', False) split_discontinuity = self.get_param('hls_split_discontinuity', False)
# References: # References:
# 1. https://tools.ietf.org/html/draft-pantos-http-live-streaming-21 # 1. https://tools.ietf.org/html/draft-pantos-http-live-streaming-21
@ -2478,7 +2481,7 @@ class InfoExtractor(object):
http://standards.iso.org/ittf/PubliclyAvailableStandards/c065274_ISO_IEC_23009-1_2014.zip http://standards.iso.org/ittf/PubliclyAvailableStandards/c065274_ISO_IEC_23009-1_2014.zip
2. https://en.wikipedia.org/wiki/Dynamic_Adaptive_Streaming_over_HTTP 2. https://en.wikipedia.org/wiki/Dynamic_Adaptive_Streaming_over_HTTP
""" """
if not self._downloader.params.get('dynamic_mpd', True): if not self.get_param('dynamic_mpd', True):
if mpd_doc.get('type') == 'dynamic': if mpd_doc.get('type') == 'dynamic':
return [], {} return [], {}
@ -2548,7 +2551,7 @@ class InfoExtractor(object):
extract_Initialization(segment_template) extract_Initialization(segment_template)
return ms_info return ms_info
skip_unplayable = not self._downloader.params.get('allow_unplayable_formats') skip_unplayable = not self.get_param('allow_unplayable_formats')
mpd_duration = parse_duration(mpd_doc.get('mediaPresentationDuration')) mpd_duration = parse_duration(mpd_doc.get('mediaPresentationDuration'))
formats = [] formats = []
@ -2797,7 +2800,7 @@ class InfoExtractor(object):
""" """
if ism_doc.get('IsLive') == 'TRUE': if ism_doc.get('IsLive') == 'TRUE':
return [], {} return [], {}
if (not self._downloader.params.get('allow_unplayable_formats') if (not self.get_param('allow_unplayable_formats')
and ism_doc.find('Protection') is not None): and ism_doc.find('Protection') is not None):
return [], {} return [], {}
@ -3402,8 +3405,8 @@ class InfoExtractor(object):
return not any_restricted return not any_restricted
def extract_subtitles(self, *args, **kwargs): def extract_subtitles(self, *args, **kwargs):
if (self._downloader.params.get('writesubtitles', False) if (self.get_param('writesubtitles', False)
or self._downloader.params.get('listsubtitles')): or self.get_param('listsubtitles')):
return self._get_subtitles(*args, **kwargs) return self._get_subtitles(*args, **kwargs)
return {} return {}
@ -3438,8 +3441,8 @@ class InfoExtractor(object):
return target return target
def extract_automatic_captions(self, *args, **kwargs): def extract_automatic_captions(self, *args, **kwargs):
if (self._downloader.params.get('writeautomaticsub', False) if (self.get_param('writeautomaticsub', False)
or self._downloader.params.get('listsubtitles')): or self.get_param('listsubtitles')):
return self._get_automatic_captions(*args, **kwargs) return self._get_automatic_captions(*args, **kwargs)
return {} return {}
@ -3447,9 +3450,9 @@ class InfoExtractor(object):
raise NotImplementedError('This method must be implemented by subclasses') raise NotImplementedError('This method must be implemented by subclasses')
def mark_watched(self, *args, **kwargs): def mark_watched(self, *args, **kwargs):
if (self._downloader.params.get('mark_watched', False) if (self.get_param('mark_watched', False)
and (self._get_login_info()[0] is not None and (self._get_login_info()[0] is not None
or self._downloader.params.get('cookiefile') is not None)): or self.get_param('cookiefile') is not None)):
self._mark_watched(*args, **kwargs) self._mark_watched(*args, **kwargs)
def _mark_watched(self, *args, **kwargs): def _mark_watched(self, *args, **kwargs):
@ -3457,7 +3460,7 @@ class InfoExtractor(object):
def geo_verification_headers(self): def geo_verification_headers(self):
headers = {} headers = {}
geo_verification_proxy = self._downloader.params.get('geo_verification_proxy') geo_verification_proxy = self.get_param('geo_verification_proxy')
if geo_verification_proxy: if geo_verification_proxy:
headers['Ytdl-request-proxy'] = geo_verification_proxy headers['Ytdl-request-proxy'] = geo_verification_proxy
return headers return headers

View File

@ -26,7 +26,7 @@ class CommonMistakesIE(InfoExtractor):
'That doesn\'t make any sense. ' 'That doesn\'t make any sense. '
'Simply remove the parameter in your command or configuration.' 'Simply remove the parameter in your command or configuration.'
) % url ) % url
if not self._downloader.params.get('verbose'): if not self.get_param('verbose'):
msg += ' Add -v to the command line to see what arguments and configuration yt-dlp has' msg += ' Add -v to the command line to see what arguments and configuration yt-dlp has'
raise ExtractorError(msg, expected=True) raise ExtractorError(msg, expected=True)

View File

@ -81,7 +81,7 @@ class CrackleIE(InfoExtractor):
def _real_extract(self, url): def _real_extract(self, url):
video_id = self._match_id(url) video_id = self._match_id(url)
geo_bypass_country = self._downloader.params.get('geo_bypass_country', None) geo_bypass_country = self.get_param('geo_bypass_country', None)
countries = orderedSet((geo_bypass_country, 'US', 'AU', 'CA', 'AS', 'FM', 'GU', 'MP', 'PR', 'PW', 'MH', 'VI', '')) countries = orderedSet((geo_bypass_country, 'US', 'AU', 'CA', 'AS', 'FM', 'GU', 'MP', 'PR', 'PW', 'MH', 'VI', ''))
num_countries, num = len(countries) - 1, 0 num_countries, num = len(countries) - 1, 0
@ -128,8 +128,8 @@ class CrackleIE(InfoExtractor):
if isinstance(media.get('MediaURLs'), list): if isinstance(media.get('MediaURLs'), list):
break break
ignore_no_formats = self._downloader.params.get('ignore_no_formats_error') ignore_no_formats = self.get_param('ignore_no_formats_error')
allow_unplayable_formats = self._downloader.params.get('allow_unplayable_formats') allow_unplayable_formats = self.get_param('allow_unplayable_formats')
if not media or (not media.get('MediaURLs') and not ignore_no_formats): if not media or (not media.get('MediaURLs') and not ignore_no_formats):
raise ExtractorError( raise ExtractorError(

View File

@ -42,7 +42,7 @@ class DailymotionBaseInfoExtractor(InfoExtractor):
def _real_initialize(self): def _real_initialize(self):
cookies = self._get_dailymotion_cookies() cookies = self._get_dailymotion_cookies()
ff = self._get_cookie_value(cookies, 'ff') ff = self._get_cookie_value(cookies, 'ff')
self._FAMILY_FILTER = ff == 'on' if ff else age_restricted(18, self._downloader.params.get('age_limit')) self._FAMILY_FILTER = ff == 'on' if ff else age_restricted(18, self.get_param('age_limit'))
self._set_dailymotion_cookie('ff', 'on' if self._FAMILY_FILTER else 'off') self._set_dailymotion_cookie('ff', 'on' if self._FAMILY_FILTER else 'off')
def _call_api(self, object_type, xid, object_fields, note, filter_extra=None): def _call_api(self, object_type, xid, object_fields, note, filter_extra=None):
@ -207,14 +207,14 @@ class DailymotionIE(DailymotionBaseInfoExtractor):
video_id, playlist_id = re.match(self._VALID_URL, url).groups() video_id, playlist_id = re.match(self._VALID_URL, url).groups()
if playlist_id: if playlist_id:
if not self._downloader.params.get('noplaylist'): if not self.get_param('noplaylist'):
self.to_screen('Downloading playlist %s - add --no-playlist to just download video' % playlist_id) self.to_screen('Downloading playlist %s - add --no-playlist to just download video' % playlist_id)
return self.url_result( return self.url_result(
'http://www.dailymotion.com/playlist/' + playlist_id, 'http://www.dailymotion.com/playlist/' + playlist_id,
'DailymotionPlaylist', playlist_id) 'DailymotionPlaylist', playlist_id)
self.to_screen('Downloading just video %s because of --no-playlist' % video_id) self.to_screen('Downloading just video %s because of --no-playlist' % video_id)
password = self._downloader.params.get('videopassword') password = self.get_param('videopassword')
media = self._call_api( media = self._call_api(
'media', video_id, '''... on Video { 'media', video_id, '''... on Video {
%s %s
@ -232,7 +232,7 @@ class DailymotionIE(DailymotionBaseInfoExtractor):
audienceCount audienceCount
isOnAir isOnAir
}''' % (self._COMMON_MEDIA_FIELDS, self._COMMON_MEDIA_FIELDS), 'Downloading media JSON metadata', }''' % (self._COMMON_MEDIA_FIELDS, self._COMMON_MEDIA_FIELDS), 'Downloading media JSON metadata',
'password: "%s"' % self._downloader.params.get('videopassword') if password else None) 'password: "%s"' % self.get_param('videopassword') if password else None)
xid = media['xid'] xid = media['xid']
metadata = self._download_json( metadata = self._download_json(

View File

@ -158,7 +158,7 @@ class DaumListIE(InfoExtractor):
query_dict = compat_parse_qs(compat_urlparse.urlparse(url).query) query_dict = compat_parse_qs(compat_urlparse.urlparse(url).query)
if 'clipid' in query_dict: if 'clipid' in query_dict:
clip_id = query_dict['clipid'][0] clip_id = query_dict['clipid'][0]
if self._downloader.params.get('noplaylist'): if self.get_param('noplaylist'):
self.to_screen('Downloading just video %s because of --no-playlist' % clip_id) self.to_screen('Downloading just video %s because of --no-playlist' % clip_id)
return self.url_result(DaumClipIE._URL_TEMPLATE % clip_id, 'DaumClip') return self.url_result(DaumClipIE._URL_TEMPLATE % clip_id, 'DaumClip')
else: else:

View File

@ -13,7 +13,7 @@ from ..utils import (
class DeezerBaseInfoExtractor(InfoExtractor): class DeezerBaseInfoExtractor(InfoExtractor):
def get_data(self, url): def get_data(self, url):
if not self._downloader.params.get('test'): if not self.get_param('test'):
self.report_warning('For now, this extractor only supports the 30 second previews. Patches welcome!') self.report_warning('For now, this extractor only supports the 30 second previews. Patches welcome!')
mobj = re.match(self._VALID_URL, url) mobj = re.match(self._VALID_URL, url)

View File

@ -2370,7 +2370,7 @@ class GenericIE(InfoExtractor):
parsed_url = compat_urlparse.urlparse(url) parsed_url = compat_urlparse.urlparse(url)
if not parsed_url.scheme: if not parsed_url.scheme:
default_search = self._downloader.params.get('default_search') default_search = self.get_param('default_search')
if default_search is None: if default_search is None:
default_search = 'fixup_error' default_search = 'fixup_error'
@ -2461,8 +2461,8 @@ class GenericIE(InfoExtractor):
info_dict['subtitles'] = subtitles info_dict['subtitles'] = subtitles
return info_dict return info_dict
if not self._downloader.params.get('test', False) and not is_intentional: if not self.get_param('test', False) and not is_intentional:
force = self._downloader.params.get('force_generic_extractor', False) force = self.get_param('force_generic_extractor', False)
self.report_warning( self.report_warning(
'%s on generic information extractor.' % ('Forcing' if force else 'Falling back')) '%s on generic information extractor.' % ('Forcing' if force else 'Falling back'))

View File

@ -96,7 +96,7 @@ class GloboIE(InfoExtractor):
video = self._download_json( video = self._download_json(
'http://api.globovideos.com/videos/%s/playlist' % video_id, 'http://api.globovideos.com/videos/%s/playlist' % video_id,
video_id)['videos'][0] video_id)['videos'][0]
if not self._downloader.params.get('allow_unplayable_formats') and video.get('encrypted') is True: if not self.get_param('allow_unplayable_formats') and video.get('encrypted') is True:
raise ExtractorError('This video is DRM protected.', expected=True) raise ExtractorError('This video is DRM protected.', expected=True)
title = video['title'] title = video['title']

View File

@ -141,7 +141,7 @@ class HotStarIE(HotStarBaseIE):
title = video_data['title'] title = video_data['title']
if not self._downloader.params.get('allow_unplayable_formats') and video_data.get('drmProtected'): if not self.get_param('allow_unplayable_formats') and video_data.get('drmProtected'):
raise ExtractorError('This video is DRM protected.', expected=True) raise ExtractorError('This video is DRM protected.', expected=True)
headers = {'Referer': url} headers = {'Referer': url}

View File

@ -65,7 +65,7 @@ class ImgGamingBaseIE(InfoExtractor):
domain, media_type, media_id, playlist_id = re.match(self._VALID_URL, url).groups() domain, media_type, media_id, playlist_id = re.match(self._VALID_URL, url).groups()
if playlist_id: if playlist_id:
if self._downloader.params.get('noplaylist'): if self.get_param('noplaylist'):
self.to_screen('Downloading just video %s because of --no-playlist' % media_id) self.to_screen('Downloading just video %s because of --no-playlist' % media_id)
else: else:
self.to_screen('Downloading playlist %s - add --no-playlist to just download video' % playlist_id) self.to_screen('Downloading playlist %s - add --no-playlist to just download video' % playlist_id)

View File

@ -165,7 +165,7 @@ class IviIE(InfoExtractor):
content_format = f.get('content_format') content_format = f.get('content_format')
if not f_url: if not f_url:
continue continue
if (not self._downloader.params.get('allow_unplayable_formats') if (not self.get_param('allow_unplayable_formats')
and ('-MDRM-' in content_format or '-FPS-' in content_format)): and ('-MDRM-' in content_format or '-FPS-' in content_format)):
continue continue
formats.append({ formats.append({

View File

@ -309,7 +309,7 @@ class KalturaIE(InfoExtractor):
if f.get('fileExt') == 'chun': if f.get('fileExt') == 'chun':
continue continue
# DRM-protected video, cannot be decrypted # DRM-protected video, cannot be decrypted
if not self._downloader.params.get('allow_unplayable_formats') and f.get('fileExt') == 'wvm': if not self.get_param('allow_unplayable_formats') and f.get('fileExt') == 'wvm':
continue continue
if not f.get('fileExt'): if not f.get('fileExt'):
# QT indicates QuickTime; some videos have broken fileExt # QT indicates QuickTime; some videos have broken fileExt

View File

@ -98,7 +98,7 @@ class LimelightBaseIE(InfoExtractor):
stream_url = stream.get('url') stream_url = stream.get('url')
if not stream_url or stream_url in urls: if not stream_url or stream_url in urls:
continue continue
if not self._downloader.params.get('allow_unplayable_formats') and stream.get('drmProtected'): if not self.get_param('allow_unplayable_formats') and stream.get('drmProtected'):
continue continue
urls.append(stream_url) urls.append(stream_url)
ext = determine_ext(stream_url) ext = determine_ext(stream_url)
@ -163,7 +163,7 @@ class LimelightBaseIE(InfoExtractor):
if not media_url or media_url in urls: if not media_url or media_url in urls:
continue continue
if (format_id in ('Widevine', 'SmoothStreaming') if (format_id in ('Widevine', 'SmoothStreaming')
and not self._downloader.params.get('allow_unplayable_formats', False)): and not self.get_param('allow_unplayable_formats', False)):
continue continue
urls.append(media_url) urls.append(media_url)
ext = determine_ext(media_url) ext = determine_ext(media_url)

View File

@ -71,7 +71,7 @@ class LiTVIE(InfoExtractor):
video_id = self._match_id(url) video_id = self._match_id(url)
noplaylist = self._downloader.params.get('noplaylist') noplaylist = self.get_param('noplaylist')
noplaylist_prompt = True noplaylist_prompt = True
if 'force_noplaylist' in data: if 'force_noplaylist' in data:
noplaylist = data['force_noplaylist'] noplaylist = data['force_noplaylist']

View File

@ -167,7 +167,7 @@ class NBAWatchIE(NBAWatchBaseIE):
display_id = self._match_id(url) display_id = self._match_id(url)
collection_id = compat_parse_qs(compat_urllib_parse_urlparse(url).query).get('collection', [None])[0] collection_id = compat_parse_qs(compat_urllib_parse_urlparse(url).query).get('collection', [None])[0]
if collection_id: if collection_id:
if self._downloader.params.get('noplaylist'): if self.get_param('noplaylist'):
self.to_screen('Downloading just video %s because of --no-playlist' % display_id) self.to_screen('Downloading just video %s because of --no-playlist' % display_id)
else: else:
self.to_screen('Downloading playlist %s - add --no-playlist to just download video' % collection_id) self.to_screen('Downloading playlist %s - add --no-playlist to just download video' % collection_id)

View File

@ -405,7 +405,7 @@ class NetEaseMusicProgramIE(NetEaseMusicBaseIE):
name = info['name'] name = info['name']
description = info['description'] description = info['description']
if not info['songs'] or self._downloader.params.get('noplaylist'): if not info['songs'] or self.get_param('noplaylist'):
if info['songs']: if info['songs']:
self.to_screen( self.to_screen(
'Downloading just the main audio %s because of --no-playlist' 'Downloading just the main audio %s because of --no-playlist'

View File

@ -34,7 +34,7 @@ class NineCNineMediaIE(InfoExtractor):
'$include': '[HasClosedCaptions]', '$include': '[HasClosedCaptions]',
}) })
if (not self._downloader.params.get('allow_unplayable_formats') if (not self.get_param('allow_unplayable_formats')
and try_get(content_package, lambda x: x['Constraints']['Security']['Type'])): and try_get(content_package, lambda x: x['Constraints']['Security']['Type'])):
raise ExtractorError('This video is DRM protected.', expected=True) raise ExtractorError('This video is DRM protected.', expected=True)

View File

@ -66,7 +66,7 @@ class NineNowIE(InfoExtractor):
video_data = common_data['video'] video_data = common_data['video']
if not self._downloader.params.get('allow_unplayable_formats') and video_data.get('drm'): if not self.get_param('allow_unplayable_formats') and video_data.get('drm'):
raise ExtractorError('This video is DRM protected.', expected=True) raise ExtractorError('This video is DRM protected.', expected=True)
brightcove_id = video_data.get('brightcoveId') or 'ref:' + video_data['referenceId'] brightcove_id = video_data.get('brightcoveId') or 'ref:' + video_data['referenceId']

View File

@ -246,7 +246,7 @@ class NPOIE(NPOBaseIE):
}) })
if not formats: if not formats:
if not self._downloader.params.get('allow_unplayable_formats') and drm: if not self.get_param('allow_unplayable_formats') and drm:
self.raise_no_formats('This video is DRM protected.', expected=True) self.raise_no_formats('This video is DRM protected.', expected=True)
return return

View File

@ -182,7 +182,7 @@ class OnetChannelIE(OnetBaseIE):
video_id = remove_start(current_clip_info['ckmId'], 'mvp:') video_id = remove_start(current_clip_info['ckmId'], 'mvp:')
video_name = url_basename(current_clip_info['url']) video_name = url_basename(current_clip_info['url'])
if self._downloader.params.get('noplaylist'): if self.get_param('noplaylist'):
self.to_screen( self.to_screen(
'Downloading just video %s because of --no-playlist' % video_name) 'Downloading just video %s because of --no-playlist' % video_name)
return self._extract_from_id(video_id, webpage) return self._extract_from_id(video_id, webpage)

View File

@ -79,7 +79,7 @@ class PhilharmonieDeParisIE(InfoExtractor):
formats.extend(self._extract_m3u8_formats( formats.extend(self._extract_m3u8_formats(
m3u8_url, video_id, 'mp4', entry_protocol='m3u8_native', m3u8_url, video_id, 'mp4', entry_protocol='m3u8_native',
m3u8_id='hls', fatal=False)) m3u8_id='hls', fatal=False))
if not formats and not self._downloader.params.get('ignore_no_formats'): if not formats and not self.get_param('ignore_no_formats'):
return return
self._sort_formats(formats) self._sort_formats(formats)
return { return {

View File

@ -337,11 +337,11 @@ query viewClip {
# In order to minimize the number of calls to ViewClip API and reduce # In order to minimize the number of calls to ViewClip API and reduce
# the probability of being throttled or banned by Pluralsight we will request # the probability of being throttled or banned by Pluralsight we will request
# only single format until formats listing was explicitly requested. # only single format until formats listing was explicitly requested.
if self._downloader.params.get('listformats', False): if self.get_param('listformats', False):
allowed_qualities = ALLOWED_QUALITIES allowed_qualities = ALLOWED_QUALITIES
else: else:
def guess_allowed_qualities(): def guess_allowed_qualities():
req_format = self._downloader.params.get('format') or 'best' req_format = self.get_param('format') or 'best'
req_format_split = req_format.split('-', 1) req_format_split = req_format.split('-', 1)
if len(req_format_split) > 1: if len(req_format_split) > 1:
req_ext, req_quality = req_format_split req_ext, req_quality = req_format_split
@ -349,7 +349,7 @@ query viewClip {
for allowed_quality in ALLOWED_QUALITIES: for allowed_quality in ALLOWED_QUALITIES:
if req_ext == allowed_quality.ext and req_quality in allowed_quality.qualities: if req_ext == allowed_quality.ext and req_quality in allowed_quality.qualities:
return (AllowedQuality(req_ext, (req_quality, )), ) return (AllowedQuality(req_ext, (req_quality, )), )
req_ext = 'webm' if self._downloader.params.get('prefer_free_formats') else 'mp4' req_ext = 'webm' if self.get_param('prefer_free_formats') else 'mp4'
return (AllowedQuality(req_ext, (best_quality, )), ) return (AllowedQuality(req_ext, (best_quality, )), )
allowed_qualities = guess_allowed_qualities() allowed_qualities = guess_allowed_qualities()

View File

@ -109,7 +109,7 @@ class PlutoTVIE(InfoExtractor):
if ad_free_formats: if ad_free_formats:
formats, subtitles = ad_free_formats, ad_free_subtitles formats, subtitles = ad_free_formats, ad_free_subtitles
else: else:
self._downloader.report_warning('Unable to find ad-free formats') self.report_warning('Unable to find ad-free formats')
return formats, subtitles return formats, subtitles
def _get_video_info(self, video_json, slug, series_name=None): def _get_video_info(self, video_json, slug, series_name=None):

View File

@ -112,7 +112,7 @@ class PokemonWatchIE(InfoExtractor):
} }
# API call can be avoided entirely if we are listing formats # API call can be avoided entirely if we are listing formats
if self._downloader.params.get('listformats', False): if self.get_param('listformats', False):
return info return info
webpage = self._download_webpage(url, video_id) webpage = self._download_webpage(url, video_id)

View File

@ -34,7 +34,7 @@ class ProSiebenSat1BaseIE(InfoExtractor):
'ids': clip_id, 'ids': clip_id,
})[0] })[0]
if not self._downloader.params.get('allow_unplayable_formats') and video.get('is_protected') is True: if not self.get_param('allow_unplayable_formats') and video.get('is_protected') is True:
raise ExtractorError('This video is DRM protected.', expected=True) raise ExtractorError('This video is DRM protected.', expected=True)
formats = [] formats = []

View File

@ -275,7 +275,7 @@ class RaiPlayIE(RaiBaseIE):
media = self._download_json( media = self._download_json(
base + '.json', video_id, 'Downloading video JSON') base + '.json', video_id, 'Downloading video JSON')
if not self._downloader.params.get('allow_unplayable_formats'): if not self.get_param('allow_unplayable_formats'):
if try_get( if try_get(
media, media,
(lambda x: x['rights_management']['rights']['drm'], (lambda x: x['rights_management']['rights']['drm'],

View File

@ -125,7 +125,7 @@ class RTBFIE(InfoExtractor):
}) })
mpd_url = data.get('urlDash') mpd_url = data.get('urlDash')
if mpd_url and (self._downloader.params.get('allow_unplayable_formats') or not data.get('drm')): if mpd_url and (self.get_param('allow_unplayable_formats') or not data.get('drm')):
formats.extend(self._extract_mpd_formats( formats.extend(self._extract_mpd_formats(
mpd_url, media_id, mpd_id='dash', fatal=False)) mpd_url, media_id, mpd_id='dash', fatal=False))

View File

@ -200,7 +200,7 @@ class RuutuIE(InfoExtractor):
return node.get('value') return node.get('value')
if not formats: if not formats:
if (not self._downloader.params.get('allow_unplayable_formats') if (not self.get_param('allow_unplayable_formats')
and xpath_text(video_xml, './Clip/DRM', default=None)): and xpath_text(video_xml, './Clip/DRM', default=None)):
self.raise_no_formats('This video is DRM protected.', expected=True) self.raise_no_formats('This video is DRM protected.', expected=True)
ns_st_cds = pv('ns_st_cds') ns_st_cds = pv('ns_st_cds')

View File

@ -114,7 +114,7 @@ class ShahidIE(ShahidBaseIE):
playout = self._call_api( playout = self._call_api(
'playout/new/url/' + video_id, video_id)['playout'] 'playout/new/url/' + video_id, video_id)['playout']
if not self._downloader.params.get('allow_unplayable_formats') and playout.get('drm'): if not self.get_param('allow_unplayable_formats') and playout.get('drm'):
raise ExtractorError('This video is DRM protected.', expected=True) raise ExtractorError('This video is DRM protected.', expected=True)
formats = self._extract_m3u8_formats(re.sub( formats = self._extract_m3u8_formats(re.sub(

View File

@ -75,7 +75,7 @@ class SonyLIVIE(InfoExtractor):
video_id = self._match_id(url) video_id = self._match_id(url)
content = self._call_api( content = self._call_api(
'1.5', 'IN/CONTENT/VIDEOURL/VOD/' + video_id, video_id) '1.5', 'IN/CONTENT/VIDEOURL/VOD/' + video_id, video_id)
if not self._downloader.params.get('allow_unplayable_formats') and content.get('isEncrypted'): if not self.get_param('allow_unplayable_formats') and content.get('isEncrypted'):
raise ExtractorError('This video is DRM protected.', expected=True) raise ExtractorError('This video is DRM protected.', expected=True)
dash_url = content['videoURL'] dash_url = content['videoURL']
headers = { headers = {

View File

@ -63,7 +63,7 @@ class SportDeutschlandIE(InfoExtractor):
if len(videos) > 1: if len(videos) > 1:
playlist_id = compat_parse_qs(compat_urllib_parse_urlparse(url).query).get('playlistId', [None])[0] playlist_id = compat_parse_qs(compat_urllib_parse_urlparse(url).query).get('playlistId', [None])[0]
if playlist_id: if playlist_id:
if self._downloader.params.get('noplaylist'): if self.get_param('noplaylist'):
videos = [videos[int(playlist_id)]] videos = [videos[int(playlist_id)]]
self.to_screen('Downloading just a single video because of --no-playlist') self.to_screen('Downloading just a single video because of --no-playlist')
else: else:
@ -77,7 +77,7 @@ class SportDeutschlandIE(InfoExtractor):
continue continue
formats = self._extract_m3u8_formats( formats = self._extract_m3u8_formats(
video_url.replace('.smil', '.m3u8'), video_id, 'mp4', fatal=False) video_url.replace('.smil', '.m3u8'), video_id, 'mp4', fatal=False)
if not formats and not self._downloader.params.get('ignore_no_formats'): if not formats and not self.get_param('ignore_no_formats'):
continue continue
yield { yield {
'id': video_id, 'id': video_id,

View File

@ -139,7 +139,7 @@ class SteamIE(InfoExtractor):
'format_id': ext + quality, 'format_id': ext + quality,
'url': video_url, 'url': video_url,
}) })
if not formats and not self._downloader.params.get('ignore_no_formats'): if not formats and not self.get_param('ignore_no_formats'):
continue continue
entry['formats'] = formats entry['formats'] = formats
entries.append(entry) entries.append(entry)

View File

@ -153,7 +153,7 @@ class ToggleIE(InfoExtractor):
}) })
if not formats: if not formats:
for meta in (info.get('Metas') or []): for meta in (info.get('Metas') or []):
if (not self._downloader.params.get('allow_unplayable_formats') if (not self.get_param('allow_unplayable_formats')
and meta.get('Key') == 'Encryption' and meta.get('Value') == '1'): and meta.get('Key') == 'Encryption' and meta.get('Value') == '1'):
self.raise_no_formats( self.raise_no_formats(
'This video is DRM protected.', expected=True) 'This video is DRM protected.', expected=True)

View File

@ -74,7 +74,7 @@ class TouTvIE(RadioCanadaIE):
}) })
# IsDrm does not necessarily mean the video is DRM protected (see # IsDrm does not necessarily mean the video is DRM protected (see
# https://github.com/ytdl-org/youtube-dl/issues/13994). # https://github.com/ytdl-org/youtube-dl/issues/13994).
if not self._downloader.params.get('allow_unplayable_formats') and metadata.get('IsDrm'): if not self.get_param('allow_unplayable_formats') and metadata.get('IsDrm'):
self.report_warning('This video is probably DRM protected.', path) self.report_warning('This video is probably DRM protected.', path)
video_id = metadata['IdMedia'] video_id = metadata['IdMedia']
details = metadata['Details'] details = metadata['Details']

View File

@ -69,7 +69,7 @@ class TVNowBaseIE(InfoExtractor):
if formats: if formats:
break break
else: else:
if not self._downloader.params.get('allow_unplayable_formats') and info.get('isDrm'): if not self.get_param('allow_unplayable_formats') and info.get('isDrm'):
raise ExtractorError( raise ExtractorError(
'Video %s is DRM protected' % video_id, expected=True) 'Video %s is DRM protected' % video_id, expected=True)
if info.get('geoblocked'): if info.get('geoblocked'):

View File

@ -59,7 +59,7 @@ class TwitCastingIE(InfoExtractor):
def _real_extract(self, url): def _real_extract(self, url):
uploader_id, video_id = re.match(self._VALID_URL, url).groups() uploader_id, video_id = re.match(self._VALID_URL, url).groups()
video_password = self._downloader.params.get('videopassword') video_password = self.get_param('videopassword')
request_data = None request_data = None
if video_password: if video_password:
request_data = urlencode_postdata({ request_data = urlencode_postdata({

View File

@ -324,7 +324,7 @@ class VikiIE(VikiBaseIE):
# Despite CODECS metadata in m3u8 all video-only formats # Despite CODECS metadata in m3u8 all video-only formats
# are actually video+audio # are actually video+audio
for f in m3u8_formats: for f in m3u8_formats:
if not self._downloader.params.get('allow_unplayable_formats') and '_drm/index_' in f['url']: if not self.get_param('allow_unplayable_formats') and '_drm/index_' in f['url']:
continue continue
if f.get('acodec') == 'none' and f.get('vcodec') != 'none': if f.get('acodec') == 'none' and f.get('vcodec') != 'none':
f['acodec'] = None f['acodec'] = None

View File

@ -76,7 +76,7 @@ class VimeoBaseInfoExtractor(InfoExtractor):
raise ExtractorError('Unable to log in') raise ExtractorError('Unable to log in')
def _get_video_password(self): def _get_video_password(self):
password = self._downloader.params.get('videopassword') password = self.get_param('videopassword')
if password is None: if password is None:
raise ExtractorError( raise ExtractorError(
'This video is protected by a password, use the --video-password option', 'This video is protected by a password, use the --video-password option',
@ -603,7 +603,7 @@ class VimeoIE(VimeoBaseInfoExtractor):
album_id, headers={'Authorization': 'jwt ' + jwt}, album_id, headers={'Authorization': 'jwt ' + jwt},
query={'fields': 'description,name,privacy'}) query={'fields': 'description,name,privacy'})
if try_get(album, lambda x: x['privacy']['view']) == 'password': if try_get(album, lambda x: x['privacy']['view']) == 'password':
password = self._downloader.params.get('videopassword') password = self.get_param('videopassword')
if not password: if not password:
raise ExtractorError( raise ExtractorError(
'This album is protected by a password, use the --video-password option', 'This album is protected by a password, use the --video-password option',
@ -1058,7 +1058,7 @@ class VimeoAlbumIE(VimeoBaseInfoExtractor):
query={'fields': 'description,name,privacy'}) query={'fields': 'description,name,privacy'})
hashed_pass = None hashed_pass = None
if try_get(album, lambda x: x['privacy']['view']) == 'password': if try_get(album, lambda x: x['privacy']['view']) == 'password':
password = self._downloader.params.get('videopassword') password = self.get_param('videopassword')
if not password: if not password:
raise ExtractorError( raise ExtractorError(
'This album is protected by a password, use the --video-password option', 'This album is protected by a password, use the --video-password option',

View File

@ -287,7 +287,7 @@ class ViuOTTIE(InfoExtractor):
raise ExtractorError('This video is not available in your region.', expected=True) raise ExtractorError('This video is not available in your region.', expected=True)
series_id = video_data.get('series_id') series_id = video_data.get('series_id')
if not self._downloader.params.get('noplaylist') and not idata.get('force_noplaylist'): if not self.get_param('noplaylist') and not idata.get('force_noplaylist'):
self.to_screen('Downloading playlist %s - add --no-playlist to just download video' % series_id) self.to_screen('Downloading playlist %s - add --no-playlist to just download video' % series_id)
series = product_data.get('series', {}) series = product_data.get('series', {})
product = series.get('product') product = series.get('product')
@ -308,7 +308,7 @@ class ViuOTTIE(InfoExtractor):
return self.playlist_result(entries, series_id, series.get('name'), series.get('description')) return self.playlist_result(entries, series_id, series.get('name'), series.get('description'))
if self._downloader.params.get('noplaylist'): if self.get_param('noplaylist'):
self.to_screen('Downloading just video %s because of --no-playlist' % video_id) self.to_screen('Downloading just video %s because of --no-playlist' % video_id)
duration_limit = False duration_limit = False

View File

@ -136,7 +136,7 @@ class VLiveIE(VLiveBaseIE):
'author{nickname},channel{channelCode,channelName},officialVideo{commentCount,exposeStatus,likeCount,playCount,playTime,status,title,type,vodId},playlist{playlistSeq,totalCount,name}') 'author{nickname},channel{channelCode,channelName},officialVideo{commentCount,exposeStatus,likeCount,playCount,playTime,status,title,type,vodId},playlist{playlistSeq,totalCount,name}')
playlist = post.get('playlist') playlist = post.get('playlist')
if not playlist or self._downloader.params.get('noplaylist'): if not playlist or self.get_param('noplaylist'):
if playlist: if playlist:
self.to_screen( self.to_screen(
'Downloading just video %s because of --no-playlist' 'Downloading just video %s because of --no-playlist'

View File

@ -41,7 +41,7 @@ class WakanimIE(InfoExtractor):
m3u8_url = urljoin(url, self._search_regex( m3u8_url = urljoin(url, self._search_regex(
r'file\s*:\s*(["\'])(?P<url>(?:(?!\1).)+)\1', webpage, 'm3u8 url', r'file\s*:\s*(["\'])(?P<url>(?:(?!\1).)+)\1', webpage, 'm3u8 url',
group='url')) group='url'))
if not self._downloader.params.get('allow_unplayable_formats'): if not self.get_param('allow_unplayable_formats'):
# https://docs.microsoft.com/en-us/azure/media-services/previous/media-services-content-protection-overview#streaming-urls # https://docs.microsoft.com/en-us/azure/media-services/previous/media-services-content-protection-overview#streaming-urls
encryption = self._search_regex( encryption = self._search_regex(
r'encryption%3D(c(?:enc|bc(?:s-aapl)?))', r'encryption%3D(c(?:enc|bc(?:s-aapl)?))',

View File

@ -160,7 +160,7 @@ class YoukuIE(InfoExtractor):
'client_ts': time.time() / 1000, 'client_ts': time.time() / 1000,
} }
video_password = self._downloader.params.get('videopassword') video_password = self.get_param('videopassword')
if video_password: if video_password:
basic_data_params['password'] = video_password basic_data_params['password'] = video_password

View File

@ -88,9 +88,9 @@ class YoutubeBaseInfoExtractor(InfoExtractor):
username, password = self._get_login_info() username, password = self._get_login_info()
# No authentication to be performed # No authentication to be performed
if username is None: if username is None:
if self._LOGIN_REQUIRED and self._downloader.params.get('cookiefile') is None: if self._LOGIN_REQUIRED and self.get_param('cookiefile') is None:
raise ExtractorError('No login info available, needed for using %s.' % self.IE_NAME, expected=True) raise ExtractorError('No login info available, needed for using %s.' % self.IE_NAME, expected=True)
# if self._downloader.params.get('cookiefile'): # TODO remove 'and False' later - too many people using outdated cookies and open issues, remind them. # if self.get_param('cookiefile'): # TODO remove 'and False' later - too many people using outdated cookies and open issues, remind them.
# self.to_screen('[Cookies] Reminder - Make sure to always use up to date cookies!') # self.to_screen('[Cookies] Reminder - Make sure to always use up to date cookies!')
return True return True
@ -1460,7 +1460,7 @@ class YoutubeIE(YoutubeBaseInfoExtractor):
) )
self._player_cache[player_id] = func self._player_cache[player_id] = func
func = self._player_cache[player_id] func = self._player_cache[player_id]
if self._downloader.params.get('youtube_print_sig_code'): if self.get_param('youtube_print_sig_code'):
self._print_sig_code(func, s) self._print_sig_code(func, s)
return func(s) return func(s)
except Exception as e: except Exception as e:
@ -1690,7 +1690,7 @@ class YoutubeIE(YoutubeBaseInfoExtractor):
if not continuation: if not continuation:
break break
headers = self._generate_api_headers(ytcfg, identity_token, account_syncid, visitor_data) headers = self._generate_api_headers(ytcfg, identity_token, account_syncid, visitor_data)
retries = self._downloader.params.get('extractor_retries', 3) retries = self.get_param('extractor_retries', 3)
count = -1 count = -1
last_error = None last_error = None
@ -1948,7 +1948,7 @@ class YoutubeIE(YoutubeBaseInfoExtractor):
video_description = video_details.get('shortDescription') video_description = video_details.get('shortDescription')
if not smuggled_data.get('force_singlefeed', False): if not smuggled_data.get('force_singlefeed', False):
if not self._downloader.params.get('noplaylist'): if not self.get_param('noplaylist'):
multifeed_metadata_list = try_get( multifeed_metadata_list = try_get(
player_response, player_response,
lambda x: x['multicamera']['playerLegacyMulticameraRenderer']['metadataList'], lambda x: x['multicamera']['playerLegacyMulticameraRenderer']['metadataList'],
@ -2092,7 +2092,7 @@ class YoutubeIE(YoutubeBaseInfoExtractor):
f['format_id'] = itag f['format_id'] = itag
formats.append(f) formats.append(f)
if self._downloader.params.get('youtube_include_dash_manifest', True): if self.get_param('youtube_include_dash_manifest', True):
for sd in (streaming_data, ytm_streaming_data): for sd in (streaming_data, ytm_streaming_data):
dash_manifest_url = sd.get('dashManifestUrl') dash_manifest_url = sd.get('dashManifestUrl')
if dash_manifest_url: if dash_manifest_url:
@ -2114,7 +2114,7 @@ class YoutubeIE(YoutubeBaseInfoExtractor):
formats.append(f) formats.append(f)
if not formats: if not formats:
if not self._downloader.params.get('allow_unplayable_formats') and streaming_data.get('licenseInfos'): if not self.get_param('allow_unplayable_formats') and streaming_data.get('licenseInfos'):
self.raise_no_formats( self.raise_no_formats(
'This video is DRM protected.', expected=True) 'This video is DRM protected.', expected=True)
pemr = try_get( pemr = try_get(
@ -2473,8 +2473,8 @@ class YoutubeIE(YoutubeBaseInfoExtractor):
is_unlisted=None if is_private is None else is_unlisted) is_unlisted=None if is_private is None else is_unlisted)
# get xsrf for annotations or comments # get xsrf for annotations or comments
get_annotations = self._downloader.params.get('writeannotations', False) get_annotations = self.get_param('writeannotations', False)
get_comments = self._downloader.params.get('getcomments', False) get_comments = self.get_param('getcomments', False)
if get_annotations or get_comments: if get_annotations or get_comments:
xsrf_token = None xsrf_token = None
ytcfg = self._extract_ytcfg(video_id, webpage) ytcfg = self._extract_ytcfg(video_id, webpage)
@ -3475,7 +3475,7 @@ class YoutubeTabIE(YoutubeBaseInfoExtractor):
response = None response = None
last_error = None last_error = None
count = -1 count = -1
retries = self._downloader.params.get('extractor_retries', 3) retries = self.get_param('extractor_retries', 3)
if check_get_keys is None: if check_get_keys is None:
check_get_keys = [] check_get_keys = []
while count < retries: while count < retries:
@ -3519,7 +3519,7 @@ class YoutubeTabIE(YoutubeBaseInfoExtractor):
return response return response
def _extract_webpage(self, url, item_id): def _extract_webpage(self, url, item_id):
retries = self._downloader.params.get('extractor_retries', 3) retries = self.get_param('extractor_retries', 3)
count = -1 count = -1
last_error = 'Incomplete yt initial data recieved' last_error = 'Incomplete yt initial data recieved'
while count < retries: while count < retries:
@ -3559,7 +3559,7 @@ class YoutubeTabIE(YoutubeBaseInfoExtractor):
item_id = self._match_id(url) item_id = self._match_id(url)
url = compat_urlparse.urlunparse( url = compat_urlparse.urlunparse(
compat_urlparse.urlparse(url)._replace(netloc='www.youtube.com')) compat_urlparse.urlparse(url)._replace(netloc='www.youtube.com'))
compat_opts = self._downloader.params.get('compat_opts', []) compat_opts = self.get_param('compat_opts', [])
# This is not matched in a channel page with a tab selected # This is not matched in a channel page with a tab selected
mobj = re.match(r'(?P<pre>%s)(?P<post>/?(?![^#?]).*$)' % self._VALID_URL, url) mobj = re.match(r'(?P<pre>%s)(?P<post>/?(?![^#?]).*$)' % self._VALID_URL, url)
@ -3584,7 +3584,7 @@ class YoutubeTabIE(YoutubeBaseInfoExtractor):
url = 'https://www.youtube.com/playlist?list=%s' % playlist_id url = 'https://www.youtube.com/playlist?list=%s' % playlist_id
if video_id and playlist_id: if video_id and playlist_id:
if self._downloader.params.get('noplaylist'): if self.get_param('noplaylist'):
self.to_screen('Downloading just video %s because of --no-playlist' % video_id) self.to_screen('Downloading just video %s because of --no-playlist' % video_id)
return self.url_result(video_id, ie=YoutubeIE.ie_key(), video_id=video_id) return self.url_result(video_id, ie=YoutubeIE.ie_key(), video_id=video_id)
self.to_screen('Downloading playlist %s; add --no-playlist to just download video %s' % (playlist_id, video_id)) self.to_screen('Downloading playlist %s; add --no-playlist to just download video %s' % (playlist_id, video_id))

View File

@ -35,7 +35,7 @@ class ZoomIE(InfoExtractor):
except ExtractorError: except ExtractorError:
form = None form = None
if form: if form:
password = self._downloader.params.get('videopassword') password = self.get_param('videopassword')
if not password: if not password:
raise ExtractorError( raise ExtractorError(
'This video is protected by a passcode, use the --video-password option', expected=True) 'This video is protected by a passcode, use the --video-password option', expected=True)