Class YoutubeAudioSourceManager

java.lang.Object
dev.lavalink.youtube.YoutubeAudioSourceManager
All Implemented Interfaces:
com.sedmelluq.discord.lavaplayer.source.AudioSourceManager

public class YoutubeAudioSourceManager extends Object implements com.sedmelluq.discord.lavaplayer.source.AudioSourceManager
  • Field Details

    • SEARCH_PREFIX

      public static final String SEARCH_PREFIX
      See Also:
    • MUSIC_SEARCH_PREFIX

      public static final String MUSIC_SEARCH_PREFIX
      See Also:
    • DEFAULT_CLIENTS

      public static final Client[] DEFAULT_CLIENTS
    • httpInterfaceManager

      protected final com.sedmelluq.discord.lavaplayer.tools.io.HttpInterfaceManager httpInterfaceManager
    • allowSearch

      protected final boolean allowSearch
    • allowDirectVideoIds

      protected final boolean allowDirectVideoIds
    • allowDirectPlaylistIds

      protected final boolean allowDirectPlaylistIds
    • clients

      protected final Client[] clients
    • oauth2Handler

      protected YoutubeOauth2Handler oauth2Handler
    • contextFilter

      protected YoutubeHttpContextFilter contextFilter
    • cipherManager

      protected CipherManager cipherManager
  • Constructor Details

    • YoutubeAudioSourceManager

      public YoutubeAudioSourceManager()
    • YoutubeAudioSourceManager

      public YoutubeAudioSourceManager(boolean allowSearch)
    • YoutubeAudioSourceManager

      public YoutubeAudioSourceManager(boolean allowSearch, boolean allowDirectVideoIds, boolean allowDirectPlaylistIds)
    • YoutubeAudioSourceManager

      public YoutubeAudioSourceManager(@NotNull @NotNull Client... clients)
      Construct an instance of YoutubeAudioSourceManager with default settings and the given clients.
      Parameters:
      clients - The clients to use for track loading. They will be queried in the order they are provided.
    • YoutubeAudioSourceManager

      public YoutubeAudioSourceManager(boolean allowSearch, @NotNull @NotNull Client... clients)
      Construct an instance of YoutubeAudioSourceManager with the given settings and clients.
      Parameters:
      allowSearch - Whether to allow searching for tracks. If disabled, the "ytsearch:" and "ytmsearch:" prefixes will return nothing.
      clients - The clients to use for track loading. They will be queried in the order they are provided.
    • YoutubeAudioSourceManager

      public YoutubeAudioSourceManager(boolean allowSearch, boolean allowDirectVideoIds, boolean allowDirectPlaylistIds, @NotNull @NotNull Client... clients)
      Construct an instance of YoutubeAudioSourceManager with the given settings and clients.
      Parameters:
      allowSearch - Whether to allow searching for tracks. If disabled, the "ytsearch:" and "ytmsearch:" prefixes will return nothing.
      allowDirectVideoIds - Whether this source will attempt to load video identifiers if they're provided without a complete URL (i.e. "dQw4w9WgXcQ")
      allowDirectPlaylistIds - Whether this source will attempt to load playlist identifiers if they're provided without a complete URL.
      clients - The clients to use for track loading. They will be queried in the order they are provided.
    • YoutubeAudioSourceManager

      public YoutubeAudioSourceManager(@NotNull @NotNull YoutubeSourceOptions options, @NotNull @NotNull Client... clients)
  • Method Details

    • getSourceName

      public String getSourceName()
      Specified by:
      getSourceName in interface com.sedmelluq.discord.lavaplayer.source.AudioSourceManager
    • setPlaylistPageCount

      public void setPlaylistPageCount(int count)
    • useOauth2

      public void useOauth2(@Nullable @Nullable String refreshToken, boolean skipInitialization)
      Instructs this source to use Oauth2 integration. null is valid and will kickstart the oauth process. Providing a refresh token will likely skip having to authenticate your account prior to making requests, as long as the provided token is still valid.
      Parameters:
      refreshToken - The token to use for generating access tokens. Can be null.
      skipInitialization - Whether linking of an account should be skipped, if you intend to provide a refresh token later. This only applies on null/empty/invalid refresh tokens. Valid refresh tokens will not be presented with an initialization prompt.
    • getOauth2RefreshToken

      @Nullable public @Nullable String getOauth2RefreshToken()
    • loadItem

      @Nullable public @Nullable com.sedmelluq.discord.lavaplayer.track.AudioItem loadItem(@NotNull @NotNull com.sedmelluq.discord.lavaplayer.player.AudioPlayerManager manager, @NotNull @NotNull com.sedmelluq.discord.lavaplayer.track.AudioReference reference)
      Specified by:
      loadItem in interface com.sedmelluq.discord.lavaplayer.source.AudioSourceManager
    • loadItemOnce

      @Nullable protected @Nullable com.sedmelluq.discord.lavaplayer.track.AudioItem loadItemOnce(@NotNull @NotNull com.sedmelluq.discord.lavaplayer.track.AudioReference reference)
    • getRouter

      @Nullable protected @Nullable YoutubeAudioSourceManager.Router getRouter(@NotNull @NotNull com.sedmelluq.discord.lavaplayer.tools.io.HttpInterface httpInterface, @NotNull @NotNull String identifier)
    • routeFromVideoId

      @Nullable protected @Nullable YoutubeAudioSourceManager.Router routeFromVideoId(@NotNull @NotNull com.sedmelluq.discord.lavaplayer.tools.io.HttpInterface httpInterface, @NotNull @NotNull String videoId, @Nullable @Nullable UrlTools.UrlInfo urlInfo)
    • buildAudioTrack

      @NotNull public @NotNull YoutubeAudioTrack buildAudioTrack(com.sedmelluq.discord.lavaplayer.track.AudioTrackInfo trackInfo)
    • getCipherManager

      @NotNull public @NotNull CipherManager getCipherManager()
    • getRemoteCipherManager

      @Nullable public @Nullable RemoteCipherManager getRemoteCipherManager()
      Gets the cipher manager as a RemoteCipherManager instance, if applicable, otherwise null.
      Returns:
      The cipher manager as a RemoteCipherManager instance or null.
    • setCipherManager

      public void setCipherManager(@NotNull @NotNull CipherManager cipherManager)
    • getClient

      @Nullable public <T extends Client> T getClient(@NotNull @NotNull Class<T> cls)
      Returns a client by the given type, if registered.
      Parameters:
      cls - The class of the client to return.
      Returns:
      The client instance, or null if it's not registered.
    • getClients

      @NotNull public @NotNull Client[] getClients()
    • getContextFilter

      @NotNull public @NotNull YoutubeHttpContextFilter getContextFilter()
    • getOauth2Handler

      @NotNull public @NotNull YoutubeOauth2Handler getOauth2Handler()
    • getHttpInterfaceManager

      @NotNull public @NotNull com.sedmelluq.discord.lavaplayer.tools.io.HttpInterfaceManager getHttpInterfaceManager()
    • getInterface

      @NotNull public @NotNull com.sedmelluq.discord.lavaplayer.tools.io.HttpInterface getInterface()
    • isTrackEncodable

      public boolean isTrackEncodable(com.sedmelluq.discord.lavaplayer.track.AudioTrack track)
      Specified by:
      isTrackEncodable in interface com.sedmelluq.discord.lavaplayer.source.AudioSourceManager
    • encodeTrack

      public void encodeTrack(com.sedmelluq.discord.lavaplayer.track.AudioTrack track, DataOutput output)
      Specified by:
      encodeTrack in interface com.sedmelluq.discord.lavaplayer.source.AudioSourceManager
    • decodeTrack

      @NotNull public @NotNull com.sedmelluq.discord.lavaplayer.track.AudioTrack decodeTrack(@NotNull @NotNull com.sedmelluq.discord.lavaplayer.track.AudioTrackInfo trackInfo, @NotNull @NotNull DataInput input)
      Specified by:
      decodeTrack in interface com.sedmelluq.discord.lavaplayer.source.AudioSourceManager
    • shutdown

      public void shutdown()
      Specified by:
      shutdown in interface com.sedmelluq.discord.lavaplayer.source.AudioSourceManager