mirror of
https://github.com/yt-dlp/yt-dlp.git
synced 2026-09-08 18:01:56 +00:00
[ie/youtube] Implement external n/sig solver (#14157)
Challenge Tests / Challenge Tests (ubuntu-latest, 3.10) (push) Has been cancelled
Challenge Tests / Challenge Tests (ubuntu-latest, 3.11) (push) Has been cancelled
Challenge Tests / Challenge Tests (ubuntu-latest, 3.12) (push) Has been cancelled
Challenge Tests / Challenge Tests (ubuntu-latest, 3.13) (push) Has been cancelled
Challenge Tests / Challenge Tests (ubuntu-latest, 3.14) (push) Has been cancelled
Challenge Tests / Challenge Tests (ubuntu-latest, pypy-3.11) (push) Has been cancelled
Challenge Tests / Challenge Tests (windows-latest, 3.10) (push) Has been cancelled
Challenge Tests / Challenge Tests (windows-latest, 3.11) (push) Has been cancelled
Challenge Tests / Challenge Tests (windows-latest, 3.12) (push) Has been cancelled
Challenge Tests / Challenge Tests (windows-latest, 3.13) (push) Has been cancelled
Challenge Tests / Challenge Tests (windows-latest, 3.14) (push) Has been cancelled
Challenge Tests / Challenge Tests (windows-latest, pypy-3.11) (push) Has been cancelled
CodeQL / Analyze (python) (push) Has been cancelled
Core Tests / Core Tests (ubuntu-latest, 3.11) (push) Has been cancelled
Core Tests / Core Tests (ubuntu-latest, 3.12) (push) Has been cancelled
Core Tests / Core Tests (ubuntu-latest, 3.13) (push) Has been cancelled
Core Tests / Core Tests (ubuntu-latest, 3.14) (push) Has been cancelled
Core Tests / Core Tests (ubuntu-latest, pypy-3.11) (push) Has been cancelled
Core Tests / Core Tests (windows-latest, 3.10) (push) Has been cancelled
Core Tests / Core Tests (windows-latest, 3.11) (push) Has been cancelled
Core Tests / Core Tests (windows-latest, 3.12) (push) Has been cancelled
Core Tests / Core Tests (windows-latest, 3.13) (push) Has been cancelled
Core Tests / Core Tests (windows-latest, 3.14) (push) Has been cancelled
Core Tests / Core Tests (windows-latest, pypy-3.11) (push) Has been cancelled
Download Tests / Quick Download Tests (push) Has been cancelled
Download Tests / Full Download Tests (ubuntu-latest, 3.11) (push) Has been cancelled
Download Tests / Full Download Tests (ubuntu-latest, 3.12) (push) Has been cancelled
Download Tests / Full Download Tests (ubuntu-latest, 3.13) (push) Has been cancelled
Download Tests / Full Download Tests (ubuntu-latest, 3.14) (push) Has been cancelled
Download Tests / Full Download Tests (ubuntu-latest, pypy-3.11) (push) Has been cancelled
Download Tests / Full Download Tests (windows-latest, 3.10) (push) Has been cancelled
Download Tests / Full Download Tests (windows-latest, pypy-3.11) (push) Has been cancelled
Quick Test / Core Test (push) Has been cancelled
Quick Test / Code check (push) Has been cancelled
Release (master) / release (push) Has been cancelled
Release (master) / publish_pypi (push) Has been cancelled
Release (nightly) / check_nightly (push) Has been cancelled
Release (nightly) / release (push) Has been cancelled
Release (nightly) / publish_pypi (push) Has been cancelled
Test and lint workflows / Check workflows (push) Has been cancelled
Challenge Tests / Challenge Tests (ubuntu-latest, 3.10) (push) Has been cancelled
Challenge Tests / Challenge Tests (ubuntu-latest, 3.11) (push) Has been cancelled
Challenge Tests / Challenge Tests (ubuntu-latest, 3.12) (push) Has been cancelled
Challenge Tests / Challenge Tests (ubuntu-latest, 3.13) (push) Has been cancelled
Challenge Tests / Challenge Tests (ubuntu-latest, 3.14) (push) Has been cancelled
Challenge Tests / Challenge Tests (ubuntu-latest, pypy-3.11) (push) Has been cancelled
Challenge Tests / Challenge Tests (windows-latest, 3.10) (push) Has been cancelled
Challenge Tests / Challenge Tests (windows-latest, 3.11) (push) Has been cancelled
Challenge Tests / Challenge Tests (windows-latest, 3.12) (push) Has been cancelled
Challenge Tests / Challenge Tests (windows-latest, 3.13) (push) Has been cancelled
Challenge Tests / Challenge Tests (windows-latest, 3.14) (push) Has been cancelled
Challenge Tests / Challenge Tests (windows-latest, pypy-3.11) (push) Has been cancelled
CodeQL / Analyze (python) (push) Has been cancelled
Core Tests / Core Tests (ubuntu-latest, 3.11) (push) Has been cancelled
Core Tests / Core Tests (ubuntu-latest, 3.12) (push) Has been cancelled
Core Tests / Core Tests (ubuntu-latest, 3.13) (push) Has been cancelled
Core Tests / Core Tests (ubuntu-latest, 3.14) (push) Has been cancelled
Core Tests / Core Tests (ubuntu-latest, pypy-3.11) (push) Has been cancelled
Core Tests / Core Tests (windows-latest, 3.10) (push) Has been cancelled
Core Tests / Core Tests (windows-latest, 3.11) (push) Has been cancelled
Core Tests / Core Tests (windows-latest, 3.12) (push) Has been cancelled
Core Tests / Core Tests (windows-latest, 3.13) (push) Has been cancelled
Core Tests / Core Tests (windows-latest, 3.14) (push) Has been cancelled
Core Tests / Core Tests (windows-latest, pypy-3.11) (push) Has been cancelled
Download Tests / Quick Download Tests (push) Has been cancelled
Download Tests / Full Download Tests (ubuntu-latest, 3.11) (push) Has been cancelled
Download Tests / Full Download Tests (ubuntu-latest, 3.12) (push) Has been cancelled
Download Tests / Full Download Tests (ubuntu-latest, 3.13) (push) Has been cancelled
Download Tests / Full Download Tests (ubuntu-latest, 3.14) (push) Has been cancelled
Download Tests / Full Download Tests (ubuntu-latest, pypy-3.11) (push) Has been cancelled
Download Tests / Full Download Tests (windows-latest, 3.10) (push) Has been cancelled
Download Tests / Full Download Tests (windows-latest, pypy-3.11) (push) Has been cancelled
Quick Test / Core Test (push) Has been cancelled
Quick Test / Code check (push) Has been cancelled
Release (master) / release (push) Has been cancelled
Release (master) / publish_pypi (push) Has been cancelled
Release (nightly) / check_nightly (push) Has been cancelled
Release (nightly) / release (push) Has been cancelled
Release (nightly) / publish_pypi (push) Has been cancelled
Test and lint workflows / Check workflows (push) Has been cancelled
Closes #14404, Closes #14431, Closes #14680, Closes #14707 Authored by: bashonly, coletdjnz, seproDev, Grub4K Co-authored-by: coletdjnz <[email protected]> Co-authored-by: bashonly <[email protected]> Co-authored-by: sepro <[email protected]>
This commit is contained in:
co-authored by
coletdjnz
bashonly
sepro
parent
d6ee677253
commit
6224a38988
@@ -0,0 +1,101 @@
|
||||
from __future__ import annotations
|
||||
import abc
|
||||
import dataclasses
|
||||
import functools
|
||||
|
||||
from ._utils import _get_exe_version_output, detect_exe_version, int_or_none
|
||||
|
||||
|
||||
# NOT public API
|
||||
def runtime_version_tuple(v):
|
||||
# NB: will return (0,) if `v` is an invalid version string
|
||||
return tuple(int_or_none(x, default=0) for x in v.split('.'))
|
||||
|
||||
|
||||
@dataclasses.dataclass(frozen=True)
|
||||
class JsRuntimeInfo:
|
||||
name: str
|
||||
path: str
|
||||
version: str
|
||||
version_tuple: tuple[int, ...]
|
||||
supported: bool = True
|
||||
|
||||
|
||||
class JsRuntime(abc.ABC):
|
||||
def __init__(self, path=None):
|
||||
self._path = path
|
||||
|
||||
@functools.cached_property
|
||||
def info(self) -> JsRuntimeInfo | None:
|
||||
return self._info()
|
||||
|
||||
@abc.abstractmethod
|
||||
def _info(self) -> JsRuntimeInfo | None:
|
||||
raise NotImplementedError
|
||||
|
||||
|
||||
class DenoJsRuntime(JsRuntime):
|
||||
MIN_SUPPORTED_VERSION = (2, 0, 0)
|
||||
|
||||
def _info(self):
|
||||
path = self._path or 'deno'
|
||||
out = _get_exe_version_output(path, ['--version'])
|
||||
if not out:
|
||||
return None
|
||||
version = detect_exe_version(out, r'^deno (\S+)', 'unknown')
|
||||
vt = runtime_version_tuple(version)
|
||||
return JsRuntimeInfo(
|
||||
name='deno', path=path, version=version, version_tuple=vt,
|
||||
supported=vt >= self.MIN_SUPPORTED_VERSION)
|
||||
|
||||
|
||||
class BunJsRuntime(JsRuntime):
|
||||
MIN_SUPPORTED_VERSION = (1, 0, 31)
|
||||
|
||||
def _info(self):
|
||||
path = self._path or 'bun'
|
||||
out = _get_exe_version_output(path, ['--version'])
|
||||
if not out:
|
||||
return None
|
||||
version = detect_exe_version(out, r'^(\S+)', 'unknown')
|
||||
vt = runtime_version_tuple(version)
|
||||
return JsRuntimeInfo(
|
||||
name='bun', path=path, version=version, version_tuple=vt,
|
||||
supported=vt >= self.MIN_SUPPORTED_VERSION)
|
||||
|
||||
|
||||
class NodeJsRuntime(JsRuntime):
|
||||
MIN_SUPPORTED_VERSION = (20, 0, 0)
|
||||
|
||||
def _info(self):
|
||||
path = self._path or 'node'
|
||||
out = _get_exe_version_output(path, ['--version'])
|
||||
if not out:
|
||||
return None
|
||||
version = detect_exe_version(out, r'^v(\S+)', 'unknown')
|
||||
vt = runtime_version_tuple(version)
|
||||
return JsRuntimeInfo(
|
||||
name='node', path=path, version=version, version_tuple=vt,
|
||||
supported=vt >= self.MIN_SUPPORTED_VERSION)
|
||||
|
||||
|
||||
class QuickJsRuntime(JsRuntime):
|
||||
MIN_SUPPORTED_VERSION = (2023, 12, 9)
|
||||
|
||||
def _info(self):
|
||||
path = self._path or 'qjs'
|
||||
# quickjs does not have --version and --help returns a status code of 1
|
||||
out = _get_exe_version_output(path, ['--help'], ignore_return_code=True)
|
||||
if not out:
|
||||
return None
|
||||
is_ng = 'QuickJS-ng' in out
|
||||
|
||||
version = detect_exe_version(out, r'^QuickJS(?:-ng)?\s+version\s+(\S+)', 'unknown')
|
||||
vt = runtime_version_tuple(version.replace('-', '.'))
|
||||
if is_ng:
|
||||
return JsRuntimeInfo(
|
||||
name='quickjs-ng', path=path, version=version, version_tuple=vt,
|
||||
supported=vt > (0,))
|
||||
return JsRuntimeInfo(
|
||||
name='quickjs', path=path, version=version, version_tuple=vt,
|
||||
supported=vt >= self.MIN_SUPPORTED_VERSION)
|
||||
Reference in New Issue
Block a user