Add yt-dlp wrapper to keep it in sync with user installed yt-dlp. Ref #469

This commit is contained in:
arabcoders 2025-11-01 17:22:16 +03:00
parent f140b598f9
commit 44fd225ab1
3 changed files with 55 additions and 10 deletions

View file

@ -57,12 +57,10 @@ RUN mkdir /config /downloads && ln -snf /usr/share/zoneinfo/${TZ} /etc/localtime
sed -i -e 's/# en_US.UTF-8 UTF-8/en_US.UTF-8 UTF-8/' /etc/locale.gen && \
dpkg-reconfigure --frontend=noninteractive locales && \
update-locale LANG=en_US.UTF-8 \
&& rm -rf /var/lib/apt/lists/*
mkdir -p /opt/bin && rm -rf /var/lib/apt/lists/*
COPY entrypoint.sh /
RUN sed -i 's/\r$//g' /entrypoint.sh && chmod +x /entrypoint.sh
COPY --chown=app:app yt-dlp /opt/bin/yt-dlp
COPY --chown=app:app ./app /app/app
COPY --chown=app:app --from=node_builder /app/exported /app/ui/exported
COPY --chown=app:app --from=python_builder /opt/python /opt/python
@ -72,13 +70,13 @@ COPY --from=ghcr.io/arabcoders/jellyfin-ffmpeg /usr/bin/ffprobe /usr/bin/ffprobe
COPY --from=denoland/deno:latest /usr/bin/deno /usr/bin/deno
COPY --chown=app:app ./healthcheck.sh /usr/local/bin/healthcheck
ENV PATH="/opt/python/bin:$PATH"
ENV PATH="/opt/bin:/opt/python/bin:$PATH"
ENV LANG=en_US.UTF-8
ENV LANGUAGE=en_US:en
ENV LC_ALL=en_US.UTF-8
RUN chown -R app:app /config /downloads && \
chmod +x /usr/local/bin/healthcheck /usr/bin/mp4box /usr/bin/ffmpeg /usr/bin/ffprobe /usr/bin/deno
RUN sed -i 's/\r$//g' /entrypoint.sh && chmod +x /entrypoint.sh && chown -R app:app /config /downloads && \
chmod +x /usr/local/bin/healthcheck /usr/bin/mp4box /usr/bin/ffmpeg /usr/bin/ffprobe /usr/bin/deno /opt/bin/yt-dlp
VOLUME /config
VOLUME /downloads

View file

@ -110,10 +110,13 @@ class PackageInstaller:
str(self.user_site),
]
if "yt_dlp" == pkg:
pkg = "yt-dlp"
if version:
if "nightly" == version and pkg == "yt_dlp":
if "nightly" == version and pkg == "yt-dlp":
cmd.extend(["--pre", "yt-dlp[default]"])
elif "master" == version and pkg == "yt_dlp":
elif "master" == version and pkg == "yt-dlp":
cmd.append("git+https://github.com/yt-dlp/yt-dlp.git@master")
else:
cmd.append(version if str(version).startswith("git+") else f"{pkg}=={version}")
@ -179,7 +182,7 @@ class PackageInstaller:
return False
def out(self, out: bytes | str | None = None, err=bytes | str | None) -> None:
def out(self, out: bytes | str | None = None, err: bytes | str | None = None) -> None:
if out:
for line in (line.strip() for line in out.strip().splitlines() if line.strip()):
LOG.info(line.decode() if isinstance(line, bytes) else line)

44
yt-dlp Executable file
View file

@ -0,0 +1,44 @@
#!/usr/bin/env bash
###########
# Set PATH to include user installed packages
PY_BASE_VERSION=$(/opt/python/bin/python -V 2>&1 | awk '{print $2}' | cut -d. -f1,2)
CONFIG_PATH="${YTP_CONFIG_PATH:-/app/var/config}"
USER_SITE="${CONFIG_PATH}/python${PY_BASE_VERSION}-packages"
USER_SITE_BIN="${USER_SITE}/bin"
if [ -d "${USER_SITE_BIN}" ]; then
case ":${PATH}:" in
*:"${USER_SITE_BIN}":*)
;;
*)
if [ -n "${PATH}" ]; then
PATH="${USER_SITE_BIN}:${PATH}"
else
PATH="${USER_SITE_BIN}"
fi
;;
esac
export PATH
fi
if [ -d "${USER_SITE}" ]; then
case ":${PYTHONPATH}:" in
*:"${USER_SITE}":*)
;;
*)
if [ -n "${PYTHONPATH}" ]; then
PYTHONPATH="${USER_SITE}:${PYTHONPATH}"
else
PYTHONPATH="${USER_SITE}"
fi
;;
esac
export PYTHONPATH
fi
# Execute yt-dlp with passed arguments
exec /opt/python/bin/python -m yt_dlp "${@}"