- Install Deno as a JavaScript runtime for yt-dlp in the Dockerfile. - Add configuration for yt-dlp to support cookies and JavaScript runtime selection. - Update API to handle cookies for YouTube bot detection and allow specifying the JavaScript runtime. - Introduce new environment variables for cookie management and JavaScript runtime configuration in README.
164 lines
5.5 KiB
Markdown
164 lines
5.5 KiB
Markdown
# YouTube Downloader
|
|
|
|
Eine einfache Web-Anwendung zum Herunterladen von YouTube-Videos mit Astro.js und yt-dlp.
|
|
|
|
## Features
|
|
|
|
- Einfache Login-Seite
|
|
- YouTube URL Download-Interface
|
|
- yt-dlp Integration für Video-Downloads (läuft innerhalb der App über npm-Package)
|
|
- Tailwind CSS für modernes Design
|
|
- Docker-Support
|
|
|
|
## Voraussetzungen
|
|
|
|
- Node.js 20 oder höher
|
|
- Docker (optional, für Container-Deployment)
|
|
|
|
## Installation
|
|
|
|
**Für unerfahrene Nutzer:** Siehe [INSTALLATION.md](./INSTALLATION.md) für eine detaillierte Schritt-für-Schritt-Anleitung.
|
|
|
|
### Schnellstart
|
|
|
|
1. **Dependencies installieren:**
|
|
```bash
|
|
npm install
|
|
```
|
|
|
|
2. **yt-dlp installieren:**
|
|
```bash
|
|
# macOS
|
|
brew install yt-dlp
|
|
|
|
# Linux
|
|
sudo apt-get install yt-dlp
|
|
|
|
# Windows oder mit pip
|
|
pip install yt-dlp
|
|
```
|
|
|
|
3. **Environment-Variablen einrichten:**
|
|
|
|
Erstelle eine `.env` Datei im Projektordner:
|
|
```env
|
|
LOGIN_USERNAME=admin
|
|
LOGIN_PASSWORD=dein-passwort
|
|
DOWNLOAD_DIR=./downloaded
|
|
SESSION_SECRET=dein-session-secret
|
|
```
|
|
|
|
4. **Development-Server starten:**
|
|
```bash
|
|
npm run dev
|
|
```
|
|
|
|
Die Anwendung läuft dann auf `http://localhost:4321`
|
|
|
|
### Mit Docker
|
|
|
|
1. Docker Image bauen und starten:
|
|
```bash
|
|
docker-compose up --build
|
|
```
|
|
|
|
Die Anwendung läuft dann auf `http://localhost:4321`
|
|
|
|
### Als Desktop-App (Electron)
|
|
|
|
**Für macOS:**
|
|
```bash
|
|
npm run electron:build:mac
|
|
```
|
|
|
|
**Für Windows:**
|
|
```bash
|
|
npm run electron:build:win
|
|
```
|
|
|
|
Die fertige App wird in `dist-electron/` erstellt:
|
|
- **macOS**: `.dmg` Installer oder `.zip` Portable Version
|
|
- **Windows**: `.exe` Installer oder Portable `.exe`
|
|
|
|
Siehe [BUILD-MACOS.md](./BUILD-MACOS.md) für detaillierte Anleitung.
|
|
|
|
## Verwendung
|
|
|
|
1. Öffne die Anwendung im Browser
|
|
2. Melde dich mit den konfigurierten Credentials an (siehe Environment-Variablen)
|
|
3. Gib eine YouTube URL in das Eingabefeld ein
|
|
4. Klicke auf "Download"
|
|
5. Das Video wird in den konfigurierten Ordner heruntergeladen (Standard: `/downloaded`)
|
|
|
|
## Konfiguration
|
|
|
|
### Environment-Variablen
|
|
|
|
- `LOGIN_USERNAME`: Benutzername für den Login (erforderlich wenn `LOGIN` nicht auf `false` gesetzt ist)
|
|
- `LOGIN_PASSWORD`: Passwort für den Login (erforderlich wenn `LOGIN` nicht auf `false` gesetzt ist)
|
|
- `LOGIN`: Wenn auf `false` gesetzt, wird der Login deaktiviert und alle Seiten sind ohne Authentifizierung zugänglich (Standard: `true`)
|
|
- `DOWNLOAD_DIR`: Verzeichnis für Downloads (Standard: `./downloaded`)
|
|
- `SESSION_SECRET`: Secret für Session-Cookies (Standard: `default-secret-change-in-production`)
|
|
- `STREAM_ONLY`: Wenn auf `true` gesetzt, werden Dateien nicht physisch gespeichert, sondern direkt als Download-Stream angeboten (Standard: `false`)
|
|
- `LOCALE`: Sprache der Anwendung - `de` für Deutsch oder `en` für Englisch (Standard: `de`)
|
|
- `YT_DLP_COOKIES`: Pfad zu einer Cookie-Datei für yt-dlp (z.B. `./cookies.txt`). Wird verwendet, um YouTube Bot-Erkennung zu umgehen. Siehe [yt-dlp Cookie-Dokumentation](https://github.com/yt-dlp/yt-dlp/wiki/FAQ#how-do-i-pass-cookies-to-yt-dlp)
|
|
- `YT_DLP_COOKIES_FROM_BROWSER`: Browser-Name, aus dem Cookies geladen werden sollen (z.B. `chrome`, `firefox`, `edge`, `safari`). Alternative zu `YT_DLP_COOKIES`. Siehe [yt-dlp Cookie-Dokumentation](https://github.com/yt-dlp/yt-dlp/wiki/Extractors#exporting-youtube-cookies)
|
|
- `YT_DLP_JS_RUNTIME`: JavaScript Runtime für yt-dlp (Standard: `deno`). Andere Optionen: `node`, `d8`, etc.
|
|
|
|
**Beispiel `.env` Datei mit Login:**
|
|
```
|
|
LOGIN_USERNAME=admin
|
|
LOGIN_PASSWORD=mein-sicheres-passwort
|
|
LOGIN=true
|
|
DOWNLOAD_DIR=./downloaded
|
|
SESSION_SECRET=mein-geheimes-session-secret
|
|
STREAM_ONLY=false
|
|
LOCALE=de
|
|
YT_DLP_COOKIES_FROM_BROWSER=chrome
|
|
```
|
|
|
|
**Beispiel `.env` Datei ohne Login:**
|
|
```
|
|
LOGIN=false
|
|
DOWNLOAD_DIR=./downloaded
|
|
STREAM_ONLY=false
|
|
LOCALE=de
|
|
YT_DLP_COOKIES_FROM_BROWSER=chrome
|
|
```
|
|
|
|
**Hinweis zu Cookies:**
|
|
- Wenn YouTube Bot-Erkennung auftritt, müssen Cookies verwendet werden
|
|
- `YT_DLP_COOKIES_FROM_BROWSER` ist die einfachste Option: Gibt den Browser-Namen an (z.B. `chrome`, `firefox`, `edge`, `safari`)
|
|
- Alternativ kann `YT_DLP_COOKIES` mit dem Pfad zu einer Cookie-Datei verwendet werden
|
|
- Cookie-Dateien können mit Browser-Erweiterungen wie "Get cookies.txt LOCALLY" oder "cookies.txt" exportiert werden
|
|
|
|
**Hinweis zu `LOGIN`:**
|
|
- Wenn `LOGIN=false`: Keine Login-Seite, alle Seiten sind öffentlich zugänglich. `LOGIN_USERNAME` und `LOGIN_PASSWORD` werden ignoriert.
|
|
- Wenn `LOGIN=true` oder nicht gesetzt: Login ist aktiviert. `LOGIN_USERNAME` und `LOGIN_PASSWORD` müssen gesetzt sein.
|
|
|
|
**Hinweis zu `STREAM_ONLY`:**
|
|
- Wenn `STREAM_ONLY=true`: Dateien werden temporär gespeichert, direkt als Download-Stream angeboten und danach automatisch gelöscht. Keine Dateien bleiben auf der Festplatte.
|
|
- Wenn `STREAM_ONLY=false` oder nicht gesetzt: Dateien werden im `DOWNLOAD_DIR` Verzeichnis gespeichert und können später über die Dateiliste abgerufen werden.
|
|
|
|
## Projektstruktur
|
|
|
|
```
|
|
/
|
|
├── src/
|
|
│ ├── components/ # Astro-Komponenten
|
|
│ ├── layouts/ # Layout-Templates
|
|
│ ├── lib/ # Utility-Funktionen
|
|
│ └── pages/ # Seiten und API-Routes
|
|
├── Dockerfile # Docker-Konfiguration
|
|
├── docker-compose.yml # Docker Compose Setup
|
|
└── package.json # Dependencies
|
|
```
|
|
|
|
## Hinweise
|
|
|
|
- Die Login-Credentials müssen in den Environment-Variablen `LOGIN_USERNAME` und `LOGIN_PASSWORD` gesetzt werden
|
|
- Für Produktionsumgebungen sollte ein starkes Passwort verwendet werden
|
|
- yt-dlp läuft innerhalb der App über das npm-Package `yt-dlp-wrap`
|
|
- Im Docker-Container wird yt-dlp automatisch installiert
|
|
- Für lokale Entwicklung muss yt-dlp separat installiert sein (siehe Installation)
|