Skip to content

Instantly share code, notes, and snippets.

@Darkflib
Created August 31, 2023 12:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Darkflib/5734441b1b921476341090c0e18a05ab to your computer and use it in GitHub Desktop.
Save Darkflib/5734441b1b921476341090c0e18a05ab to your computer and use it in GitHub Desktop.
quick and dirty yt-dlp worker to use yt-dlp through a VPN to avoid getting your IP blocked. Note: the yt-dlp container is hardcoded to use an archive file and a batchfile...
version: "3.8"
services:
gluetun:
image: qmcgaw/gluetun
container_name: gluetun
# container_name: gluetun
# line above must be uncommented to allow external containers to connect.
# See https://github.com/qdm12/gluetun-wiki/blob/main/setup/connect-a-container-to-gluetun.md#external-container-to-gluetun
cap_add:
- NET_ADMIN
devices:
- /dev/net/tun:/dev/net/tun
ports:
- 8888:8888/tcp # HTTP proxy
- 8388:8388/tcp # Shadowsocks
- 8388:8388/udp # Shadowsocks
volumes:
- ./gluetun:/gluetun
environment:
# See https://github.com/qdm12/gluetun-wiki/tree/main/setup#setup
- VPN_SERVICE_PROVIDER=myspecialvpn
- VPN_TYPE=wireguard
- SERVER_COUNTRIES=Sweden
- FIREWALL_VPN_INPUT_PORTS=12345 # Not actually required here, but I like copy/paste
# OpenVPN:
#- OPENVPN_USER=
#- OPENVPN_PASSWORD=
# Wireguard:
- WIREGUARD_PRIVATE_KEY=0123456789abcdefghjklm+/123456789=
- WIREGUARD_ADDRESSES=10.1.2.3/32
- WIREGUARD_PRESHARED_KEY=ILikemesomerandombase64+/=
# Timezone for accurate log times
- TZ=UTC
# Server list updater
# See https://github.com/qdm12/gluetun-wiki/blob/main/setup/servers.md#update-the-vpn-servers-list
- UPDATER_PERIOD=24h
yt-dlp:
container_name: yt-dlp
image: yt_dlp
volumes:
- /mnt/data/yt:/data
# /data is configured by default as the dl directory, the archive.log and the download.txt files location
# Use Python 3.10 as the base image
FROM python:3.10
# Install FFmpeg
RUN apt-get update && \
apt-get install -y ffmpeg && \
rm -rf /var/lib/apt/lists/*
# Install yt-dlp via pip
RUN pip install yt-dlp
# Create a new user 'appuser' to run the container as non-root
RUN useradd -ms /bin/bash appuser
# Switch to the new user
USER appuser
# Set the default working directory
WORKDIR /data
# Set default command to run yt-dlp with provided arguments
CMD ["yt-dlp", "--download-archive", "/data/archive.log", "--restrict-filenames", "-P", "/data", "--batch-file", "/data/download.txt", "--add-metadata", "--cache-dir", "/data/cache", "--embed-thumbnail", "--progress", "--sub-langs", "en", "--embed-subs", "--embed-chapters"]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment