Skip to content
forked from topi314/LavaSrc

A collection of additional Lavaplayer/Lavalink Sources

License

Notifications You must be signed in to change notification settings

PeTeR3431/LavaSrc

 
 

Repository files navigation

LavaSrc

A collection of additional Lavaplayer v2 & LavaSearch Audio Source Managers and Lavalink v4 Plugin.

*tracks are searched & played via YouTube or other configurable sources

Important

For LavaSrc v3 (Lavaplayer v1 & Lavalink v3) look here

Summary

Lavaplayer Usage

Replace x.y.z with the latest version number

Snapshot builds are available in https://maven.topi.wtf/snapshots with 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"
}

Using in Maven:

Maven
<repositories>
  <repository>
    <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>
</dependencies>

Usage

For all supported urls and queries see here

Spotify

To get a Spotify clientId & clientSecret you must go here and create a new application.

AudioPlayerManager playerManager = new DefaultAudioPlayerManager();

// create a new SpotifySourceManager with the default providers, clientId, clientSecret, countryCode and AudioPlayerManager and register it
playerManager.registerSourceManager(new SpotifySourceManager(null, clientId, clientSecret, countryCode, playerManager));

Apple Music

AudioPlayerManager playerManager = new DefaultAudioPlayerManager();

// create a new AppleMusicSourceManager with the standard providers, apple music api token, countrycode and AudioPlayerManager and register it
playerManager.registerSourceManager(new AppleMusicSourceManager(null, mediaAPIToken , "us", playerManager));
How to get media api token without Apple developer account
  1. Go to https://music.apple.com
  2. Open DevTools and go to the Debugger tab
  3. Search with this regex "(?<token>(ey[\w-]+)\.([\w-]+)\.([\w-]+))" in all index-*.js files
  4. Copy the token from the source code

Alternatively, you can follow this guide

Deezer

AudioPlayerManager playerManager = new DefaultAudioPlayerManager();

// create a new DeezerSourceManager with the master decryption key and register it
playerManager.registerSourceManager(new DeezerSourceManager("...");

Yandex Music

How to get access token
  1. (Optional) Open DevTools in your browser and on the Network tab enable trotlining.
  2. Go to https://oauth.yandex.ru/authorize?response_type=token&client_id=23cabbbdc6cd418abb4b39c32c41195d
  3. Authorize and grant access
  4. The browser will redirect to the address like https://music.yandex.ru/#access_token=AQAAAAAYc***&token_type=bearer&expires_in=31535645. Very quickly there will be a redirect to another page, so you need to have time to copy the link. image
  5. Your accessToken, what is after access_token.

Token expires in 1 year. You can get a new one by repeating the steps above.

Important information

Yandex Music is very location-dependent. You should either have a premium subscription or be located in one of the following countries:

  • Azerbaijan
  • Armenia
  • Belarus
  • Georgia
  • Kazakhstan
  • Kyrgyzstan
  • Moldova
  • Russia
  • Tajikistan
  • Turkmenistan
  • Uzbekistan

Else you will only have access to podcasts.

AudioPlayerManager playerManager = new DefaultAudioPlayerManager();

// create a new YandexMusicSourceManager with the access token and register it
playerManager.registerSourceManager(new YandexMusicSourceManager("...");

Flowery Text-to-Speech

Get list of all voices and languages supported here

AudioPlayerManager playerManager = new DefaultAudioPlayerManager();

// create a new FloweryTTSSourceManager with a valid voice and register it
playerManager.registerSourceManager(new FloweryTTSSourceManager("..."));

Lavalink Usage

This plugin requires Lavalink v4 or greater

To install this plugin either download the latest release and place it into your plugins folder or add the following into your application.yml

Note For a full application.yml example see here

Replace x.y.z with the latest version number

lavalink:
  plugins:
    - dependency: "com.github.topi314.lavasrc:lavasrc-plugin:x.y.z"
      repository: "https://maven.topi.wtf/releases"

Snapshot builds are available in https://maven.topi.wtf/snapshots with the short commit hash as the version

Configuration

For all supported urls and queries see here

To get your Spotify clientId & clientSecret go here & then copy them into your application.yml like the following.

To get your Apple Music api token go here

To get your Yandex Music access token go here

(YES plugins IS AT ROOT IN THE YAML)

plugins:
  lavasrc:
    providers: # Custom providers for track loading. This is the default
      # - "dzisrc:%ISRC%" # Deezer ISRC provider
      # - "dzsearch:%QUERY%" # Deezer search provider
      - "ytsearch:\"%ISRC%\"" # Will be ignored if track does not have an ISRC. See https://en.wikipedia.org/wiki/International_Standard_Recording_Code
      - "ytsearch:%QUERY%" # Will be used if track has no ISRC or no track could be found for the ISRC
      #  you can add multiple other fallback sources here
    sources:
      spotify: false # Enable Spotify source
      applemusic: false # Enable Apple Music source
      deezer: false # Enable Deezer source
      yandexmusic: false # Enable Yandex Music source
      flowerytts: false # Enable Flowery TTS source
      youtube: true # Enable YouTube search source (https://github.com/topi314/LavaSearch)
    spotify:
      clientId: "your client id"
      clientSecret: "your client secret"
      countryCode: "US" # the country code you want to use for filtering the artists top tracks. See https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2
      playlistLoadLimit: 6 # The number of pages at 100 tracks each
      albumLoadLimit: 6 # The number of pages at 50 tracks each
    applemusic:
      countryCode: "US" # the country code you want to use for filtering the artists top tracks and language. See https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2
      mediaAPIToken: "your apple music api token" # apple music api token
      # or specify an apple music key
      keyID: "your key id"
      teamID: "your team id"
      musicKitKey: |
        -----BEGIN PRIVATE KEY-----
        your key
        -----END PRIVATE KEY-----      
      playlistLoadLimit: 6 # The number of pages at 300 tracks each
      albumLoadLimit: 6 # The number of pages at 300 tracks each
    deezer:
      masterDecryptionKey: "your master decryption key" # the master key used for decrypting the deezer tracks. (yes this is not here you need to get it from somewhere else)
    yandexmusic:
      accessToken: "your access token" # the token used for accessing the yandex music api. See https://github.com/TopiSenpai/LavaSrc#yandex-music
    flowerytts:
      voice: "default voice" # (case-sensitive) get default voice from here https://api.flowery.pw/v1/tts/voices
      translate: false # whether to translate the text to the native language of voice
      silence: 0 # the silence parameter is in milliseconds. Range is 0 to 10000. The default is 0.
      speed: 1.0 # the speed parameter is a float between 0.5 and 10. The default is 1.0. (0.5 is half speed, 2.0 is double speed, etc.)
      audioFormat: "mp3" # supported formats are: mp3, ogg_opus, ogg_vorbis, aac, wav, and flac. Default format is mp3

Plugin Info

LavaSrc adds the following fields to tracks & playlists in Lavalink

Track

Field Type Description
albumName ?string The name of the album
albumArtUrl ?string The url of the album art
artistUrl ?string The url of the artist
artistArtworkUrl ?string The url of the artist artwork
previewUrl ?string The url of the preview
isPreview ?bool Whether the track is a preview

Playlist

Field Type Description
type Playlist Type The type of the playlist
url ?string The url of the playlist
artworkUrl ?string The url of the playlist artwork
author ?string The author of the playlist
totalTracks ?int The total number of tracks in the playlist

Playlist Types

Type Description
album The playlist is an album
playlist The playlist is a playlist
artist The playlist is an artist
recommendations The playlist is a recommendations playlist

Supported URLs and Queries

Spotify

(including new regional links like https://open.spotify.com/intl-de/track/0eG08cBeKk0mzykKjw4hcQ)

Apple Music

Deezer

Yandex Music

Flowery TTS

You can ready about all the available options here, a list of available voices is here

  • ftts://hello%20world
  • ftts://hello%20world?audio_format=ogg_opus&translate=False&silence=1000&speed=1.0

About

A collection of additional Lavaplayer/Lavalink Sources

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Java 88.3%
  • Kotlin 11.7%