The Core Concept
Lava-Anghami is a robust plugin built for Lavalink and LavaPlayer. It bridges the gap between Discord audio bots and the MENA region's largest music streaming service, Anghami.
By reverse-engineering Anghami's private mobile/web gateways (coussa.anghami.com), this plugin bypasses standard limitations, allowing direct audio extraction and playback routing.
⚠️ The Geographic Reality
Let's not hide the fact that Anghami imposes strict geographic restrictions. If you are outside the Middle East and North Africa, the capitalist system prevails, and you must have an Anghami Plus (premium) account to stream content.
However, if your server/instance is located in an Arab country, you bypass the paywall! The plugin works seamlessly, even with a completely free Anghami account.
Technical Capabilities
The plugin injects a custom AudioSourceManager directly into the Lavalink ecosystem. Here is what it can instantly resolve and stream:
| Feature | Support Status | Example Query / URL |
|---|---|---|
| Track Parsing | ✅ Fully Supported | https://play.anghami.com/song/105381896 |
| Album Resolution | ✅ Fully Supported | https://play.anghami.com/album/1018732306 |
| Playlist Scraping | ✅ Fully Supported | https://play.anghami.com/playlist/105381896 |
| Artist Top Tracks | ✅ Fully Supported | https://play.anghami.com/artist/89236 |
| Global Search | ✅ angsearch: | angsearch:hello adele |
| App Links | ✅ Auto-Redirects | anghami.app.link/... |
| Track Recommendations | ⏳ Coming Soon | angreq:105381896 |
Infrastructure Integration
1. Lavalink Server (Automatic via JitPack)
To deploy this on a Lavalink node (v4+), the plugin is injected via application.yml. It requires extracting session cookies directly from an active web session.
lavalink:
plugins:
- dependency: "com.github.ferrymehdi:lava-anghami:VERSION"
repository: "https://jitpack.io"
plugins:
lava-anghami:
enabled: true
anghamiToken: "YOUR_SESSION_ID_TOKEN" # Extracted from cookies
reqKey: "YOUR_REQ_KEY" # Local Storage Auth
resKey: "YOUR_RES_KEY" # Local Storage Auth
language: "en" # Forced localization
2. Standalone Java/Kotlin (LavaPlayer)
For custom bots not relying on the Lavalink node architecture, the source manager can be registered directly into the AudioPlayerManager thread pool.
import org.ferrymehdi.plugin.anghami.AnghamiAudioSourceManager;
// Initialize custom source manager with web session credentials
AnghamiAudioSourceManager anghamiSource = new AnghamiAudioSourceManager(
"YOUR_SESSION_ID",
"YOUR_REQ_KEY",
"YOUR_RES_KEY",
"en"
);
// Inject into LavaPlayer
playerManager.registerSourceManager(anghamiSource);
Under The Hood
The plugin operates entirely cookieless per-request (HttpClientTools.createCookielessThreadLocalManager()), utilizing a custom AnghamiProtobufDecoder to parse obfuscated song buffers returned by Anghami's internal GETsongdata endpoint. It natively decodes the payload, extracts the raw stream URL, and pipes the buffer directly into the LavaPlayer decoding engine.
