Add support for yt-dlp with NodeJS
This commit is contained in:
15
Dockerfile
15
Dockerfile
@@ -4,7 +4,20 @@ FROM python:3.11-slim-bookworm
|
|||||||
RUN sed -i 's|deb.debian.org|mirror.yandex.ru|g' /etc/apt/sources.list.d/debian.sources \
|
RUN sed -i 's|deb.debian.org|mirror.yandex.ru|g' /etc/apt/sources.list.d/debian.sources \
|
||||||
&& apt-get update
|
&& apt-get update
|
||||||
|
|
||||||
RUN apt-get install -y ffmpeg
|
# Установка Node.js для JS обработчика yt-dlp (требуется для Instagram, TikTok и других сайтов)
|
||||||
|
# Используем официальный установочный скрипт NodeSource
|
||||||
|
RUN apt-get install -y curl ca-certificates \
|
||||||
|
&& curl -fsSL https://deb.nodesource.com/setup_20.x | bash - \
|
||||||
|
&& apt-get install -y nodejs \
|
||||||
|
&& apt-get clean \
|
||||||
|
&& rm -rf /var/lib/apt/lists/* \
|
||||||
|
&& node --version \
|
||||||
|
&& npm --version
|
||||||
|
|
||||||
|
# Установка ffmpeg для обработки видео
|
||||||
|
RUN apt-get update && apt-get install -y ffmpeg \
|
||||||
|
&& apt-get clean \
|
||||||
|
&& rm -rf /var/lib/apt/lists/*
|
||||||
|
|
||||||
# Создание рабочей директории
|
# Создание рабочей директории
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
|
|||||||
@@ -158,6 +158,19 @@ async def download_media(
|
|||||||
'ignoreerrors': False,
|
'ignoreerrors': False,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Check if Node.js is available for JS extraction (required for Instagram, TikTok, etc.)
|
||||||
|
import shutil
|
||||||
|
nodejs_path = shutil.which('node')
|
||||||
|
if nodejs_path:
|
||||||
|
logger.debug(f"Node.js found at: {nodejs_path}. JS extraction will be available.")
|
||||||
|
# yt-dlp will automatically use Node.js if available
|
||||||
|
# Optionally, we can explicitly set it via extractor_args if needed
|
||||||
|
else:
|
||||||
|
logger.warning(
|
||||||
|
"Node.js not found. Some sites (Instagram, TikTok, etc.) may require JS extraction. "
|
||||||
|
"Install Node.js for full functionality."
|
||||||
|
)
|
||||||
|
|
||||||
# Add cookies if specified (for Instagram and other sites)
|
# Add cookies if specified (for Instagram and other sites)
|
||||||
if cookies_file:
|
if cookies_file:
|
||||||
# Resolve cookies file path (support relative and absolute paths)
|
# Resolve cookies file path (support relative and absolute paths)
|
||||||
|
|||||||
Reference in New Issue
Block a user