Compare commits

...

4 Commits

Author SHA1 Message Date
pukkandan
778763d9e6 Release 2022.08.18.36 2022-08-19 10:22:49 +05:30
pukkandan
6657e7834f Use compat.re 2022-08-19 09:49:52 +05:30
pukkandan
5dceb21df6 Revert "Remove Python 3.6 support"
This reverts commit 6929b41a21.
2022-08-19 09:49:29 +05:30
pukkandan
bf6bdf22de Revert "[ffmpeg] Set ffmpeg_location in a contextvar"
This reverts commit 6a7d3a0a09.
2022-08-19 09:49:26 +05:30
20 changed files with 68 additions and 40 deletions

View File

@@ -264,7 +264,7 @@ jobs:
- name: Make Update spec - name: Make Update spec
run: | run: |
echo "# This file is used for regulating self-update" >> _update_spec echo "# This file is used for regulating self-update" >> _update_spec
echo "lock 2022.07.18 .+ Python 3.6" >> _update_spec echo "lock 2022.08.18.36 .+ Python 3.6" >> _update_spec
- name: Make SHA2-SUMS files - name: Make SHA2-SUMS files
run: | run: |
sha256sum artifact/yt-dlp | awk '{print $1 " yt-dlp"}' >> SHA2-256SUMS sha256sum artifact/yt-dlp | awk '{print $1 " yt-dlp"}' >> SHA2-256SUMS

View File

@@ -10,7 +10,7 @@ jobs:
matrix: matrix:
os: [ubuntu-latest] os: [ubuntu-latest]
# CPython 3.9 is in quick-test # CPython 3.9 is in quick-test
python-version: ['3.7', '3.10', 3.11-dev, pypy-3.7, pypy-3.8] python-version: ['3.6', '3.7', '3.10', 3.11-dev, pypy-3.6, pypy-3.7, pypy-3.8]
run-tests-ext: [sh] run-tests-ext: [sh]
include: include:
# atleast one of each CPython/PyPy tests must be in windows # atleast one of each CPython/PyPy tests must be in windows

View File

@@ -25,7 +25,7 @@ jobs:
fail-fast: true fail-fast: true
matrix: matrix:
os: [ubuntu-latest] os: [ubuntu-latest]
python-version: ['3.7', '3.10', 3.11-dev, pypy-3.7, pypy-3.8] python-version: ['3.6', '3.7', '3.10', 3.11-dev, pypy-3.6, pypy-3.7, pypy-3.8]
run-tests-ext: [sh] run-tests-ext: [sh]
include: include:
# atleast one of each CPython/PyPy tests must be in windows # atleast one of each CPython/PyPy tests must be in windows

View File

@@ -11,6 +11,12 @@
--> -->
### 2022.08.18.36
* Revert "[ffmpeg] Set `ffmpeg_location` in a contextvar"
* Revert "Remove Python 3.6 support"
* Use `compat.re`
### 2022.08.19 ### 2022.08.19
* Fix bug in `--download-archive` * Fix bug in `--download-archive`

View File

@@ -16,6 +16,7 @@ from devscripts.utils import read_version, write_file
def get_new_version(revision): def get_new_version(revision):
return read_version()
version = datetime.utcnow().strftime('%Y.%m.%d') version = datetime.utcnow().strftime('%Y.%m.%d')
if revision: if revision:

View File

@@ -126,7 +126,7 @@ setup(
url='https://github.com/yt-dlp/yt-dlp', url='https://github.com/yt-dlp/yt-dlp',
packages=packages(), packages=packages(),
install_requires=REQUIREMENTS, install_requires=REQUIREMENTS,
python_requires='>=3.7', python_requires='>=3.6',
project_urls={ project_urls={
'Documentation': 'https://github.com/yt-dlp/yt-dlp#readme', 'Documentation': 'https://github.com/yt-dlp/yt-dlp#readme',
'Source': 'https://github.com/yt-dlp/yt-dlp', 'Source': 'https://github.com/yt-dlp/yt-dlp',
@@ -138,6 +138,7 @@ setup(
'Development Status :: 5 - Production/Stable', 'Development Status :: 5 - Production/Stable',
'Environment :: Console', 'Environment :: Console',
'Programming Language :: Python', 'Programming Language :: Python',
'Programming Language :: Python :: 3.6',
'Programming Language :: Python :: 3.7', 'Programming Language :: Python :: 3.7',
'Programming Language :: Python :: 3.8', 'Programming Language :: Python :: 3.8',
'Programming Language :: Python :: 3.9', 'Programming Language :: Python :: 3.9',

View File

@@ -28,8 +28,7 @@ class TestCompat(unittest.TestCase):
with self.assertWarns(DeprecationWarning): with self.assertWarns(DeprecationWarning):
compat.WINDOWS_VT_MODE compat.WINDOWS_VT_MODE
# TODO: Test submodule compat.asyncio.events # Must not raise error
# compat.asyncio.events # Must not raise error
def test_compat_expanduser(self): def test_compat_expanduser(self):
old_home = os.environ.get('HOME') old_home = os.environ.get('HOME')

View File

@@ -8,8 +8,8 @@ import unittest
sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
import math import math
import re
from yt_dlp.compat import re
from yt_dlp.jsinterp import JS_Undefined, JSInterpreter from yt_dlp.jsinterp import JS_Undefined, JSInterpreter

View File

@@ -591,8 +591,7 @@ class YoutubeDL:
for type_, stream in self._out_files.items_ if type_ != 'console' for type_, stream in self._out_files.items_ if type_ != 'console'
}) })
# The code is left like this to be reused for future deprecations MIN_SUPPORTED, MIN_RECOMMENDED = (3, 6), (3, 7)
MIN_SUPPORTED, MIN_RECOMMENDED = (3, 7), (3, 7)
current_version = sys.version_info[:2] current_version = sys.version_info[:2]
if current_version < MIN_RECOMMENDED: if current_version < MIN_RECOMMENDED:
msg = ('Support for Python version %d.%d has been deprecated. ' msg = ('Support for Python version %d.%d has been deprecated. '

View File

@@ -1,8 +1,4 @@
try: f'You are using an unsupported version of Python. Only Python versions 3.6 and above are supported by yt-dlp' # noqa: F541
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
__license__ = 'Public Domain' __license__ = 'Public Domain'
@@ -25,7 +21,6 @@ from .options import parseOpts
from .postprocessor import ( from .postprocessor import (
FFmpegExtractAudioPP, FFmpegExtractAudioPP,
FFmpegMergerPP, FFmpegMergerPP,
FFmpegPostProcessor,
FFmpegSubtitlesConvertorPP, FFmpegSubtitlesConvertorPP,
FFmpegThumbnailsConvertorPP, FFmpegThumbnailsConvertorPP,
FFmpegVideoConvertorPP, FFmpegVideoConvertorPP,
@@ -907,11 +902,6 @@ def _real_main(argv=None):
if print_extractor_information(opts, all_urls): if print_extractor_information(opts, all_urls):
return 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: with YoutubeDL(ydl_opts) as ydl:
pre_process = opts.update_self or opts.rm_cachedir pre_process = opts.update_self or opts.rm_cachedir
actual_use = all_urls or opts.load_info_filename actual_use = all_urls or opts.load_info_filename

View File

@@ -3,6 +3,7 @@ import sys
import warnings import warnings
import xml.etree.ElementTree as etree import xml.etree.ElementTree as etree
from . import re
from ._deprecated import * # noqa: F401, F403 from ._deprecated import * # noqa: F401, F403
from .compat_utils import passthrough_module from .compat_utils import passthrough_module
@@ -32,7 +33,6 @@ compat_os_name = os._name if os.name == 'java' else os.name
if compat_os_name == 'nt': if compat_os_name == 'nt':
def compat_shlex_quote(s): 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"' % s.replace('"', '\\"')
else: else:
from shlex import quote as compat_shlex_quote # noqa: F401 from shlex import quote as compat_shlex_quote # noqa: F401

View File

@@ -22,14 +22,10 @@ import urllib.request
import xml.etree.ElementTree as etree import xml.etree.ElementTree as etree
from subprocess import DEVNULL from subprocess import DEVNULL
# isort: split from .compat_utils import passthrough_module # isort: split
import asyncio # noqa: F401 from .asyncio import run as compat_asyncio_run # noqa: F401
import re # noqa: F401 from .re import Pattern as compat_Pattern # noqa: F401
from asyncio import run as compat_asyncio_run # noqa: F401 from .re import match as compat_Match # noqa: F401
from re import Pattern as compat_Pattern # noqa: F401
from re import match as compat_Match # noqa: F401
from .compat_utils import passthrough_module
from ..dependencies import Cryptodome_AES as compat_pycrypto_AES # noqa: F401 from ..dependencies import Cryptodome_AES as compat_pycrypto_AES # noqa: F401
from ..dependencies import brotli as compat_brotli # noqa: F401 from ..dependencies import brotli as compat_brotli # noqa: F401
from ..dependencies import websockets as compat_websockets # noqa: F401 from ..dependencies import websockets as compat_websockets # noqa: F401

23
yt_dlp/compat/asyncio.py Normal file
View File

@@ -0,0 +1,23 @@
# flake8: noqa: F405
from asyncio import * # noqa: F403
from .compat_utils import passthrough_module
passthrough_module(__name__, 'asyncio')
del passthrough_module
try:
run # >= 3.7
except NameError:
def run(coro):
try:
loop = get_event_loop()
except RuntimeError:
loop = new_event_loop()
set_event_loop(loop)
loop.run_until_complete(coro)
try:
all_tasks # >= 3.7
except NameError:
all_tasks = Task.all_tasks

18
yt_dlp/compat/re.py Normal file
View File

@@ -0,0 +1,18 @@
# flake8: noqa: F405
from re import * # F403
from .compat_utils import passthrough_module
passthrough_module(__name__, 're')
del passthrough_module
try:
Pattern # >= 3.7
except NameError:
Pattern = type(compile(''))
try:
Match # >= 3.7
except NameError:
Match = type(compile('').match(''))

View File

@@ -1,4 +1,3 @@
import asyncio
import contextlib import contextlib
import os import os
import signal import signal
@@ -6,6 +5,7 @@ import threading
from .common import FileDownloader from .common import FileDownloader
from .external import FFmpegFD from .external import FFmpegFD
from ..compat import asyncio
from ..dependencies import websockets from ..dependencies import websockets

View File

@@ -11,7 +11,6 @@ import math
import netrc import netrc
import os import os
import random import random
import re
import sys import sys
import time import time
import types import types
@@ -19,7 +18,7 @@ import urllib.parse
import urllib.request import urllib.request
import xml.etree.ElementTree import xml.etree.ElementTree
from ..compat import functools # isort: split from ..compat import functools, re # isort: split
from ..compat import compat_etree_fromstring, compat_expanduser, compat_os_name from ..compat import compat_etree_fromstring, compat_expanduser, compat_os_name
from ..downloader import FileDownloader from ..downloader import FileDownloader
from ..downloader.f4m import get_base_url, remove_encrypted_media from ..downloader.f4m import get_base_url, remove_encrypted_media

View File

@@ -1,5 +1,4 @@
import collections import collections
import contextvars
import itertools import itertools
import json import json
import os import os
@@ -83,8 +82,6 @@ class FFmpegPostProcessorError(PostProcessingError):
class FFmpegPostProcessor(PostProcessor): class FFmpegPostProcessor(PostProcessor):
_ffmpeg_location = contextvars.ContextVar('ffmpeg_location', default=None)
def __init__(self, downloader=None): def __init__(self, downloader=None):
PostProcessor.__init__(self, downloader) PostProcessor.__init__(self, downloader)
self._prefer_ffmpeg = self.get_param('prefer_ffmpeg', True) self._prefer_ffmpeg = self.get_param('prefer_ffmpeg', True)
@@ -104,7 +101,7 @@ class FFmpegPostProcessor(PostProcessor):
def _determine_executables(self): def _determine_executables(self):
programs = [*self._ffmpeg_to_avconv.keys(), *self._ffmpeg_to_avconv.values()] 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: if location is None:
return {p: p for p in programs} return {p: p for p in programs}

View File

@@ -1,4 +1,3 @@
import asyncio
import atexit import atexit
import base64 import base64
import binascii import binascii
@@ -47,7 +46,7 @@ import urllib.request
import xml.etree.ElementTree import xml.etree.ElementTree
import zlib import zlib
from .compat import functools # isort: split from .compat import asyncio, functools # isort: split
from .compat import ( from .compat import (
compat_etree_fromstring, compat_etree_fromstring,
compat_expanduser, compat_expanduser,

View File

@@ -1,6 +1,6 @@
# Autogenerated by devscripts/update-version.py # Autogenerated by devscripts/update-version.py
__version__ = '2022.08.19' __version__ = '2022.08.18.36'
RELEASE_GIT_HEAD = '48c88e088' RELEASE_GIT_HEAD = '48c88e088'

View File

@@ -9,8 +9,8 @@ in RFC 8216 §3.5 <https://tools.ietf.org/html/rfc8216#section-3.5>.
""" """
import io import io
import re
from .compat import re
from .utils import int_or_none, timetuple_from_msec from .utils import int_or_none, timetuple_from_msec