Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
.git/
__pycache__/
*.pyc
*.pyo
*.wvd
cookies.txt
*.egg-info/
dist/
build/
.venv/
venv/
.env
.claude/
Apple Music/
76 changes: 76 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
FROM python:3.11-slim AS builder

WORKDIR /build
RUN pip install --no-cache-dir --user gamdl

# Build Bento4 from source
FROM python:3.11-slim AS bento4-builder

RUN apt-get update && apt-get install -y --no-install-recommends \
git \
cmake \
make \
g++ \
&& rm -rf /var/lib/apt/lists/*

RUN git clone --depth 1 https://github.com/axiomatic-systems/Bento4.git /tmp/bento4 && \
cd /tmp/bento4 && \
mkdir build && cd build && \
cmake -DCMAKE_BUILD_TYPE=Release .. && \
make mp4decrypt && \
cp mp4decrypt /usr/local/bin/

# Build GPAC (MP4Box) from source
FROM python:3.11-slim AS gpac-builder

RUN apt-get update && apt-get install -y --no-install-recommends \
git \
build-essential \
pkg-config \
zlib1g-dev \
&& rm -rf /var/lib/apt/lists/*

RUN git clone --depth 1 https://github.com/gpac/gpac.git /tmp/gpac && \
cd /tmp/gpac && \
./configure --static-bin && \
make -j$(nproc) && \
cp bin/gcc/MP4Box /usr/local/bin/

FROM python:3.11-slim

# Install FFmpeg, libicu (for N_m3u8DL-RE), and other dependencies
RUN apt-get update && apt-get install -y --no-install-recommends \
ffmpeg \
curl \
ca-certificates \
libicu76 \
jq \
&& rm -rf /var/lib/apt/lists/*

# Copy mp4decrypt from builder
COPY --from=bento4-builder /usr/local/bin/mp4decrypt /usr/local/bin/

# Copy MP4Box from builder
COPY --from=gpac-builder /usr/local/bin/MP4Box /usr/local/bin/

# Download N_m3u8DL-RE - architecture aware, fetches latest release
RUN ARCH=$(dpkg --print-architecture) && \
if [ "$ARCH" = "amd64" ]; then \
N_M3U8_ARCH="linux-x64"; \
elif [ "$ARCH" = "arm64" ]; then \
N_M3U8_ARCH="linux-arm64"; \
else \
echo "Unsupported architecture: $ARCH" && exit 1; \
fi && \
DOWNLOAD_URL=$(curl -s https://api.github.com/repos/nilaoda/N_m3u8DL-RE/releases/latest | jq -r ".assets[] | select(.name | contains(\"${N_M3U8_ARCH}\") and (contains(\"musl\") | not)) | .browser_download_url") && \
curl -L "$DOWNLOAD_URL" -o /tmp/nm3u8.tar.gz && \
tar -xzf /tmp/nm3u8.tar.gz -C /usr/local/bin/ && \
chmod +x /usr/local/bin/N_m3u8DL-RE && \
rm /tmp/nm3u8.tar.gz

# Copy Python packages from builder
COPY --from=builder /root/.local /root/.local
ENV PATH=/root/.local/bin:$PATH

WORKDIR /app
ENTRYPOINT ["gamdl"]
44 changes: 44 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,50 @@ pip install gamdl
1. Place your cookies file in the working directory as `cookies.txt`, or
2. Specify the path using `--cookies-path` or in the config file

## 🐳 Docker

Run gamdl via Docker with all external binaries pre-installed (FFmpeg, mp4decrypt, MP4Box, N_m3u8DL-RE).

**Build the image:**

```bash
docker build -t gamdl .
```

**Basic usage:**

```bash
docker run --rm \
-v /path/to/cookies.txt:/app/cookies.txt:ro \
-v /path/to/output:/app/music \
gamdl --cookies-path /app/cookies.txt --output-path /app/music "https://music.apple.com/..."
```

**With config persistence:**

```bash
docker run --rm \
-v /path/to/cookies.txt:/app/cookies.txt:ro \
-v /path/to/output:/app/music \
-v /path/to/config:/root/.gamdl \
gamdl --cookies-path /app/cookies.txt --output-path /app/music "https://music.apple.com/..."
```

**Using N_m3u8DL-RE downloader:**

```bash
docker run --rm \
-v ./cookies.txt:/app/cookies.txt:ro \
-v ./music:/app/music \
gamdl --cookies-path /app/cookies.txt --output-path /app/music --download-mode nm3u8dlre "https://music.apple.com/..."
```

| Volume Mount | Purpose | Mode |
|--------------|---------|------|
| `/app/cookies.txt` | Apple Music cookies | read-only |
| `/app/music` | Download output | read-write |
| `/root/.gamdl` | Config persistence (optional) | read-write |

## 🚀 Usage

```bash
Expand Down