From 414750bfd8bfa859eeff1b54b40b17fc4207e901 Mon Sep 17 00:00:00 2001 From: imagede Date: Sun, 29 Mar 2026 21:17:10 +0200 Subject: [PATCH] docker: alpine, autodownload --- .gitignore | 3 +- Dockerfile | 16 +++---- app/static/index.html | 72 +++++++++++------------------- docker-compose.yml => compose.yaml | 0 4 files changed, 34 insertions(+), 57 deletions(-) rename docker-compose.yml => compose.yaml (100%) diff --git a/.gitignore b/.gitignore index 872339c..ebfcd56 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ -app/__pycache__ \ No newline at end of file +app/__pycache__ +downloads/ \ No newline at end of file diff --git a/Dockerfile b/Dockerfile index f0ddca2..59c7780 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,9 +1,7 @@ -FROM python:3.12-slim +FROM python:3.12-alpine -# Install ffmpeg (required for merging video+audio streams and MP3 conversion) -RUN apt-get update && \ - apt-get install -y --no-install-recommends ffmpeg && \ - rm -rf /var/lib/apt/lists/* +# Install ffmpeg and dcron (lightweight cron daemon for Alpine) +RUN apk add --no-cache ffmpeg dcron WORKDIR /app @@ -17,10 +15,10 @@ COPY app/ . # Downloads are stored here (mount a host volume to persist them) RUN mkdir -p /downloads -# Setup Cronjob -RUN apt-get update && apt-get install -y cron && \ - echo "0 4 * * * pip install --upgrade yt-dlp >> /var/log/yt-dlp-upgrade.log 2>&1" | crontab - +# Setup Cronjob (fails) +RUN echo "0 4 * * * pip install --upgrade yt-dlp >> /var/log/yt-dlp-upgrade.log 2>&1" | crontab - EXPOSE 8080 -CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "8080"] +# Launch +CMD uvicorn main:app --host 0.0.0.0 --port 8080 \ No newline at end of file diff --git a/app/static/index.html b/app/static/index.html index 40f042b..a55cd93 100644 --- a/app/static/index.html +++ b/app/static/index.html @@ -96,6 +96,7 @@ border: none; border-radius: 8px; padding: 11px 20px; + margin: 1px; font-size: 0.9rem; font-weight: 600; cursor: pointer; @@ -290,15 +291,7 @@
- -

Download videos & audio from YouTube and 1000+ sites

+

hier könnte ihre werbung stehen

@@ -315,28 +308,10 @@
-
-
- - -
-
- - -
-
+
+ -
- +
@@ -359,12 +334,6 @@ return n + ' views'; } - function onFormatChange() { - const fmt = document.getElementById('format-select').value; - document.getElementById('quality-group').style.opacity = fmt === 'audio' ? '0.4' : '1'; - document.getElementById('quality-select').disabled = fmt === 'audio'; - } - async function fetchInfo() { const url = document.getElementById('url-input').value.trim(); if (!url) return; @@ -390,15 +359,19 @@ } } - async function startDownload() { + async function startDownload(isVideo) { const url = document.getElementById('url-input').value.trim(); if (!url) { alert('Please enter a URL first.'); return; } - const format = document.getElementById('format-select').value; - const quality = document.getElementById('quality-select').value; + const format = isVideo ? "video" : "audio"; + const quality = "best"; - const btn = document.getElementById('dl-btn'); - btn.disabled = true; - btn.innerHTML = 'Starting…'; + const btnv = document.getElementById('dl-btn-video'); + btnv.disabled = true; + btnv.innerHTML = 'Starting…'; + + const btna = document.getElementById('dl-btn-audio'); + btna.disabled = true; + btna.innerHTML = 'Starting…'; try { const res = await fetch('/api/download', { @@ -413,8 +386,11 @@ } catch (e) { alert('Failed to start download: ' + e.message); } finally { - btn.disabled = false; - btn.textContent = 'Download'; + btna.disabled = false; + btna.textContent = 'Download Audio'; + + btnv.disabled = false; + btnv.textContent = 'Download Video'; } } @@ -482,7 +458,8 @@ } else if (job.status === 'processing') { meta.textContent = 'Post-processing (merging / converting)…'; } else if (job.status === 'done') { - meta.textContent = 'Complete · ' + job.filename.split('_').slice(1).join('_'); + const goodname = job.filename.split('_').slice(1).join('_'); + meta.textContent = 'Complete · ' + goodname; if (!actions.querySelector('a')) { const a = document.createElement('a'); a.href = '/api/file/' + job.id; @@ -490,8 +467,9 @@ a.style.fontSize = '0.82rem'; a.style.padding = '7px 14px'; a.textContent = '⬇ Download File'; - a.download = ''; + a.download = goodname; actions.appendChild(a); + window.location.href = '/api/file/' + job.id; } } else if (job.status === 'error') { meta.textContent = ''; @@ -502,7 +480,7 @@ // Allow pressing Enter in the URL field document.getElementById('url-input').addEventListener('keydown', (e) => { - if (e.key === 'Enter') startDownload(); + if (e.key === 'Enter') startDownload(true); }); diff --git a/docker-compose.yml b/compose.yaml similarity index 100% rename from docker-compose.yml rename to compose.yaml