LavaSrc

repository·master·Indexed 42 days ago

https://github.com/topi314/lavasrc

A Lavalink plugin for Lavalink v4+ that adds support for multiple music streaming services including Spotify, Apple Music, Deezer, Yandex, Tidal, Qobuz, and VK Music. It features a mirroring system to resolve metadata from mirror sources (like Spotify) and play them via direct sources, along with integrated LavaSearch and LavaLyrics capabilities.

Tokens
6.2K
Snippets
27
Records
32
Agent score
4%

What's inside LavaSrc

  1. Overview of LavaSrc sources and features

    master

    LavaSrc is a source manager that provides metadata and playback capabilities for various music streaming platforms. It supports several playback modes:

    • Direct: The source can be used to retrieve a playable AudioTrack directly.
    • Mirror: The source provides metadata (playlists, albums, tracks, etc.) but cannot be played directly. Instead, the metadata resolved from a Mirror source is used to find and play a track from a Direct source (e.g., using Spotify metadata to find a playable track on Deezer).

    Supported Sources

    SourcePlaybackFeatures
    SpotifyMirrorPlaylists, Albums, Tracks, Artist Top Tracks, Search, LavaSearch, LavaLyrics
    Apple MusicMirrorPlaylists, Albums, Tracks, Artist Top Tracks, LavaSearch
    DeezerDirectPlaylists, Albums, Tracks, Artist Top Tracks, Search, Recommendations, LavaSearch, LavaLyrics
    YandexDirectPlaylists, Albums, Tracks, Artist Top Tracks, Search, Recommendations, LavaSearch, LavaLyrics
    Flowery TTSDirect
    YouTube (Music)N/ALavaSearch, LavaLyrics
    VK MusicDirectPlaylists, Albums, Tracks, Artist Top Tracks, Search, Recommendations, LavaSearch, LavaLyrics
    TidalMirrorPlaylists, Albums, Tracks, Search, Recommendations
    QobuzDirectPlaylists, Albums, Tracks, Search, Recommendations
    YouTube (yt-dlp)DirectPlaylists, Albums, Tracks, Search
    LRCLIBN/ALavaLyrics
    JioSaavnDirectPlaylists, Albums, Tracks, Artist Top Tracks, Search, Recommendations, LavaSearch

    Feature Legend

    • 📁 Playlists
    • 💿 Albums
    • 🎵 Tracks
    • 📻 Recommendations
    • 🧑 Artist top tracks
    • 🔍 Search results
    • 🔬 LavaSearch
    • 📜 LavaLyrics
  2. Use LavaLyrics and LavaSearch with Source Managers

    master

    Once you have registered a source manager (like Spotify, Deezer, Yandex, Vk, or Apple Music), you can enable lyrics and search capabilities by registering the source with LyricsManager and SearchManager respectively.

    // Example for Spotify
    var lyricsManager = new LyricsManager();
    lyricsManager.registerLyricsManager(spotify);
    
    var searchManager = new SearchManager();
    searchManager.registerSearchManager(spotify);
  3. How Mirroring works in LavaSrc

    master

    Mirroring is the process of resolving metadata from one source and using that metadata to retrieve a playable AudioTrack from a different, compatible source.

    Because some platforms (like Spotify or Tidal) do not allow direct audio streaming through LavaSrc, they are marked as Mirror sources. To play music from these platforms, LavaSrc takes the resolved metadata and searches for a corresponding playable track in a source marked as Direct (such as Deezer or YouTube). You can also use any other source manager registered to your AudioPlayerManager as the target for mirroring.

  4. Install LavaSrc plugin for Lavalink

    master

    LavaSrc requires Lavalink v4 or greater. You can install it by downloading the latest release to your plugins folder or by adding the dependency to your application.yml file.

    When using application.yml, ensure the plugins key is at the root of the YAML structure.

    lavalink:
      plugins:
        - dependency: "com.github.topi314.lavasrc:lavasrc-plugin:x.y.z"
          repository: "https://maven.lavalink.dev/releases"
          snapshot: false
  5. Install LavaSrc via Gradle or Maven

    master

    To use LavaSrc in your Lavaplayer project, add the following dependencies to your build configuration. Replace x.y.z with the latest version number. Snapshot builds are available at https://maven.topi.wtf/snapshots using the short commit hash as the version.

    ### Using in Gradle:
    
    ```gradle
    repositories {
      maven {
        url "https://maven.topi.wtf/releases"
      }
    }
    
    dependencies {
      implementation "com.github.topi314.lavasrc:lavasrc:x.y.z"
      implementation "com.github.topi314.lavasrc:lavasrc-protocol:x.y.z"
    }

    Using in Maven:

    <repositories>
      <repository>
        <id>TopiWTF-releases</id>
        <name>Topis Maven Repo</name>
        <url>https://maven.topi.wtf/releases</url>
      </repository>
    </repositories>
    
    <dependencies>
      <dependency>
        <groupId>com.github.topi314.lavasrc</groupId>
        <artifactId>lavasrc</artifactId>
        <version>x.y.z</version>
      </dependency>
      <dependency>
        <groupId>com.github.topi314.lavasrc</groupId>
        <artifactId>lavasrc-protocol-jvm</artifactId>
        <version>x.y.z</version>
      </dependency>
    </dependencies>
  6. Configure Deezer in LavaSrc

    master

    Deezer requires an arl cookie. You can also specify preferred audio formats. Note that high-quality formats like FLAC require a premium account and a valid arl.

    plugins:
      lavasrc:
        deezer:
          masterDecryptionKey: "your master decryption key"
          arl: "your deezer arl"
          formats: [ "FLAC", "MP3_320", "MP3_256", "MP3_128", "MP3_64", "AAC_64" ]
  7. Configure Apple Music in LavaSrc

    master

    Apple Music requires an API token or an Apple Music key (including keyID, teamID, and musicKitKey).

    plugins:
      lavasrc:
        applemusic:
          countryCode: "US"
          mediaAPIToken: "your apple music api token"
          # OR use a key:
          keyID: "your key id"
          teamID: "your team id"
          musicKitKey: |
            -----BEGIN PRIVATE KEY-----
            your key
            -----END PRIVATE KEY-----
          playlistLoadLimit: 6
          albumLoadLimit: 6
  8. Configure yt-dlp in LavaSrc

    master

    To use yt-dlp as a source, you must provide the path to the executable. You can also pass custom arguments for loading and playback.

    plugins:
      lavasrc:
        ytdlp:
          path: "yt-dlp"
          searchLimit: 10
          mixPlaylistLoadLimit: 25
          playlistLoadLimit: 1000
          customLoadArgs: ["-q", "--no-warnings", "--flat-playlist", "--skip-download", "-J"]
          customPlaybackArgs: ["-q", "--no-warnings", "-f", "bestaudio", "-J"]
  9. Use YouTube search prefixes

    master

    The YoutubeSearchManager supports two specific search prefixes to differentiate between standard YouTube searches and YouTube Music searches:

    • ytsearch:<QUERY>: Performs a standard YouTube autocomplete search, returning text suggestions.
    • ytmsearch:<QUERY>: Performs a YouTube Music autocomplete search, which can return tracks, albums, artists, and playlists.

    When using ytmsearch:, the manager returns structured results including YoutubeAudioTrack and ExtendedAudioPlaylist objects.

    // Example search prefixes
    ytsearch:my query
    ytmsearch:my query
  10. Configure Spotify in LavaSrc

    master

    To use Spotify, you must provide a clientId and clientSecret from the Spotify Developer Dashboard.

    Key options:

    • spDc: The Spotify sp_dc cookie, required for accessing the Spotify lyrics API.
    • countryCode: ISO 3166-1 alpha-2 code (e.g., US) for filtering top tracks.
    • preferPartnerApi: If true, uses the Spotify Partner API by default.
    • localFiles: Enables local file support for Spotify playlists.
    plugins:
      lavasrc:
        spotify:
          clientId: "your client id"
          clientSecret: "your client secret"
          spDc: "your sp dc cookie"
          countryCode: "US"
          playlistLoadLimit: 6
          albumLoadLimit: 6
          resolveArtistsInSearch: true
          localFiles: false
          preferPartnerApi: false
          preferV1SearchApi: false
          customTokenEndpoint: "http://localhost:8080/api/token"
  11. Configure LavaSrc providers and sources

    master

    LavaSrc uses providers to define how tracks are loaded (e.g., via ISRC or search queries) and sources to enable/disable specific music services.

    Providers allow for fallback logic. For example, you can attempt to load a track via YouTube search using an ISRC first, and then fall back to a standard YouTube search query if the ISRC fails.

    Sources enable support for services like Spotify, Apple Music, Deezer, etc. You must also configure lyrics-sources if you want to enable lyrics for specific services.

    plugins:
      lavasrc:
        providers: # Custom providers for track loading
          - "ytsearch:\"%ISRC%\""
          - "ytsearch:%QUERY%"
        sources:
          spotify: false
          applemusic: false
          deezer: false
          yandexmusic: false
          flowerytts: false
          youtube: false
          vkmusic: false
          tidal: false
          qobuz : false
          ytdlp: false
          jiosaavn: false
        lyrics-sources:
          spotify: false
          deezer: false
          youtube: false
          yandexmusic: false
          vkmusic: false
          lrcLib: false
  12. Configure yt-dlp Source Manager

    master

    To use yt-dlp as a source, provide the local file path to the yt-dlp executable.

    AudioPlayerManager playerManager = new DefaultAudioPlayerManager();
    
    // create a new YTDLPSourceManager with the path to the yt-dlp executable and register it
    playerManager.registerSourceManager(new YTDLPSourceManager("path/to/yt-dlp"));