diff --git a/youtube_dl/YoutubeDL.py b/youtube_dl/YoutubeDL.py old mode 100755 new mode 100644 index 4c762bf2c..b52b6b6ca --- a/youtube_dl/YoutubeDL.py +++ b/youtube_dl/YoutubeDL.py @@ -540,7 +540,9 @@ class YoutubeDL(object): """Print message to stdout if not in quiet mode.""" return self.to_stdout(message, skip_eol, check_quiet=True) - def _write_string(self, s, out=None, only_once=False, _cache=set()): + def _write_string(self, s, out=None, only_once=False, _cache=None): + if _cache is None: + _cache = set() if only_once and s in _cache: return write_string(s, out=out, encoding=self.params.get('encoding')) @@ -838,7 +840,7 @@ class YoutubeDL(object): for key, value in extra_info.items(): info_dict.setdefault(key, value) - def extract_info(self, url, download=True, ie_key=None, extra_info={}, + def extract_info(self, url, download=True, ie_key=None, extra_info=None, process=True, force_generic_extractor=False): """ Return a list with a dictionary for each video extracted. @@ -854,6 +856,8 @@ class YoutubeDL(object): must be True for download to work. force_generic_extractor -- force using the generic extractor """ + if extra_info is None: + extra_info = {} if not ie_key and force_generic_extractor: ie_key = 'Generic' @@ -998,7 +1002,7 @@ class YoutubeDL(object): 'extractor_key': ie.ie_key(), }) - def process_ie_result(self, ie_result, download=True, extra_info={}): + def process_ie_result(self, ie_result, download=True, extra_info=None): """ Take the result of the ie (may be modified) and resolve all unresolved references (URLs, playlist items). @@ -1006,6 +1010,8 @@ class YoutubeDL(object): It will also download the videos if 'download'. Returns the resolved ie_result. """ + if extra_info is None: + extra_info = {} result_type = ie_result.get('_type', 'video') if result_type in ('url', 'url_transparent'): diff --git a/youtube_dl/compat.py b/youtube_dl/compat.py index a985cb03e..7f1a2ffb0 100644 --- a/youtube_dl/compat.py +++ b/youtube_dl/compat.py @@ -3740,8 +3740,10 @@ else: except Exception: pass - def __repr__(self, _repr_running={}): + def __repr__(self, _repr_running=None): # skip recursive items ... + if _repr_running is None: + _repr_running = {} call_key = id(self), _get_ident() if _repr_running.get(call_key): return '...' diff --git a/youtube_dl/downloader/__init__.py b/youtube_dl/downloader/__init__.py index d701d6292..a48d45790 100644 --- a/youtube_dl/downloader/__init__.py +++ b/youtube_dl/downloader/__init__.py @@ -5,7 +5,9 @@ from ..utils import ( ) -def get_suitable_downloader(info_dict, params={}): +def get_suitable_downloader(info_dict, params=None): + if params is None: + params = {} info_dict['protocol'] = determine_protocol(info_dict) info_copy = info_dict.copy() return _get_suitable_downloader(info_copy, params) @@ -39,8 +41,10 @@ PROTOCOL_MAP = { } -def _get_suitable_downloader(info_dict, params={}): +def _get_suitable_downloader(info_dict, params=None): """Get the downloader class that can handle the info dict.""" + if params is None: + params = {} # if (info_dict.get('start_time') or info_dict.get('end_time')) and not info_dict.get('requested_formats') and FFmpegFD.can_download(info_dict): # return FFmpegFD diff --git a/youtube_dl/downloader/external.py b/youtube_dl/downloader/external.py index 4fbc0f520..5154fe0d3 100644 --- a/youtube_dl/downloader/external.py +++ b/youtube_dl/downloader/external.py @@ -111,7 +111,9 @@ class ExternalFD(FileDownloader): def _valueless_option(self, command_option, param, expected_value=True): return cli_valueless_option(self.params, command_option, param, expected_value) - def _configuration_args(self, default=[]): + def _configuration_args(self, default=None): + if default is None: + default = [] return cli_configuration_args(self.params, 'external_downloader_args', default) def _write_cookies(self): diff --git a/youtube_dl/extractor/adobepass.py b/youtube_dl/extractor/adobepass.py index 38dca1b0a..65cf0b408 100644 --- a/youtube_dl/extractor/adobepass.py +++ b/youtube_dl/extractor/adobepass.py @@ -1360,7 +1360,9 @@ class AdobePassIE(InfoExtractor): token_expires = unified_timestamp(re.sub(r'[_ ]GMT', '', xml_text(token, date_ele))) return token_expires and token_expires <= int(time.time()) - def post_form(form_page_res, note, data={}): + def post_form(form_page_res, note, data=None): + if data is None: + data = {} form_page, urlh = form_page_res post_url = self._html_search_regex(r'