Skip to content

Commit

Permalink
Implement ANDROID_VR and de-prioritise TVHTML5EMBEDDED (#70)
Browse files Browse the repository at this point in the history
* Replace degraded TVHTML5 client with WEB EMBEDDED for limited age-restricted playback

* Add ANDROID_VR client and deprioritise TVHTML5

* Formatting and readme update
  • Loading branch information
apex2504 authored Oct 21, 2024
1 parent f27cbf7 commit c358ae4
Show file tree
Hide file tree
Showing 6 changed files with 64 additions and 10 deletions.
16 changes: 7 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -154,9 +154,9 @@ plugins:
# Clients are queried in the order they are given (so the first client is queried first and so on...)
clients:
- MUSIC
- ANDROID_TESTSUITE
- ANDROID_VR
- WEB
- TVHTML5EMBEDDED
- WEBEMBEDDED
```

### Advanced Options
Expand All @@ -173,7 +173,7 @@ plugins:
# Example: Disabling a client's playback capabilities.
playback: false
videoLoading: false # Disables loading of videos for this client. A client may still be used for playback even if this is set to 'false'.
TVHTML5EMBEDDED:
WEBEMBEDDED:
# Example: Configuring a client to exclusively be used for video loading and playback.
playlistLoading: false # Disables loading of playlists and mixes.
searching: false # Disables the ability to search for videos.
Expand All @@ -189,6 +189,7 @@ Currently, the following clients are available for use:
- ✔ Opus formats.
- `WEBEMBEDDED`
- ✔ Opus formats.
- ✔ Limited age-restricted video playback.
- ❌ No mix/playlist/search support.
- `ANDROID`
- ❌ Heavily restricted, frequently dysfunctional.
Expand All @@ -198,15 +199,17 @@ Currently, the following clients are available for use:
- `ANDROID_MUSIC`
- ✔ Opus formats.
- ❌ No playlist/livestream support.
- `ANDROID_VR`
- ✔ Opus formats.
- `MEDIA_CONNECT`
- ❌ No Opus formats (requires transcoding).
- ❌ No mix/playlist/search support.
- `IOS`
- ❌ No Opus formats (requires transcoding).
- `TVHTML5EMBEDDED`
- ✔ Opus formats.
- ✔ Age-restricted video playback.
- ❌ No playlist support.
- ❌ Playback requires sign-in.

## 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.
Expand Down Expand Up @@ -387,11 +390,6 @@ In addition, there are a few significant changes to note:
the source manager with (e.g. an overridden `YoutubeTrackDetailsLoader`), this **is not** compatible
with this source manager.

- Support for logging into accounts as a means of playing age-restricted tracks has been removed, with the
`TVHTML5EMBEDDED` client instead being the preferred workaround. There were a large number of
reasons for this change, but not least the fact that logging in was slowly becoming problematic and deprecated
on the YouTube backend. The amount of code to support this feature meant that it has been axed.

## Additional Support
If you need additional help with using this source, that's not covered here or in any of the issues,
[join our Discord server](https://discord.gg/ZW4s47Ppw4).
39 changes: 39 additions & 0 deletions common/src/main/java/dev/lavalink/youtube/clients/AndroidVr.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
package dev.lavalink.youtube.clients;

import com.sedmelluq.discord.lavaplayer.tools.io.HttpInterface;
import dev.lavalink.youtube.clients.ClientConfig.AndroidVersion;
import org.jetbrains.annotations.NotNull;

public class AndroidVr extends Android {
public static String CLIENT_VERSION = "1.60.18";
public static AndroidVersion ANDROID_VERSION = AndroidVersion.ANDROID_12L;

public static ClientConfig BASE_CONFIG = new ClientConfig()
.withApiKey(Android.BASE_CONFIG.getApiKey())
.withUserAgent(String.format("com.google.android.apps.youtube.vr.oculus/%s (Linux; U; Android %s; eureka-user Build/SQ3A.220605.009.A1) gzip", CLIENT_VERSION, ANDROID_VERSION.getOsVersion()))
.withClientName("ANDROID_VR")
.withClientField("clientVersion", CLIENT_VERSION)
.withClientField("androidSdkVersion", ANDROID_VERSION.getSdkVersion());

protected ClientOptions options;

public AndroidVr() {
this(ClientOptions.DEFAULT);
}

public AndroidVr(@NotNull ClientOptions options) {
super(options, false);
}

@Override
@NotNull
protected ClientConfig getBaseClientConfig(@NotNull HttpInterface httpInterface) {
return BASE_CONFIG.copy();
}

@Override
@NotNull
public String getIdentifier() {
return BASE_CONFIG.getName();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,8 @@ public String toJsonString() {
public enum AndroidVersion {
// https://apilevels.com/
ANDROID_13("13", 33),
ANDROID_12("12", 31), // 12L => 32
ANDROID_12L("12L", 32),
ANDROID_12("12", 31),
ANDROID_11("11", 30);

private final String osVersion;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ private enum ClientMapping implements ClientReference {
ANDROID_TESTSUITE(AndroidTestsuite::new),
ANDROID_LITE(AndroidLite::new),
ANDROID_MUSIC(AndroidMusic::new),
ANDROID_VR(AndroidVr::new),
IOS(Ios::new),
MUSIC(Music::new),
TVHTML5EMBEDDED(TvHtml5Embedded::new),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ private enum ClientMapping implements ClientReference {
ANDROID_TESTSUITE(AndroidTestsuiteWithThumbnail::new),
ANDROID_LITE(AndroidLiteWithThumbnail::new),
ANDROID_MUSIC(AndroidMusicWithThumbnail::new),
ANDROID_VR(AndroidVrWithThumbnail::new),
IOS(IosWithThumbnail::new),
MUSIC(MusicWithThumbnail::new),
TVHTML5EMBEDDED(TvHtml5EmbeddedWithThumbnail::new),
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package dev.lavalink.youtube.clients;

import dev.lavalink.youtube.clients.skeleton.NonMusicClientWithThumbnail;
import org.jetbrains.annotations.NotNull;

public class AndroidVrWithThumbnail extends AndroidVr implements NonMusicClientWithThumbnail {
public AndroidVrWithThumbnail() {
super();
}

public AndroidVrWithThumbnail(@NotNull ClientOptions options) {
super(options);
}
}

0 comments on commit c358ae4

Please sign in to comment.