mirror of
https://github.com/yt-dlp/yt-dlp.git
synced 2024-12-22 01:56:30 -05:00
parent
115add4387
commit
70b2340909
1
.github/workflows/build.yml
vendored
1
.github/workflows/build.yml
vendored
@ -89,6 +89,7 @@ jobs:
|
|||||||
if: "env.TWINE_PASSWORD != ''"
|
if: "env.TWINE_PASSWORD != ''"
|
||||||
run: |
|
run: |
|
||||||
rm -rf dist/*
|
rm -rf dist/*
|
||||||
|
python devscripts/set-variant.py pip -M "You installed yt-dlp with pip or using the wheel from PyPi; Use that to update"
|
||||||
python setup.py sdist bdist_wheel
|
python setup.py sdist bdist_wheel
|
||||||
twine upload dist/*
|
twine upload dist/*
|
||||||
|
|
||||||
|
@ -343,7 +343,8 @@ If you wish to build it anyway, install Python and py2exe, and then simply run `
|
|||||||
|
|
||||||
### Related scripts
|
### Related scripts
|
||||||
|
|
||||||
* **`devscripts/update-version.py`** - Update the version number based on current timestamp
|
* **`devscripts/update-version.py [revision]`** - Update the version number based on current date
|
||||||
|
* **`devscripts/set-variant.py variant [-M update_message]`** - Set the build variant of the executable
|
||||||
* **`devscripts/make_lazy_extractors.py`** - Create lazy extractors. Running this before building the binaries (any variant) will improve their startup performance. Set the environment variable `YTDLP_NO_LAZY_EXTRACTORS=1` if you wish to forcefully disable lazy extractor loading.
|
* **`devscripts/make_lazy_extractors.py`** - Create lazy extractors. Running this before building the binaries (any variant) will improve their startup performance. Set the environment variable `YTDLP_NO_LAZY_EXTRACTORS=1` if you wish to forcefully disable lazy extractor loading.
|
||||||
|
|
||||||
You can also fork the project on github and run your fork's [build workflow](.github/workflows/build.yml) to automatically build a full release
|
You can also fork the project on github and run your fork's [build workflow](.github/workflows/build.yml) to automatically build a full release
|
||||||
@ -360,8 +361,8 @@ You can also fork the project on github and run your fork's [build workflow](.gi
|
|||||||
## General Options:
|
## General Options:
|
||||||
-h, --help Print this help text and exit
|
-h, --help Print this help text and exit
|
||||||
--version Print program version and exit
|
--version Print program version and exit
|
||||||
-U, --update Update this program to latest version
|
-U, --update Update this program to the latest version
|
||||||
--no-update Do not update (default)
|
--no-update Do not check for updates (default)
|
||||||
-i, --ignore-errors Ignore download and postprocessing errors.
|
-i, --ignore-errors Ignore download and postprocessing errors.
|
||||||
The download will be considered successful
|
The download will be considered successful
|
||||||
even if the postprocessing fails
|
even if the postprocessing fails
|
||||||
|
@ -45,6 +45,10 @@ switch_col_width = len(re.search(r'(?m)^\s{5,}', options).group())
|
|||||||
delim = f'\n{" " * switch_col_width}'
|
delim = f'\n{" " * switch_col_width}'
|
||||||
|
|
||||||
PATCHES = (
|
PATCHES = (
|
||||||
|
( # Standardize update message
|
||||||
|
r'(?m)^( -U, --update\s+).+(\n \s.+)*$',
|
||||||
|
r'\1Update this program to the latest version',
|
||||||
|
),
|
||||||
( # Headings
|
( # Headings
|
||||||
r'(?m)^ (\w.+\n)( (?=\w))?',
|
r'(?m)^ (\w.+\n)( (?=\w))?',
|
||||||
r'## \1'
|
r'## \1'
|
||||||
|
36
devscripts/set-variant.py
Normal file
36
devscripts/set-variant.py
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
#!/usr/bin/env python3
|
||||||
|
|
||||||
|
# Allow direct execution
|
||||||
|
import os
|
||||||
|
import sys
|
||||||
|
|
||||||
|
sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
|
||||||
|
|
||||||
|
|
||||||
|
import argparse
|
||||||
|
import functools
|
||||||
|
import re
|
||||||
|
|
||||||
|
from devscripts.utils import compose_functions, read_file, write_file
|
||||||
|
|
||||||
|
VERSION_FILE = 'yt_dlp/version.py'
|
||||||
|
|
||||||
|
|
||||||
|
def parse_options():
|
||||||
|
parser = argparse.ArgumentParser(description='Set the build variant of the package')
|
||||||
|
parser.add_argument('variant', help='Name of the variant')
|
||||||
|
parser.add_argument('-M', '--update-message', default=None, help='Message to show in -U')
|
||||||
|
return parser.parse_args()
|
||||||
|
|
||||||
|
|
||||||
|
def property_setter(name, value):
|
||||||
|
return functools.partial(re.sub, rf'(?m)^{name}\s*=\s*.+$', f'{name} = {value!r}')
|
||||||
|
|
||||||
|
|
||||||
|
opts = parse_options()
|
||||||
|
transform = compose_functions(
|
||||||
|
property_setter('VARIANT', opts.variant),
|
||||||
|
property_setter('UPDATE_HINT', opts.update_message)
|
||||||
|
)
|
||||||
|
|
||||||
|
write_file(VERSION_FILE, transform(read_file(VERSION_FILE)))
|
@ -43,6 +43,10 @@ VERSION_FILE = f'''\
|
|||||||
__version__ = {VERSION!r}
|
__version__ = {VERSION!r}
|
||||||
|
|
||||||
RELEASE_GIT_HEAD = {GIT_HEAD!r}
|
RELEASE_GIT_HEAD = {GIT_HEAD!r}
|
||||||
|
|
||||||
|
VARIANT = None
|
||||||
|
|
||||||
|
UPDATE_HINT = None
|
||||||
'''
|
'''
|
||||||
|
|
||||||
write_file('yt_dlp/version.py', VERSION_FILE)
|
write_file('yt_dlp/version.py', VERSION_FILE)
|
||||||
|
@ -144,7 +144,7 @@ from .utils import (
|
|||||||
write_json_file,
|
write_json_file,
|
||||||
write_string,
|
write_string,
|
||||||
)
|
)
|
||||||
from .version import RELEASE_GIT_HEAD, __version__
|
from .version import RELEASE_GIT_HEAD, VARIANT, __version__
|
||||||
|
|
||||||
if compat_os_name == 'nt':
|
if compat_os_name == 'nt':
|
||||||
import ctypes
|
import ctypes
|
||||||
@ -3676,6 +3676,8 @@ class YoutubeDL:
|
|||||||
write_debug = lambda msg: self._write_string(f'[debug] {msg}\n')
|
write_debug = lambda msg: self._write_string(f'[debug] {msg}\n')
|
||||||
|
|
||||||
source = detect_variant()
|
source = detect_variant()
|
||||||
|
if VARIANT not in (None, 'pip'):
|
||||||
|
source += '*'
|
||||||
write_debug(join_nonempty(
|
write_debug(join_nonempty(
|
||||||
'yt-dlp version', __version__,
|
'yt-dlp version', __version__,
|
||||||
f'[{RELEASE_GIT_HEAD}]' if RELEASE_GIT_HEAD else '',
|
f'[{RELEASE_GIT_HEAD}]' if RELEASE_GIT_HEAD else '',
|
||||||
|
@ -20,12 +20,13 @@ from .postprocessor import (
|
|||||||
SponsorBlockPP,
|
SponsorBlockPP,
|
||||||
)
|
)
|
||||||
from .postprocessor.modify_chapters import DEFAULT_SPONSORBLOCK_CHAPTER_TITLE
|
from .postprocessor.modify_chapters import DEFAULT_SPONSORBLOCK_CHAPTER_TITLE
|
||||||
from .update import detect_variant
|
from .update import detect_variant, is_non_updateable
|
||||||
from .utils import (
|
from .utils import (
|
||||||
OUTTMPL_TYPES,
|
OUTTMPL_TYPES,
|
||||||
POSTPROCESS_WHEN,
|
POSTPROCESS_WHEN,
|
||||||
Config,
|
Config,
|
||||||
expand_path,
|
expand_path,
|
||||||
|
format_field,
|
||||||
get_executable_path,
|
get_executable_path,
|
||||||
join_nonempty,
|
join_nonempty,
|
||||||
remove_end,
|
remove_end,
|
||||||
@ -333,11 +334,13 @@ def create_parser():
|
|||||||
general.add_option(
|
general.add_option(
|
||||||
'-U', '--update',
|
'-U', '--update',
|
||||||
action='store_true', dest='update_self',
|
action='store_true', dest='update_self',
|
||||||
help='Update this program to latest version')
|
help=format_field(
|
||||||
|
is_non_updateable(), None, 'Check if updates are available. %s',
|
||||||
|
default='Update this program to the latest version'))
|
||||||
general.add_option(
|
general.add_option(
|
||||||
'--no-update',
|
'--no-update',
|
||||||
action='store_false', dest='update_self',
|
action='store_false', dest='update_self',
|
||||||
help='Do not update (default)')
|
help='Do not check for updates (default)')
|
||||||
general.add_option(
|
general.add_option(
|
||||||
'-i', '--ignore-errors',
|
'-i', '--ignore-errors',
|
||||||
action='store_true', dest='ignoreerrors',
|
action='store_true', dest='ignoreerrors',
|
||||||
|
@ -18,7 +18,7 @@ from .utils import (
|
|||||||
traverse_obj,
|
traverse_obj,
|
||||||
version_tuple,
|
version_tuple,
|
||||||
)
|
)
|
||||||
from .version import __version__
|
from .version import UPDATE_HINT, VARIANT, __version__
|
||||||
|
|
||||||
REPOSITORY = 'yt-dlp/yt-dlp'
|
REPOSITORY = 'yt-dlp/yt-dlp'
|
||||||
API_URL = f'https://api.github.com/repos/{REPOSITORY}/releases'
|
API_URL = f'https://api.github.com/repos/{REPOSITORY}/releases'
|
||||||
@ -47,7 +47,7 @@ def _get_variant_and_executable_path():
|
|||||||
|
|
||||||
|
|
||||||
def detect_variant():
|
def detect_variant():
|
||||||
return _get_variant_and_executable_path()[0]
|
return VARIANT or _get_variant_and_executable_path()[0]
|
||||||
|
|
||||||
|
|
||||||
_FILE_SUFFIXES = {
|
_FILE_SUFFIXES = {
|
||||||
@ -64,13 +64,16 @@ _NON_UPDATEABLE_REASONS = {
|
|||||||
**{variant: f'Auto-update is not supported for unpackaged {name} executable; Re-download the latest release'
|
**{variant: f'Auto-update is not supported for unpackaged {name} executable; Re-download the latest release'
|
||||||
for variant, name in {'win32_dir': 'Windows', 'darwin_dir': 'MacOS', 'linux_dir': 'Linux'}.items()},
|
for variant, name in {'win32_dir': 'Windows', 'darwin_dir': 'MacOS', 'linux_dir': 'Linux'}.items()},
|
||||||
'source': 'You cannot update when running from source code; Use git to pull the latest changes',
|
'source': 'You cannot update when running from source code; Use git to pull the latest changes',
|
||||||
'unknown': 'It looks like you installed yt-dlp with a package manager, pip or setup.py; Use that to update',
|
'unknown': 'You installed yt-dlp with a package manager or setup.py; Use that to update',
|
||||||
'other': 'It looks like you are using an unofficial build of yt-dlp; Build the executable again',
|
'other': 'You are using an unofficial build of yt-dlp; Build the executable again',
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
def is_non_updateable():
|
def is_non_updateable():
|
||||||
return _NON_UPDATEABLE_REASONS.get(detect_variant(), _NON_UPDATEABLE_REASONS['other'])
|
if UPDATE_HINT:
|
||||||
|
return UPDATE_HINT
|
||||||
|
return _NON_UPDATEABLE_REASONS.get(
|
||||||
|
detect_variant(), _NON_UPDATEABLE_REASONS['unknown' if VARIANT else 'other'])
|
||||||
|
|
||||||
|
|
||||||
def _sha256_file(path):
|
def _sha256_file(path):
|
||||||
|
@ -3,3 +3,7 @@
|
|||||||
__version__ = '2022.07.18'
|
__version__ = '2022.07.18'
|
||||||
|
|
||||||
RELEASE_GIT_HEAD = '135f05ef6'
|
RELEASE_GIT_HEAD = '135f05ef6'
|
||||||
|
|
||||||
|
VARIANT = None
|
||||||
|
|
||||||
|
UPDATE_HINT = None
|
||||||
|
Loading…
Reference in New Issue
Block a user