radio-dl
v1.0.0
Published
Stream and record 1100+ live radio stations from 42 countries. Discord bot compatible.
Maintainers
Readme
radio-dl
Eine JavaScript-Library zum Streamen von Live-Radiostationen. Ähnlich wie ytdl, aber spezialisiert auf Live-Radio-Streaming mit über 1100+ internationalen Sendern.
Features
- 🎙️ Streamen von 1100+ Live-Radiostationen
- 📻 Unterstützung für verschiedene Radio-Formate (M3U, PLS, Shoutcast, Icecast)
- 🎵 Metadaten-Abruf (Station-Name, Genre, Bitrate)
- 📊 Stream-Qualitäts-Management
- 🔄 Resiliente Stream-Verbindungen mit FFmpeg
- 🔐 Cookie-basierte Authentifizierung für geschützte Streams
- 🌍 42 Länder mit Sendern
- 🎸 30+ verschiedene Musik-Genres
- 🔍 Suche & Filter Funktionen
- 💾 MP3 Aufnahme (30 Sekunden bis unbegrenzt)
Installation
npm install radio-dlAbhängigkeiten:
- FFmpeg (für Audio-Verarbeitung) - Download
- Node.js 12+
Schnellstart
const RadioDownloader = require('radio-dl');
const radio = new RadioDownloader();
// Stream starten (z.B. für Discord Bot)
const stream = await radio.stream('energy');
// oder direkt mit URL
const stream = await radio.stream('https://ice1.somafm.com/groovesalad-128-aac');API Referenz
Klasse: RadioDownloader
new RadioDownloader(options)
Parameter:
{
timeout: 30000, // Stream-Timeout in ms
userAgent: '...', // Custom User-Agent
maxRedirects: 5, // Max. HTTP Redirects
retryAttempts: 3 // Retry-Versuche
}Stream-Methoden
stream(stationKeyOrUrl, options)
Startet einen Audio-Stream.
Parameter:
stationKeyOrUrl- Station-Key (z.B. 'energy') oder URLoptions- Optional: { headers: {...} }
Returns: Promise - Nodejs ReadableStream
Beispiel:
// Mit Station-Key
const stream = await radio.stream('energy');
// Mit URL
const stream = await radio.stream('https://example.com/stream.mp3');
// Mit Custom Headers
const stream = await radio.stream('bigfm', {
headers: { 'Authorization': 'Bearer token' }
});streamStation(stationKey, options)
Startet Stream einer vordefinierten Station.
Parameter:
stationKey- Name der Station (z.B. 'energy', 'bigfm', 'rockantenne')options- Optional
Returns: Promise
Beispiel:
const stream = await radio.streamStation('energy');Aufnahme-Methoden
recordStream(stationKeyOrUrl, outputPath, duration)
Nimmt einen Stream auf und speichert als MP3.
Parameter:
stationKeyOrUrl- Station oder URLoutputPath- Pfad zur Output MP3 Dateiduration- Dauer in Sekunden (default: 30)
Returns: Promise<{success, file, station, duration, size}>
Beispiel:
const result = await radio.recordStream('energy', './radio.mp3', 30);
console.log(result);
// {
// success: true,
// file: './radio.mp3',
// station: 'Energy',
// duration: 30,
// size: 567890
// }recordMultipleStations(stationArray, outputDir, duration)
Nimmt mehrere Stationen nacheinander auf.
Parameter:
stationArray- Array von Stations-KeysoutputDir- Output-Ordnerduration- Dauer pro Station in Sekunden
Returns: Promise
Beispiel:
const results = await radio.recordMultipleStations(
['energy', 'bigfm', 'rockantenne'],
'./downloads',
30
);Such & Filter Methoden
getAllStations()
Gibt alle 1100+ Stationen als Array zurück.
Returns: Array<{id, name, url, genre, country}>
const allStations = radio.getAllStations();
console.log(allStations[0]);
// {
// id: 'energy',
// name: 'Energy',
// url: 'https://...',
// genre: 'Pop',
// country: 'DE'
// }getAvailableStations()
Gibt nur die Station-Keys zurück.
Returns: Array
const keys = radio.getAvailableStations();
// ['energy', 'bigfm', 'rockantenne', ...]getStationsByGenre(genre)
Findet Stationen nach Genre.
Parameter:
genre- Genre-Name (z.B. 'Rock', 'Pop', 'Jazz')
Returns: Array
const rockStations = radio.getStationsByGenre('Rock');
// Findet alle Rock-SendergetStationsByCountry(country)
Findet Stationen nach Länder-Code.
Parameter:
country- 2-Buchstaben Länder-Code (z.B. 'DE', 'US', 'UK')
Returns: Array
const germanRadios = radio.getStationsByCountry('DE');
// Findet alle deutschen SendersearchStations(keyword)
Sucht Stationen nach Keyword.
Parameter:
keyword- Suchtext
Returns: Array
const results = radio.searchStations('jazz');
// Findet alle Stationen mit 'jazz' im Namen/Genre/etc.getRandomStation()
Gibt eine zufällige Station zurück.
Returns: Station
const random = radio.getRandomStation();
console.log(random.name); // z.B. "Berlin Jazz Radio"getStationInfo(stationKey)
Gibt Info zu einer spezifischen Station.
Parameter:
stationKey- Station-ID
Returns: Station | undefined
const station = radio.getStationInfo('energy');getStats()
Gibt Statistiken über die Sender-Datenbank.
Returns: {totalStations, totalCountries, totalGenres, countries[], genres[]}
const stats = radio.getStats();
// {
// totalStations: 1100+,
// totalCountries: 42,
// totalGenres: 30,
// countries: ['DE', 'AT', 'US', ...],
// genres: ['Pop', 'Rock', 'Jazz', ...]
// }Praktische Beispiele
Discord Bot Integration
const discord = require('discord.js');
const RadioDownloader = require('radio-dl');
const radio = new RadioDownloader();
const client = new discord.Client();
client.on('message', async (message) => {
if (message.content.startsWith('!radio ')) {
const stationKey = message.content.replace('!radio ', '').trim();
try {
// Stream starten
const stream = await radio.stream(stationKey);
// In Voice Channel abspielen
const voiceChannel = message.member.voice.channel;
const connection = await voiceChannel.join();
const dispatcher = connection.play(stream, { type: 'unknown' });
message.reply(`🎙️ Jetzt am streamen: ${stationKey}`);
} catch (error) {
message.reply(`❌ Fehler: ${error.message}`);
}
}
});Radio aufnehmen
const radio = new RadioDownloader();
// 60 Sekunden aufnehmen
await radio.recordStream('energy', './record.mp3', 60);
// Mehrere Sender
await radio.recordMultipleStations(
['energy', 'bigfm', 'rockantenne'],
'./downloads',
30
);Zufällige Station
const radio = new RadioDownloader();
// Zufälligen Sender streamen
const randomStation = radio.getRandomStation();
const stream = await radio.stream(randomStation.id);
console.log(`Jetzt: ${randomStation.name}`);Nach Genre filtern
const radio = new RadioDownloader();
// Alle Rock-Sender
const rockStations = radio.getStationsByGenre('Rock');
// Ersten wählen
const station = rockStations[0];
const stream = await radio.stream(station.id);Verfügbare Länder (42)
DE, AT, CH, UK, FR, ES, IT, BE, NL, SE, NO, DK, FI, PL, CZ, HU, RO, GR, PT, US, CA, AU, NZ, JP, IN, BR, MX, RU, KR, SG, TR, ZA, IE, IL, AE, TH, MY, PH, ID, VN, CN, TW, HK
Verfügbare Genres (30+)
Pop, Rock, Jazz, Classical, Electronic, Hip Hop, Country, News, Talk, Sports, Metal, Alternative, Indie, R&B, Reggae, Latin, World, Folk, Blues, Soul, Funk, Disco, Dance, House, Techno, Ambient, Experimental, Comedy, Podcast, Kids
Fehlerbehandlung
const radio = new RadioDownloader();
try {
const stream = await radio.stream('energy');
stream.on('error', (error) => {
console.error('Stream Fehler:', error);
});
} catch (error) {
console.error('Fehler beim Starten:', error.message);
}Lizenz
MIT
Autor
[Dein Name]
