Baike.dev
All toolsOnline toolsAI codingTrendingOpen sourceNewsSubmit
Log in
< Back to tools
Y

youtube-source

> 编程语言
Open source

A rewritten YouTube source manager for Lavaplayer.

385 stars0 likes2 views
WebsiteGitHub

About

A rewritten YouTube source manager for Lavaplayer.

youtube-source

A rewritten YouTube source manager for Lavaplayer.

This source aims to provide robustness by leveraging multiple InnerTube clients for requests. Where one client fails, another will try to load the request. Which clients are used is entirely configurable.

Table of Contents

  • Common
    • Information about the common module and usage of.
  • V2
    • Information about the v2 module and usage of.
  • Plugin
    • Information about the plugin module and usage of.
  • Available Clients
    • Information about the clients provided by youtube-source, as well as their advantages/disadvantages.
  • Using OAuth tokens
    • Information on using OAuth tokens with youtube-source.
  • Using a poToken
    • Information on using a poToken with youtube-source.
  • Using a remote cipher server
    • Information on using a remote cipher server with youtube-source.
  • REST Routes (plugin only)
    • Information on the REST routes provided by the youtube-source plugin module.
  • Migration Information
    • Information on migrating from Lavaplayer's built-in Youtube source manager.
  • Additional Support
    • For everything else.

common

This module provides the base source manager, which can be used with any com.sedmelluq.discord.lavaplayer packages still on major version 1.

Using in Gradle:

kotlin
repositories {
  // replace with https://maven.lavalink.dev/snapshots if you want to use a snapshot version.
  maven(url = "https://maven.lavalink.dev/releases")
}

dependencies {
  // Replace VERSION with the current version as shown by the Releases tab or a long commit hash `-SNAPSHOT` for snapshots.
  implementation("dev.lavalink.youtube:common:VERSION")
}

Example usage:

java
YoutubeAudioSourceManager youtube = new YoutubeAudioSourceManager();
// Optionally, you may instantiate the source with a custom options, such as toggling use of searching, and clients.
YoutubeAudioSourceManager youtube = new YoutubeAudioSourceManager(/*allowSearch:*/ true, new Client[] { new Music(), new Web(), new AndroidTestsuite() });

You may also extend the Client interface to support additional InnerTube clients. There are a few abstract classes to make this easier, notably, MusicClient (for music.youtube.com InnerTube clients), NonMusicClient (for youtube.com innertube clients) and StreamingNonMusicClient (for clients that can be used to stream videos).

Support for IP rotation has been included, and can be achieved using the following:

java
AbstractRoutePlanner routePlanner = new ...
YoutubeIpRotatorSetup rotator = new YoutubeIpRotatorSetup(routePlanner);

// 'youtube' is the variable holding your YoutubeAudioSourceManager instance.
rotator.forConfiguration(youtube.getHttpInterfaceManager(), false)
    .withMainDelegateFilter(youtube.getContextFilter()) // IMPORTANT
    .setup();

v2

This modules expands on common by providing additional support for Lavaplayer 2.x clients, such as Lavalink-Devs/Lavaplayer. Such features currently include thumbnail support within AudioTrackInfo. Additional clients are included that provide access to this additional information. These clients are suffixed with Thumbnail, such as WebWithThumbnail, AndroidWithThumbnail etc.

Using in Gradle:

kotlin
repositories {
  // replace with https://maven.lavalink.dev/snapshots if you want to use a snapshot version.
  maven(url = "https://maven.lavalink.dev/releases")
}

dependencies {
  // Replace VERSION with the current version as shown by the Releases tab or a long commit hash `-SNAPSHOT` for snapshots.
  implementation("dev.lavalink.youtube:v2:VERSION")
}

Example usage:

java
// same as the 'common' module but there are additional clients that provide video thumbnails in the returned metadata.
YoutubeAudioSourceManager youtube = new YoutubeAudioSourceManager(/*allowSearch:*/ true, new Client[] { new MusicWithThumbnail(), new WebWithThumbnail(), new AndroidTestsuiteWithThumbnail() });

plugin

This module serves as the plugin for use with Lavalink.

To use this plugin with Lavalink, you must declare the dependency.

Using with Lavalink v3:

yaml
lavalink:
  plugins:
    # Replace VERSION with the current version as shown by the Releases tab or a long commit hash for snapshots.
    - dependency: "dev.lavalink.youtube:youtube-plugin:VERSION"
      repository: "https://maven.lavalink.dev/releases" # use https://maven.lavalink.dev/snapshots if you want to use a snapshot version.

Using with Lavalink v4:

yaml
lavalink:
  plugins:
    # Replace VERSION with the current version as shown by the Releases tab or a long commit hash for snapshots.
    - dependency: "dev.lavalink.youtube:youtube-plugin:VERSION"
      snapshot: false # Set to true if you want to use a snapshot version.

Configuring the plugin:

[!IMPORTANT] You must make sure to disable the built-in YouTube source like so:

yaml
lavalink:
  server:
    sources:
      youtube: false

[!NOTE] Existing options, such as ratelimit and youtubePlaylistLoadLimit will be picked up automatically by the plugin, so these don't need changing.

…

Advanced Options

…

Available Clients

Currently, the following clients are available for use:

Identifier Opus Formats OAuth Age-restriction Support Playback Support Metadata Support Additional Notes
MUSIC No No No No Search YouTube music search support via ytmsearch: prefix
WEB Yes No No Yes + Livestream Video, Search, Playlist, Mix
MWEB Yes No No Yes + Livestream Video, Search, Playlist, Mix
WEBEMBEDDED Yes No Limited Yes + Livestream Video
ANDROID Yes No No Yes + Livestream Video, Search, Playlist, Mix Heavily restricted, frequently dysfunctional
ANDROID_MUSIC Yes No No Yes Video, Search, Mix
ANDROID_VR Yes No No Yes + Livestream Video, Search, Playlist, Mix
IOS No No No Yes + Livestream Video, Search, Playlist, Mix
TV Yes Yes With OAuth Yes + Livestream None Playback requires sign-in
TVHTML5_SIMPLY Yes No No Yes + Livestream Video, Search, Mix

[!NOTE] Clients that do not return Opus formats will require transcoding. Livestreams do not yield Opus formats so will always require transcoding.

Using OAuth Tokens

You may notice that some requests are flagged by YouTube, causing an error message asking you to sign in to confirm you're not a bot. With OAuth integration, you can request that youtube-source use your account credentials to appear as a normal user, with varying degrees of efficacy. You do not need to use poToken with OAuth.

[!WARNING] Similar to the poToken method, this is NOT a silver bullet solution, and worst case could get your account terminated! For this reason, it is advised that you use burner accounts and NOT your primary! This method may also trigger ratelimit errors if used in a high traffic environment. USE WITH CAUTION!

[!NOTE] You may need to set your log level for dev.lavalink.youtube.http.YoutubeOauth2Handler to INFO, to see additional information within your terminal regarding completing the OAuth flow.

[!NOTE] If you do not have a refresh token, then do not supply one. The source will output your refresh token into your terminal upon successfully completing the OAuth flow at least once. If you do not see your token, you may need to configure your logging (see above note).

You can instruct youtube-source to use OAuth with the following:

Lavaplayer

…

Lavalink

…

Passing an oauth token from your client

Another option to use oauth is by using oauth access tokens that are managed from your client. In this case your bot/client provides LavaLink with the token to use when playing a track. To do this simply add the oauth access token to a track's userData field in a json format when updating the player to play a track like:

json
{
  "oauth-token": "access token to use"
}

Using a poToken

A poToken, also known as a "Proof of Origin Token" is a way to identify what requests originate from. In YouTube's case, this is sent as a JavaScript challenge that browsers must evaluate, and send back the resolved string. Typically, this challenge would remain unsolved for bots as more often than not, they don't simulate an entire browser environment, instead only evaluating the minimum amount of JS required to do its job. Therefore, it's a reasonable assumption that if the challenge is not fulfilled, the request origin is a bot.

To obtain a poToken, you can use https://github.com/iv-org/youtube-trusted-session-generator, by running the Python script or the docker image. Both methods will print a poToken after a successful run, which you can supply to youtube-source to try and work around having automated requests blocked.

[!NOTE] A poToken is not a silver bullet, and currently it only applies to requests made via the WEB & WEBEMBEDDED client. You do not need to specify a poToken if using OAuth, and vice versa.

Specifying the token is as simple as doing:

Lavaplayer

java
// Web is dev.lavalink.youtube.clients.Web
Web.setPoTokenAndVisitorData("your po_token", "your visitor_data");

Lavalink

yaml
plugins:
  youtube:
    pot:
      token: "paste your po_token here"
      visitorData: "paste your visitor_data here"

Using a remote cipher server

It becomes harder and harder to keep up with YouTube's cipher changes, as they become more frequent and complex. To help with this, you can use a remote cipher server to handle signature deciphering for you. You can use yt-cipher, which is a simple Deno server that exposes a REST API for deciphering signatures. Check out the repository for more information on how to set it up.

If you want to implement your own, you can follow the yt-cipher API specification.

Lavaplayer

java
YoutubeSourceOptions options = new YoutubeSourceOptions()
     // The base URL of your remote cipher server & the password to authenticate with your remote cipher server, along with an identifier for metrics.
    .setRemoteCipher("http://localhost:8001", "your_secret_password", "user agent");
YoutubeAudioSourceManager sourceManager = new YoutubeAudioSourc

Issues· 0 open

View all issuesOpen on GitHub

No open issues yet, or sync has not completed.

> Tags

Javahacktoberfestlavaplayerlavaplayer-source-manageryoutube

No comments yet. Be the first to share.

> Details

PublishedAug 1, 2026
UpdatedSep 17, 2026
Category编程语言
PricingOpen source

> Related tools

T
TypeScript
JavaScript 的超集,为前端与全栈提供静态类型
P
Python
通用编程语言,广泛用于 Web、数据与 AI
G
Go
Google 推出的简洁高效系统语言