
Security News
Rust RFC Proposes a Security Tab on crates.io for RustSec Advisories
Rustβs crates.io team is advancing an RFC to add a Security tab that surfaces RustSec vulnerability and unsoundness advisories directly on crate pages.
rikn-music-fetcher
Advanced tools
A TypeScript wrapper for Discord bots, unifying music fetching from YouTube, SoundCloud (comming soon), Spotify with ytmusic-api, yt-dlp, lrclib. Robust fallback & link parsing for reliable music search, download, streaming.
rikn-music-fetcher is a TypeScript wrapper library that unifies multiple popular music sources (YouTube Music, Spotify) with capabilities for searching, streaming, downloading, and fetching lyrics (synced lyrics). Specially designed for Discord Music Bots with smart fallback features and flexible URL parsing.
npm install rikn-music-fetcher
import RiknClient from 'rikn-music-fetcher';
const client = new RiknClient({
spotify: {
clientId: 'YOUR_SPOTIFY_CLIENT_ID',
clientSecret: 'YOUR_SPOTIFY_CLIENT_SECRET'
},
ytmusic: {
cookiesPath: './cookies-ytm.txt', // Optional: cookies for better stability, from music.youtube.com (Netscape format)
GL: 'US',
HL: 'en'
},
ytdlp: {
autoUpdate: true, // Auto-update yt-dlp
updateIntervalDays: 7,
}
});
// Search on YouTube Music (default)
const tracks = await client.searchSong('Imagine Dragons Believer');
// Search on Spotify
const spotifyTracks = await client.searchSong('Shape of You', 'spotify');
console.log(tracks[0].title, tracks[0].artist);
// Find first song and get stream URL
const song = await client.searchFirstAndStream('Shape of You');
console.log('Stream URL:', song.streamUrl);
console.log('Track info:', song.title, song.artist);
// Auto-detect platform
const track = await client.getSongByUrl(
'https://open.spotify.com/track/3n3Ppam7vgaVa1iaRUc9Lp',
true // withStreamUrl = true to get stream URL
);
// Or from YouTube
const ytTrack = await client.getSongByUrl(
'https://www.youtube.com/watch?v=kJQP7kiw5Fk'
);
// Spotify playlist
const playlist = await client.getSongsByPlaylist(
'https://open.spotify.com/playlist/37i9dQZF1DXcBWIGoYBM5M'
);
// YouTube Music playlist
const ytPlaylist = await client.getSongsByPlaylist(
'https://music.youtube.com/playlist?list=RDCLAK5uy_...'
);
console.log(`Playlist has ${playlist.length} songs`);
import { createWriteStream } from 'fs';
// Stream from URL (auto-fallback if Spotify)
const stream = await client.streamSongByUrl(
'https://www.youtube.com/watch?v=kJQP7kiw5Fk'
);
// Pipe to file or Discord voice connection
stream.pipe(createWriteStream('output.m4a'));
// Or use with Discord.js
const connection = joinVoiceChannel({...});
const player = createAudioPlayer();
player.play(createAudioResource(stream));
// Get exact lyrics
const lyrics = await client.getLyrics(
'Shape of You',
'Ed Sheeran',
'Divide', // optional
233 // duration in seconds (optional)
);
console.log('Plain lyrics:', lyrics.plainLyrics);
console.log('Synced lyrics:', lyrics.syncedLyrics);
// Search lyrics
const searchResults = await client.searchLyrics('Believer', 'Imagine Dragons');
rikn-music-fetcher-wrapper/
βββ src/
β βββ RiknClient.ts # Main client class
β βββ index.ts # Export entry point
β βββ providers/
β β βββ spotify.ts # Spotify API wrapper
β β βββ youtube.ts # YouTube Music API wrapper
β β βββ yt-dlp.ts # yt-dlp wrapper
β β βββ lyrics.ts # LRCLIB API wrapper
β βββ types/
β β βββ music.type.ts # Common music types
β β βββ spotify.type.ts
β β βββ yt.type.ts
β β βββ lyrics.type.ts
β βββ constants/
β β βββ spotify.constants.ts
β β βββ yt.contants.ts
β β βββ lyrics.contants.ts
β βββ core/
β βββ utils.ts # Utility functions
βββ tests/
β βββ config.example.ts # Config template
βββ dist/ # Compiled output
βββ bin/ # yt-dlp binaries
βββ package.json
βββ tsconfig.json
βββ .npmignore
βββ README.md
new RiknClient(config?: RiknClientConfig)
RiknClientConfig:
{
spotify?: {
clientId: string;
clientSecret: string;
timeout?: number;
};
ytmusic?: {
cookiesPath?: string; // Path to cookies file from music.youtube.com (Netscape format)
GL?: string; // Country code (e.g., 'VN', 'US')
HL?: string; // Language code (e.g., 'vi', 'en')
};
ytdlp?: {
binDir?: string;
cookiesPath?: string; // Path to cookies file from youtube.com (Netscape format)
autoUpdate?: boolean;
updateIntervalDays?: number;
};
}
searchSong(query: string, platform?: Platform): Promise<Track[]>searchFirstAndStream(query: string): Promise<SongWithStream | null>getSongByUrl(url: string, withStreamUrl?: boolean): Promise<SongWithStream | null>getSongsByPlaylist(url: string): Promise<Track[]>streamSongByUrl(url: string): Promise<NodeJS.ReadableStream>getLyrics(trackName: string, artistName: string, albumName?: string, duration?: number): Promise<Lyrics | null>searchLyrics(trackName: string, artistName: string, albumName?: string): Promise<Lyrics[] | null># Clone repository
git clone https://github.com/Riikon-Team/rikn-music-fetcher-wrapper.git
cd rikn-music-fetcher-wrapper
# Install dependencies
npm install
# Build
npm run build
# Development
npm run dev
# Test
npm test
β οΈ Beta Version: This library is currently in beta stage. Some features may not be fully complete or thoroughly tested.
To improve stability when using YouTube Music API, you should provide a cookies file:
Get credentials at Spotify Developer Dashboard:
This library is built upon these amazing open-source projects:
Special thanks to all maintainers and contributors of these projects! π
We welcome all contributions from the community:
git checkout -b feature/AmazingFeature)git commit -m 'Add some AmazingFeature')git push origin feature/AmazingFeature)Please create an issue with:
This project is distributed under the GNU General Public License v3.0.
See the LICENSE file for more details.
Made with β€οΈ by Riikon Team
π Found a bug? Report it
π‘ Have an idea? Share it
β Like it? Star it
searchFirstAndStream(query)Search and get direct stream URL for first result.
getSongByUrl(url, withStreamUrl?)Get track info from URL (auto-detect platform).
getSongsByPlaylist(url)Get all tracks from playlist URL.
streamSongByUrl(url)Get readable stream for audio (YouTube only).
getLyrics(trackName, artistName, ...)Fetch lyrics from LRCLIB.
GPL-3.0
FAQs
A TypeScript wrapper for Discord bots, unifying music fetching from YouTube, SoundCloud (comming soon), Spotify with ytmusic-api, yt-dlp, lrclib. Robust fallback & link parsing for reliable music search, download, streaming.
The npm package rikn-music-fetcher receives a total of 10 weekly downloads. As such, rikn-music-fetcher popularity was classified as not popular.
We found that rikn-music-fetcher demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago.Β It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Rustβs crates.io team is advancing an RFC to add a Security tab that surfaces RustSec vulnerability and unsoundness advisories directly on crate pages.

Security News
/Research
Socket found a Rust typosquat (finch-rust) that loads sha-rust to steal credentials, using impersonation and an unpinned dependency to auto-deliver updates.

Research
/Security Fundamentals
A pair of typosquatted Go packages posing as Googleβs UUID library quietly turn helper functions into encrypted exfiltration channels to a paste site, putting developer and CI data at risk.