flux-dl
v1.1.10
Published
Leistungsstarke Video-Downloader Library für YouTube, Vimeo und Dailymotion - komplett in JavaScript, keine externen Binaries
Maintainers
Readme
flux-dl
Eine leistungsstarke Node.js Library zum Downloaden von Videos von YouTube, Vimeo und Dailymotion - komplett in JavaScript, keine externen Binaries!
Installation
npm install flux-dlFeatures
✅ YouTube Videos & Audio downloaden (ohne yt-dlp!)
✅ YouTube Suche - Song-Namen eingeben statt URLs!
✅ Vimeo Videos downloaden
✅ Dailymotion Videos downloaden
✅ Automatische Format-Auswahl
✅ Progress-Tracking
✅ Cookie-Support für authentifizierte Videos
✅ Perfekt für Bots (WhatsApp, Discord, Telegram)
✅ Komplett in JavaScript - keine externen Binaries
API Dokumentation
YouTubeSearch
Suche nach Videos ohne URL - perfekt für Bots!
Constructor
const { YouTubeSearch } = require('flux-dl');
const search = new YouTubeSearch();Methoden
search(query, maxResults)
Sucht nach Videos auf YouTube.
const results = await search.search('Rick Astley Never Gonna Give You Up', 5);
results.forEach(video => {
console.log(video.title);
console.log(video.url);
console.log(video.author);
});Response:
[
{
videoId: "dQw4w9WgXcQ",
title: "Rick Astley - Never Gonna Give You Up",
url: "https://www.youtube.com/watch?v=dQw4w9WgXcQ",
thumbnail: "https://...",
duration: 213,
author: "Rick Astley",
views: "1.7B views",
publishedTime: "15 years ago"
}
]searchAndDownload(query, downloader, options)
Sucht und lädt direkt das erste Ergebnis herunter.
const { VideoDownloader, YouTubeSearch } = require('flux-dl');
const downloader = new VideoDownloader();
const search = new YouTubeSearch();
const result = await search.searchAndDownload(
'Rick Astley Never Gonna Give You Up',
downloader,
{
audioOnly: true,
outputPath: './downloads'
}
);
console.log(result.filepath);VideoDownloader
Die Hauptklasse für Video-Downloads.
Constructor
const { VideoDownloader } = require('flux-dl');
const downloader = new VideoDownloader({
userAgent: 'Mozilla/5.0 ...', // Optional
timeout: 30000, // Optional
encryptionKey: 'your-key' // Optional
});Methoden
getVideoInfo(url)
Extrahiert Video-Informationen ohne Download.
const info = await downloader.getVideoInfo('https://youtube.com/watch?v=...');
console.log(info.title); // Video-Titel
console.log(info.author); // Autor/Kanal
console.log(info.duration); // Dauer in Sekunden
console.log(info.quality); // Qualität (z.B. "1080p")
console.log(info.videoUrl); // Download-URL
console.log(info.allFormats); // Alle verfügbaren FormateResponse:
{
title: "Video Titel",
videoId: "dQw4w9WgXcQ",
duration: 213,
thumbnail: "https://...",
author: "Kanal Name",
viewCount: 1742252685,
videoUrl: "https://...",
quality: "360p",
format: { /* Format-Details */ },
allFormats: [ /* Array aller Formate */ ],
platform: "YouTube"
}download(url, outputPath)
Lädt ein Video herunter.
const result = await downloader.download(
'https://youtube.com/watch?v=...',
'./downloads' // Optional, default: './downloads'
);
console.log(result.filepath); // Pfad zur heruntergeladenen Datei
console.log(result.info); // Video-InformationenResponse:
{
filepath: "./downloads/video_titel.mp3",
info: { /* Video-Info Objekt */ }
}downloadAudio(url, outputPath)
Lädt nur die Audio-Spur herunter.
const result = await downloader.downloadAudio(
'https://youtube.com/watch?v=...',
'./downloads'
);
console.log(result.filepath); // Pfad zur Audio-Datei
console.log(result.format); // Audio-Format DetailsBeispiele
YouTube Suche (NEU!)
const { VideoDownloader, YouTubeSearch } = require('flux-dl');
async function searchAndDownload() {
const downloader = new VideoDownloader();
const search = new YouTubeSearch();
// Suche nach Song-Name
const results = await search.search('Rick Astley', 3);
console.log('Gefundene Videos:');
results.forEach((video, i) => {
console.log(`${i + 1}. ${video.title} - ${video.author}`);
});
// Direkt suchen und downloaden
const result = await search.searchAndDownload(
'Rick Astley Never Gonna Give You Up',
downloader,
{ audioOnly: true }
);
console.log('✓ Downloaded:', result.filepath);
}
searchAndDownload();Einfacher Download
const { VideoDownloader } = require('flux-dl');
async function downloadVideo() {
const downloader = new VideoDownloader();
try {
const result = await downloader.download(
'https://youtube.com/watch?v=dQw4w9WgXcQ'
);
console.log('✓ Video gespeichert:', result.filepath);
} catch (error) {
console.error('Fehler:', error.message);
}
}
downloadVideo();Video-Info abrufen
const { VideoDownloader } = require('flux-dl');
async function getInfo() {
const downloader = new VideoDownloader();
const info = await downloader.getVideoInfo(
'https://youtube.com/watch?v=dQw4w9WgXcQ'
);
console.log(`Titel: ${info.title}`);
console.log(`Autor: ${info.author}`);
console.log(`Dauer: ${info.duration}s`);
console.log(`Qualität: ${info.quality}`);
console.log(`Verfügbare Formate: ${info.allFormats.length}`);
}
getInfo();Nur Audio downloaden
const { VideoDownloader } = require('flux-dl');
async function downloadAudio() {
const downloader = new VideoDownloader();
const result = await downloader.downloadAudio(
'https://youtube.com/watch?v=dQw4w9WgXcQ',
'./music'
);
console.log('✓ Audio gespeichert:', result.filepath);
}
downloadAudio();Mit Progress-Tracking
const { VideoDownloader } = require('flux-dl');
async function downloadWithProgress() {
const downloader = new VideoDownloader();
// Info abrufen
const info = await downloader.getVideoInfo(
'https://youtube.com/watch?v=dQw4w9WgXcQ'
);
console.log(`Starte Download: ${info.title}`);
// Download mit Progress
const result = await downloader.download(info.videoUrl);
console.log('✓ Fertig!');
}
downloadWithProgress();Mehrere Videos downloaden
const { VideoDownloader } = require('flux-dl');
async function downloadMultiple() {
const downloader = new VideoDownloader();
const urls = [
'https://youtube.com/watch?v=...',
'https://vimeo.com/...',
'https://dailymotion.com/video/...'
];
for (const url of urls) {
try {
const result = await downloader.download(url);
console.log('✓', result.info.title);
} catch (error) {
console.error('✗', url, error.message);
}
}
}
downloadMultiple();Für WhatsApp/Discord Bots
const { VideoDownloader, YouTubeSearch } = require('flux-dl');
// WhatsApp Bot Beispiel
bot.on('message', async (msg) => {
if (msg.body.startsWith('!song ')) {
const songName = msg.body.replace('!song ', '');
const downloader = new VideoDownloader();
const search = new YouTubeSearch();
try {
msg.reply('🔍 Suche...');
const result = await search.searchAndDownload(
songName,
downloader,
{ audioOnly: true }
);
msg.reply('✓ Fertig!');
await bot.sendFile(msg.from, result.filepath);
} catch (error) {
msg.reply('❌ Fehler: ' + error.message);
}
}
});Spezifisches Format wählen
const { VideoDownloader } = require('flux-dl');
async function downloadSpecificFormat() {
const downloader = new VideoDownloader();
// Alle Formate abrufen
const info = await downloader.getVideoInfo(
'https://youtube.com/watch?v=dQw4w9WgXcQ'
);
// Bestes 1080p Format finden
const format1080p = info.allFormats.find(f =>
f.qualityLabel === '1080p' && f.mimeType.includes('video')
);
if (format1080p) {
// Direkt mit Format-URL downloaden
const fs = require('fs');
const stream = await downloader.spoofing.downloadStream(
format1080p.url,
`https://youtube.com/watch?v=${info.videoId}`,
(percent) => console.log(`Progress: ${percent}%`)
);
const writer = fs.createWriteStream('./video_1080p.mp4');
stream.pipe(writer);
await new Promise((resolve, reject) => {
writer.on('finish', resolve);
writer.on('error', reject);
});
}
}
downloadSpecificFormat();Unterstützte Plattformen
const { supportedPlatforms } = require('flux-dl');
console.log(supportedPlatforms);
// ['YouTube', 'Vimeo', 'Dailymotion']Cookie-Support
Für Videos die Authentifizierung benötigen, kannst du eine cookies.txt Datei im Netscape-Format verwenden:
- Exportiere Cookies mit Browser-Extension (z.B. "Get cookies.txt")
- Speichere als
cookies.txtim Projekt-Root - Die Library lädt sie automatisch
Error Handling
const { VideoDownloader } = require('flux-dl');
async function safeDownload(url) {
const downloader = new VideoDownloader();
try {
const result = await downloader.download(url);
return { success: true, filepath: result.filepath };
} catch (error) {
if (error.message.includes('403')) {
return { success: false, error: 'Video nicht verfügbar oder geschützt' };
} else if (error.message.includes('Platform not supported')) {
return { success: false, error: 'Plattform nicht unterstützt' };
} else {
return { success: false, error: error.message };
}
}
}Technische Details
- Keine externen Binaries: Komplett in JavaScript implementiert
- YouTube InnerTube API: Nutzt die offizielle (undokumentierte) API
- Signatur-Entschlüsselung: Automatische Entschlüsselung von geschützten URLs
- Browser-Emulation: Simuliert echte Browser-Requests
- Multi-Platform: Unterstützt YouTube, Vimeo und Dailymotion
Dependencies
axios- HTTP-Requestscheerio- HTML-Parsing (für Vimeo/Dailymotion)m3u8-parser- HLS-Stream-Parsing
Lizenz
MIT
Support
Bei Problemen oder Fragen, erstelle ein Issue auf GitHub.
