Skip to content

Commit

Permalink
yt_dlp: c54ddfba0f7d68034339426223d75373c5fc86df
Browse files Browse the repository at this point in the history
  • Loading branch information
github-actions[bot] committed Sep 24, 2023
1 parent efab602 commit 53acb43
Show file tree
Hide file tree
Showing 6 changed files with 53 additions and 24 deletions.
16 changes: 4 additions & 12 deletions lib/yt_dlp/YoutubeDL.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
get_postprocessor,
)
from .postprocessor.ffmpeg import resolve_mapping as resolve_recode_mapping
from .update import REPOSITORY, current_git_head, detect_variant
from .update import REPOSITORY, _get_system_deprecation, current_git_head, detect_variant
from .utils import (
DEFAULT_OUTTMPL,
IDENTITY,
Expand Down Expand Up @@ -640,17 +640,9 @@ def process_color_policy(stream):
for name, stream in self._out_files.items_ if name != 'console'
})

# The code is left like this to be reused for future deprecations
MIN_SUPPORTED, MIN_RECOMMENDED = (3, 7), (3, 7)
current_version = sys.version_info[:2]
if current_version < MIN_RECOMMENDED:
msg = ('Support for Python version %d.%d has been deprecated. '
'See https://github.com/yt-dlp/yt-dlp/issues/3764 for more details.'
'\n You will no longer receive updates on this version')
if current_version < MIN_SUPPORTED:
msg = 'Python version %d.%d is no longer supported'
self.deprecated_feature(
f'{msg}! Please update to Python %d.%d or above' % (*current_version, *MIN_RECOMMENDED))
system_deprecation = _get_system_deprecation()
if system_deprecation:
self.deprecated_feature(system_deprecation.replace('\n', '\n '))

if self.params.get('allow_unplayable_formats'):
self.report_warning(
Expand Down
2 changes: 1 addition & 1 deletion lib/yt_dlp/compat/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def compat_etree_fromstring(text):
if compat_os_name == 'nt':
def compat_shlex_quote(s):
import re
return s if re.match(r'^[-_\w./]+$', s) else '"%s"' % s.replace('"', '\\"')
return s if re.match(r'^[-_\w./]+$', s) else s.replace('"', '""').join('""')
else:
from shlex import quote as compat_shlex_quote # noqa: F401

Expand Down
12 changes: 5 additions & 7 deletions lib/yt_dlp/postprocessor/exec.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import subprocess

from .common import PostProcessor
from ..compat import compat_shlex_quote
from ..utils import PostProcessingError, encodeArgument, variadic
from ..utils import Popen, PostProcessingError, variadic


class ExecPP(PostProcessor):
Expand All @@ -27,10 +25,10 @@ def parse_cmd(self, cmd, info):
def run(self, info):
for tmpl in self.exec_cmd:
cmd = self.parse_cmd(tmpl, info)
self.to_screen('Executing command: %s' % cmd)
retCode = subprocess.call(encodeArgument(cmd), shell=True)
if retCode != 0:
raise PostProcessingError('Command returned error code %d' % retCode)
self.to_screen(f'Executing command: {cmd}')
_, _, return_code = Popen.run(cmd, shell=True)
if return_code != 0:
raise PostProcessingError(f'Command returned error code {return_code}')
return [], info


Expand Down
25 changes: 25 additions & 0 deletions lib/yt_dlp/update.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,31 @@ def is_non_updateable():
detect_variant(), _NON_UPDATEABLE_REASONS['unknown' if VARIANT else 'other'])


def _get_system_deprecation():
MIN_SUPPORTED, MIN_RECOMMENDED = (3, 7), (3, 8)

if sys.version_info > MIN_RECOMMENDED:
return None

major, minor = sys.version_info[:2]
if sys.version_info < MIN_SUPPORTED:
msg = f'Python version {major}.{minor} is no longer supported'
else:
msg = f'Support for Python version {major}.{minor} has been deprecated. '
# Temporary until `win_x86_exe` uses 3.8, which will deprecate Vista and Server 2008
if detect_variant() == 'win_x86_exe':
platform_name = platform.platform()
if any(platform_name.startswith(f'Windows-{name}') for name in ('Vista', '2008Server')):
msg = 'Support for Windows Vista/Server 2008 has been deprecated. '
else:
return None
msg += ('See https://github.com/yt-dlp/yt-dlp/issues/7803 for details.'
'\nYou may stop receiving updates on this version at any time')

major, minor = MIN_RECOMMENDED
return f'{msg}! Please update to Python {major}.{minor} or above'


def _sha256_file(path):
h = hashlib.sha256()
mv = memoryview(bytearray(128 * 1024))
Expand Down
18 changes: 16 additions & 2 deletions lib/yt_dlp/utils/_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -825,7 +825,7 @@ def _fix(key):
_fix('LD_LIBRARY_PATH') # Linux
_fix('DYLD_LIBRARY_PATH') # macOS

def __init__(self, *args, env=None, text=False, **kwargs):
def __init__(self, args, *remaining, env=None, text=False, shell=False, **kwargs):
if env is None:
env = os.environ.copy()
self._fix_pyinstaller_ld_path(env)
Expand All @@ -835,7 +835,21 @@ def __init__(self, *args, env=None, text=False, **kwargs):
kwargs['universal_newlines'] = True # For 3.6 compatibility
kwargs.setdefault('encoding', 'utf-8')
kwargs.setdefault('errors', 'replace')
super().__init__(*args, env=env, **kwargs, startupinfo=self._startupinfo)

if shell and compat_os_name == 'nt' and kwargs.get('executable') is None:
if not isinstance(args, str):
args = ' '.join(compat_shlex_quote(a) for a in args)
shell = False
args = f'{self.__comspec()} /Q /S /D /V:OFF /C "{args}"'

super().__init__(args, *remaining, env=env, shell=shell, **kwargs, startupinfo=self._startupinfo)

def __comspec(self):
comspec = os.environ.get('ComSpec') or os.path.join(
os.environ.get('SystemRoot', ''), 'System32', 'cmd.exe')
if os.path.isabs(comspec):
return comspec
raise FileNotFoundError('shell not found: neither %ComSpec% nor %SystemRoot% is set')

def communicate_or_kill(self, *args, **kwargs):
try:
Expand Down
4 changes: 2 additions & 2 deletions lib/yt_dlp/version.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# Autogenerated by devscripts/update-version.py

__version__ = '2023.07.06'
__version__ = '2023.09.24'

RELEASE_GIT_HEAD = 'b532a3481046e1eabb6232ee8196fb696c356ff6'
RELEASE_GIT_HEAD = '088add9567d39b758737e4299a0e619fd89d2e8f'

VARIANT = None

Expand Down

0 comments on commit 53acb43

Please sign in to comment.