From bf6bdf22de7fb96390cafa9b90c2ae9eba5170bf Mon Sep 17 00:00:00 2001 From: pukkandan Date: Fri, 19 Aug 2022 09:49:26 +0530 Subject: [PATCH] Revert "[ffmpeg] Set `ffmpeg_location` in a contextvar" This reverts commit 6a7d3a0a0981d05903e70bcb31fc3f9438eedf22. --- yt_dlp/__init__.py | 12 +----------- yt_dlp/postprocessor/ffmpeg.py | 5 +---- 2 files changed, 2 insertions(+), 15 deletions(-) diff --git a/yt_dlp/__init__.py b/yt_dlp/__init__.py index 317dd26231..6ad2e97e8e 100644 --- a/yt_dlp/__init__.py +++ b/yt_dlp/__init__.py @@ -1,8 +1,4 @@ -try: - import contextvars # noqa: F401 -except Exception: - raise Exception( - f'You are using an unsupported version of Python. Only Python versions 3.7 and above are supported by yt-dlp') # noqa: F541 +f'You are using an unsupported version of Python. Only Python versions 3.7 and above are supported by yt-dlp' # noqa: F541 __license__ = 'Public Domain' @@ -25,7 +21,6 @@ from .options import parseOpts from .postprocessor import ( FFmpegExtractAudioPP, FFmpegMergerPP, - FFmpegPostProcessor, FFmpegSubtitlesConvertorPP, FFmpegThumbnailsConvertorPP, FFmpegVideoConvertorPP, @@ -907,11 +902,6 @@ def _real_main(argv=None): if print_extractor_information(opts, all_urls): return - # We may need ffmpeg_location without having access to the YoutubeDL instance - # See https://github.com/yt-dlp/yt-dlp/issues/2191 - if opts.ffmpeg_location: - FFmpegPostProcessor._ffmpeg_location.set(opts.ffmpeg_location) - with YoutubeDL(ydl_opts) as ydl: pre_process = opts.update_self or opts.rm_cachedir actual_use = all_urls or opts.load_info_filename diff --git a/yt_dlp/postprocessor/ffmpeg.py b/yt_dlp/postprocessor/ffmpeg.py index a1f367ae42..20a0b22f08 100644 --- a/yt_dlp/postprocessor/ffmpeg.py +++ b/yt_dlp/postprocessor/ffmpeg.py @@ -1,5 +1,4 @@ import collections -import contextvars import itertools import json import os @@ -83,8 +82,6 @@ class FFmpegPostProcessorError(PostProcessingError): class FFmpegPostProcessor(PostProcessor): - _ffmpeg_location = contextvars.ContextVar('ffmpeg_location', default=None) - def __init__(self, downloader=None): PostProcessor.__init__(self, downloader) self._prefer_ffmpeg = self.get_param('prefer_ffmpeg', True) @@ -104,7 +101,7 @@ class FFmpegPostProcessor(PostProcessor): def _determine_executables(self): programs = [*self._ffmpeg_to_avconv.keys(), *self._ffmpeg_to_avconv.values()] - location = self.get_param('ffmpeg_location', self._ffmpeg_location.get()) + location = self.get_param('ffmpeg_location') if location is None: return {p: p for p in programs}