aboutsummaryrefslogtreecommitdiffstats
path: root/yt_dlp
diff options
context:
space:
mode:
authorpukkandan <pukkandan.ytdlp@gmail.com>2022-07-29 20:33:01 +0530
committerpukkandan <pukkandan.ytdlp@gmail.com>2022-08-09 01:08:48 +0530
commit70b2340909d8d917f71d20181614fd7392d3f7f0 (patch)
tree9836125a25c94260c99040cb4d73f302257bd924 /yt_dlp
parent115add43876964956917bf596c1d0b148c5b3c26 (diff)
downloadhypervideo-pre-70b2340909d8d917f71d20181614fd7392d3f7f0.tar.lz
hypervideo-pre-70b2340909d8d917f71d20181614fd7392d3f7f0.tar.xz
hypervideo-pre-70b2340909d8d917f71d20181614fd7392d3f7f0.zip
[build, devscripts] Add devscript to set a build variant
Closes #4471
Diffstat (limited to 'yt_dlp')
-rw-r--r--yt_dlp/YoutubeDL.py4
-rw-r--r--yt_dlp/options.py9
-rw-r--r--yt_dlp/update.py13
-rw-r--r--yt_dlp/version.py4
4 files changed, 21 insertions, 9 deletions
diff --git a/yt_dlp/YoutubeDL.py b/yt_dlp/YoutubeDL.py
index ded34b8ed..228aa7bf5 100644
--- a/yt_dlp/YoutubeDL.py
+++ b/yt_dlp/YoutubeDL.py
@@ -144,7 +144,7 @@ from .utils import (
write_json_file,
write_string,
)
-from .version import RELEASE_GIT_HEAD, __version__
+from .version import RELEASE_GIT_HEAD, VARIANT, __version__
if compat_os_name == 'nt':
import ctypes
@@ -3676,6 +3676,8 @@ class YoutubeDL:
write_debug = lambda msg: self._write_string(f'[debug] {msg}\n')
source = detect_variant()
+ if VARIANT not in (None, 'pip'):
+ source += '*'
write_debug(join_nonempty(
'yt-dlp version', __version__,
f'[{RELEASE_GIT_HEAD}]' if RELEASE_GIT_HEAD else '',
diff --git a/yt_dlp/options.py b/yt_dlp/options.py
index b70f5798e..2c7f686dd 100644
--- a/yt_dlp/options.py
+++ b/yt_dlp/options.py
@@ -20,12 +20,13 @@ from .postprocessor import (
SponsorBlockPP,
)
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 (
OUTTMPL_TYPES,
POSTPROCESS_WHEN,
Config,
expand_path,
+ format_field,
get_executable_path,
join_nonempty,
remove_end,
@@ -333,11 +334,13 @@ def create_parser():
general.add_option(
'-U', '--update',
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(
'--no-update',
action='store_false', dest='update_self',
- help='Do not update (default)')
+ help='Do not check for updates (default)')
general.add_option(
'-i', '--ignore-errors',
action='store_true', dest='ignoreerrors',
diff --git a/yt_dlp/update.py b/yt_dlp/update.py
index 92c07acc1..a04518c9b 100644
--- a/yt_dlp/update.py
+++ b/yt_dlp/update.py
@@ -18,7 +18,7 @@ from .utils import (
traverse_obj,
version_tuple,
)
-from .version import __version__
+from .version import UPDATE_HINT, VARIANT, __version__
REPOSITORY = 'yt-dlp/yt-dlp'
API_URL = f'https://api.github.com/repos/{REPOSITORY}/releases'
@@ -47,7 +47,7 @@ def _get_variant_and_executable_path():
def detect_variant():
- return _get_variant_and_executable_path()[0]
+ return VARIANT or _get_variant_and_executable_path()[0]
_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'
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',
- 'unknown': 'It looks like you installed yt-dlp with a package manager, pip or setup.py; Use that to update',
- 'other': 'It looks like you are using an unofficial build of yt-dlp; Build the executable again',
+ 'unknown': 'You installed yt-dlp with a package manager or setup.py; Use that to update',
+ 'other': 'You are using an unofficial build of yt-dlp; Build the executable again',
}
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):
diff --git a/yt_dlp/version.py b/yt_dlp/version.py
index a1a5880e9..75ede4973 100644
--- a/yt_dlp/version.py
+++ b/yt_dlp/version.py
@@ -3,3 +3,7 @@
__version__ = '2022.07.18'
RELEASE_GIT_HEAD = '135f05ef6'
+
+VARIANT = None
+
+UPDATE_HINT = None