From e121e3cee731426f620e17939141018d09661fa2 Mon Sep 17 00:00:00 2001 From: christoph-heinrich Date: Sat, 18 Jun 2022 03:57:22 +0200 Subject: [PATCH] [cleanup] Minor fixes (#4096) Authored by: christoph-heinrich --- yt_dlp/extractor/common.py | 4 ++-- yt_dlp/extractor/openload.py | 4 ++-- yt_dlp/postprocessor/ffmpeg.py | 6 ++++-- yt_dlp/utils.py | 2 +- 4 files changed, 9 insertions(+), 7 deletions(-) diff --git a/yt_dlp/extractor/common.py b/yt_dlp/extractor/common.py index 080d682eb..6b5252280 100644 --- a/yt_dlp/extractor/common.py +++ b/yt_dlp/extractor/common.py @@ -909,7 +909,7 @@ class InfoExtractor: dump = base64.b64encode(webpage_bytes).decode('ascii') self._downloader.to_screen(dump) if self.get_param('write_pages'): - filename = self._request_dump_filename(video_id, urlh.geturl()) + filename = self._request_dump_filename(urlh.geturl(), video_id) self.to_screen(f'Saving request to {filename}') with open(filename, 'wb') as outf: outf.write(webpage_bytes) @@ -940,7 +940,7 @@ class InfoExtractor: if fatal: raise ExtractorError(errmsg, cause=ve) else: - self.report_warning(errmsg + str(ve)) + self.report_warning(f'{errmsg}: {ve}') def _parse_socket_response_as_json(self, data, video_id, transform_source=None, fatal=True): return self._parse_json( diff --git a/yt_dlp/extractor/openload.py b/yt_dlp/extractor/openload.py index d987cd927..22d7e1a84 100644 --- a/yt_dlp/extractor/openload.py +++ b/yt_dlp/extractor/openload.py @@ -216,10 +216,10 @@ class PhantomJSwrapper: [self.exe, '--ssl-protocol=any', self._TMP_FILES['script'].name], text=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE) if returncode: - raise ExtractorError(f'Executing JS failed\n:{stderr}') + raise ExtractorError(f'Executing JS failed:\n{stderr}') with open(self._TMP_FILES['html'].name, 'rb') as f: html = f.read().decode('utf-8') self._load_cookies() - return (html, stdout) + return html, stdout diff --git a/yt_dlp/postprocessor/ffmpeg.py b/yt_dlp/postprocessor/ffmpeg.py index 71ae16b51..0c8d4611d 100644 --- a/yt_dlp/postprocessor/ffmpeg.py +++ b/yt_dlp/postprocessor/ffmpeg.py @@ -239,7 +239,8 @@ class FFmpegPostProcessor(PostProcessor): encodeArgument('-i')] cmd.append(encodeFilename(self._ffmpeg_filename_argument(path), True)) self.write_debug(f'{self.basename} command line: {shell_quote(cmd)}') - stdout, stderr, returncode = Popen.run(cmd, text=True, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE) + stdout, stderr, returncode = Popen.run( + cmd, text=True, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE) if returncode != (0 if self.probe_available else 1): return None except OSError: @@ -343,7 +344,8 @@ class FFmpegPostProcessor(PostProcessor): for i, (path, opts) in enumerate(path_opts) if path) self.write_debug('ffmpeg command line: %s' % shell_quote(cmd)) - stdout, stderr, returncode = Popen.run(cmd, text=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE, stdin=subprocess.PIPE) + _, stderr, returncode = Popen.run( + cmd, text=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE, stdin=subprocess.PIPE) if returncode not in variadic(expected_retcodes): raise FFmpegPostProcessorError(stderr.strip().splitlines()[-1]) for out_path, _ in output_path_opts: diff --git a/yt_dlp/utils.py b/yt_dlp/utils.py index 8dda5e931..4a519e4e0 100644 --- a/yt_dlp/utils.py +++ b/yt_dlp/utils.py @@ -4954,7 +4954,7 @@ def write_xattr(path, key, value): try: _, stderr, returncode = Popen.run( [exe, '-w', key, value, path] if exe == 'xattr' else [exe, '-n', key, '-v', value, path], - stdout=subprocess.PIPE, stderr=subprocess.PIPE, stdin=subprocess.PIPE) + text=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE, stdin=subprocess.PIPE) except OSError as e: raise XAttrMetadataError(e.errno, e.strerror) if returncode: