diff --git a/tubesync/upgrade_yt-dlp.sh b/tubesync/upgrade_yt-dlp.sh new file mode 100755 index 00000000..9da6d555 --- /dev/null +++ b/tubesync/upgrade_yt-dlp.sh @@ -0,0 +1,38 @@ +#!/usr/bin/env bash + +warning_message() { + cat <&2 + +pip3() { + local pip_runner pip_whl run_whl + + # pipenv + pip_runner='/usr/lib/python3/dist-packages/pipenv/patched/pip/__pip-runner__.py' + test -s "${pip_runner}" || pip_runner='' + + # python3-pip-whl + pip_whl="$(ls -1r /usr/share/python-wheels/pip-*-py3-none-any.whl | head -n 1)" + run_whl="${pip_whl}/pip" + + python3 "${pip_runner:-"${run_whl}"}" "$@" +} + +warning_message +test -n "${TUBESYNC_DEBUG}" || exit 1 + +# Use the flag added in 23.0.1, if possible. +# https://github.com/pypa/pip/pull/11780 +break_system_packages='--break-system-packages' +pip_version="$(pip3 --version | awk '$1 = "pip" { print $2; exit; }')" +if [[ "${pip_version}" < "23.0.1" ]]; then + break_system_packages='' +fi + +pip3 install --upgrade ${break_system_packages} yt-dlp +