aboutsummaryrefslogtreecommitdiffstats
path: root/yt_dlp/postprocessor/embedthumbnail.py
diff options
context:
space:
mode:
authorpukkandan <pukkandan.ytdlp@gmail.com>2022-06-16 02:25:43 +0530
committerpukkandan <pukkandan.ytdlp@gmail.com>2022-06-16 06:23:50 +0530
commitf0c9fb96827ff798a48626e7e5d32a9c5de7b97e (patch)
tree440139f107fb95d967f5ff32361a194e4e5afd22 /yt_dlp/postprocessor/embedthumbnail.py
parent560738f34de4df6eaf82290fd503def3f366f878 (diff)
downloadhypervideo-pre-f0c9fb96827ff798a48626e7e5d32a9c5de7b97e.tar.lz
hypervideo-pre-f0c9fb96827ff798a48626e7e5d32a9c5de7b97e.tar.xz
hypervideo-pre-f0c9fb96827ff798a48626e7e5d32a9c5de7b97e.zip
[utils] `Popen`: Refactor to use contextmanager
Fixes https://github.com/yt-dlp/yt-dlp/issues/3531#issuecomment-1156223597
Diffstat (limited to 'yt_dlp/postprocessor/embedthumbnail.py')
-rw-r--r--yt_dlp/postprocessor/embedthumbnail.py10
1 files changed, 4 insertions, 6 deletions
diff --git a/yt_dlp/postprocessor/embedthumbnail.py b/yt_dlp/postprocessor/embedthumbnail.py
index e031d344f..606d90d3d 100644
--- a/yt_dlp/postprocessor/embedthumbnail.py
+++ b/yt_dlp/postprocessor/embedthumbnail.py
@@ -157,14 +157,12 @@ class EmbedThumbnailPP(FFmpegPostProcessor):
self._report_run('atomicparsley', filename)
self.write_debug('AtomicParsley command line: %s' % shell_quote(cmd))
- p = Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
- stdout, stderr = p.communicate_or_kill()
- if p.returncode != 0:
- msg = stderr.decode('utf-8', 'replace').strip()
- self.report_warning(f'Unable to embed thumbnails using AtomicParsley; {msg}')
+ stdout, stderr, returncode = Popen.run(cmd, text=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
+ if returncode:
+ self.report_warning(f'Unable to embed thumbnails using AtomicParsley; {stderr.strip()}')
# for formats that don't support thumbnails (like 3gp) AtomicParsley
# won't create to the temporary file
- if b'No changes' in stdout:
+ if 'No changes' in stdout:
self.report_warning('The file format doesn\'t support embedding a thumbnail')
success = False