Skip to content

Commit dc725b2

Browse files
committed
Update README with basic usage.
1 parent c18854e commit dc725b2

File tree

1 file changed

+105
-0
lines changed

1 file changed

+105
-0
lines changed

README.md

Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,107 @@
11
# lavaplayer-youtube-source
22
A rewritten YouTube source manager for Lavaplayer.
3+
4+
This source aims to provide robustness by leveraging multiple InnerTube clients
5+
for requests. Where one client fails, another will try to load the request.
6+
Which clients are used is entirely configurable.
7+
8+
## common
9+
This module provides the base source manager, which can be used with any
10+
`com.sedmelluq.discord.lavaplayer` packages still on major version `1`.
11+
12+
Example usage:
13+
```java
14+
YoutubeAudioSourceManager youtube = new YoutubeAudioSourceManager();
15+
// Optionally, you may instantiate the source with a custom options, such as toggling use of searching, and clients.
16+
YoutubeAudioSourceManager youtube = new YoutubeAudioSourceManager(/*allowSearch:*/ true, new Client[] { new Music(), new Web(), new Android() });
17+
```
18+
19+
You may also extend the `Client` interface to support additional InnerTube clients. There are a few abstract classes to
20+
make this easier, notably, `MusicClient` (for `music.youtube.com` InnerTube clients), `NonMusicClient` (for youtube.com
21+
innertube clients) and `StreamingNonMusicClient` (for clients that can be used to stream videos).
22+
23+
Support for IP rotation has been included, and can be achieved using the following:
24+
```java
25+
AbstractRouterPlanner routePlanner = new ...
26+
YoutubeIpRotatorSetup rotator = new YoutubeIpRotatorSetup(routePlanner);
27+
28+
rotator.forConfiguration(youtube.getHttpInterfaceManager(), false)
29+
.withMainDelegateFilter(null) // This is important, otherwise you may get NullPointerExceptions.
30+
.setup();
31+
```
32+
33+
## lldevs
34+
This modules expands on `common` by providing additional support for
35+
Lavaplayer `2.x` clients, such as [Lavalink-Devs/Lavaplayer](https://github.com/lavalink-devs/lavaplayer).
36+
Such features currently include thumbnail support within `AudioTrackInfo`.
37+
Additional clients are included that provide access to this additional information.
38+
These clients are suffixed with `Thumbnail`, such as `WebWithThumbnail`, `AndroidWithThumbnail` etc.
39+
40+
Example usage:
41+
```java
42+
// same as the 'common' module but there are additional clients that provide video thumbnails in the returned metadata.
43+
YoutubeAudioSourceManager youtube = new YoutubeAudioSourceManager(/*allowSearch:*/ true, new Client[] { new MusicWithThumbnail(), new WebWithThumbnail(), new AndroidWithThumbnail() });
44+
```
45+
46+
## plugin
47+
This module serves as the plugin for use with [Lavalink](https://github.com/lavalink-devs/lavalink).
48+
49+
To use this plugin with Lavalink, you must declare the dependency.
50+
```yaml
51+
lavalink:
52+
# ...
53+
plugins:
54+
# replace VERSION with the current version as shown by the Releases tab.
55+
- dependency: "com.github.lavalink-devs.lavaplayer-youtube-source:plugin:VERSION"
56+
repository: "https://jitpack.io"
57+
```
58+
59+
Configuring the plugin:
60+
```yaml
61+
plugins:
62+
youtube:
63+
enabled: true
64+
clients: ["MUSIC", "ANDROID", "WEB"]
65+
```
66+
67+
> [!IMPORTANT]
68+
> You must make sure to disable the built-in YouTube source like so:
69+
```yaml
70+
lavalink:
71+
server:
72+
sources:
73+
youtube: false
74+
```
75+
76+
Existing options, such as `ratelimit` and `youtubePlaylistLoadLimit` will be picked up automatically by the plugin,
77+
so these don't need changing.
78+
79+
## Available Clients
80+
Currently, the following clients are available for use:
81+
82+
- `MUSIC`
83+
- Provides support for searching YouTube music (`ytmsearch:`)
84+
- `WEB`
85+
- `ANDROID`
86+
- `ANDROID_TESTSUITE`
87+
- NOTE: This client does NOT support loading of mixes or playlists.
88+
It is advised not to use this client on its own for that reason, if playlists and mix support is required.
89+
- `IOS`
90+
- NOTE: This client does not receive Opus formats, so transcoding is required. This can
91+
increase resource consumption. It is recommended not to use this client unless it has
92+
the least priority (specified last), or where hardware usage is not a concern.
93+
- `TVHTML5EMBEDDED`
94+
- This client is useful for playing age-restricted tracks. Do keep in mind that, even with this
95+
client enabled, age-restricted tracks are **not** guaranteed to play.
96+
97+
## Migration from Lavaplayer's built-in YouTube source
98+
This client is intended to be a drop-in replacement, however there are a couple of things to note:
99+
100+
- This source's class structure differs so if you had custom classes that you were initialising
101+
the source manager with (e.g. an overridden `YoutubeTrackDetailsLoader`), this **is not** compatible
102+
with this source manager.
103+
104+
- Support for logging into accounts as a means of playing age-restricted tracks has been removed, with the
105+
`TVHTML5EMBEDDED` client instead being the preferred workaround. There were a large number of
106+
reasons for this change, but not least the fact that logging in was slowly becoming problematic and deprecated
107+
on the YouTube backend. The amount of code to support this feature meant that it has been axed.

0 commit comments

Comments
 (0)