Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/main'
Browse files Browse the repository at this point in the history
  • Loading branch information
munishkhatri720 committed Dec 2, 2024
2 parents 704157e + 8742c34 commit b516a09
Show file tree
Hide file tree
Showing 22 changed files with 151 additions and 278 deletions.
15 changes: 8 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -187,24 +187,19 @@ Currently, the following clients are available for use:
- ❌ Cannot be used for playback, or playlist/mix/livestream loading.
- `WEB`
- ✔ Opus formats.
- `MWEB`
- ✔ Opus formats.
- `WEBEMBEDDED`
- ✔ Opus formats.
- ✔ Limited age-restricted video playback.
- ❌ No mix/playlist/search support.
- `ANDROID`
- ❌ Heavily restricted, frequently dysfunctional.
- ✔ Opus formats.
- `ANDROID_TESTSUITE`
- ✔ Opus formats.
- ❌ No mix/playlist/livestream support.
- `ANDROID_MUSIC`
- ✔ No opus formats for livestreams (requires transcoding).
- ❌ 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`
Expand Down Expand Up @@ -391,6 +386,12 @@ 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.

## Versioning Policy
This project follows [Semantic Versioning](https://semver.org/), except in the case of [client](#available-clients) removal.
Typically, clients are not removed unless there is good reason, such as being deprecated, irreparably broken or removed from YouTube's client lifecycle.
In such scenarios, we anticipate that you have ceased usage of such clients prior to their removal, so do not expect any code breakage,
however we advise that you periodically check and keep your client list up to date due to this.

## 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).
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ public YoutubeAudioSourceManager(boolean allowSearch) {

public YoutubeAudioSourceManager(boolean allowSearch, boolean allowDirectVideoIds, boolean allowDirectPlaylistIds) {
// query order: music -> web -> androidtestsuite -> tvhtml5embedded
this(allowSearch, allowDirectVideoIds, allowDirectPlaylistIds, new Music(), new Web(), new AndroidTestsuite(), new TvHtml5Embedded());
this(allowSearch, allowDirectVideoIds, allowDirectPlaylistIds, new Music(), new AndroidVr(), new Web(), new WebEmbedded());
}

/**
Expand Down Expand Up @@ -212,6 +212,7 @@ protected AudioItem loadItemOnce(@NotNull AudioReference reference) {
}

log.debug("Attempting to load {} with client \"{}\"", reference.identifier, client.getIdentifier());
httpInterface.getContext().setAttribute(Client.OAUTH_CLIENT_ATTRIBUTE, client.supportsOAuth());

try {
AudioItem item = router.route(client);
Expand Down
24 changes: 23 additions & 1 deletion common/src/main/java/dev/lavalink/youtube/clients/Android.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package dev.lavalink.youtube.clients;

import com.sedmelluq.discord.lavaplayer.tools.JsonBrowser;
import com.sedmelluq.discord.lavaplayer.tools.io.HttpInterface;
import dev.lavalink.youtube.clients.ClientConfig.AndroidVersion;
import dev.lavalink.youtube.clients.skeleton.StreamingNonMusicClient;
Expand All @@ -10,7 +11,7 @@
public class Android extends StreamingNonMusicClient {
private static final Logger log = LoggerFactory.getLogger(Android.class);

public static String CLIENT_VERSION = "19.32.24";
public static String CLIENT_VERSION = "19.44.38";
public static AndroidVersion ANDROID_VERSION = AndroidVersion.ANDROID_11;

public static ClientConfig BASE_CONFIG = new ClientConfig()
Expand Down Expand Up @@ -62,4 +63,25 @@ public ClientOptions getOptions() {
public String getIdentifier() {
return BASE_CONFIG.getName();
}

@Override
@NotNull
protected String extractPlaylistName(@NotNull JsonBrowser json) {
return json.get("header")
.get("pageHeaderRenderer")
.get("content")
.get("elementRenderer")
.get("newElement")
.get("type")
.get("componentType")
.get("model")
.get("youtubeModel")
.get("viewModel")
.get("pageHeaderViewModel")
.get("title")
.get("dynamicTextViewModel")
.get("text")
.get("content")
.text();
}
}
73 changes: 0 additions & 73 deletions common/src/main/java/dev/lavalink/youtube/clients/AndroidLite.java

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

public class AndroidMusic extends Android {
private static final Logger log = LoggerFactory.getLogger(AndroidMusic.class);
public static String CLIENT_VERSION = "7.11.50";
public static String CLIENT_VERSION = "7.27.52";

public static ClientConfig BASE_CONFIG = new ClientConfig()
.withApiKey(Android.BASE_CONFIG.getApiKey())
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
package dev.lavalink.youtube.clients;

import com.sedmelluq.discord.lavaplayer.tools.JsonBrowser;
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 String CLIENT_VERSION = "1.60.19";
public static AndroidVersion ANDROID_VERSION = AndroidVersion.ANDROID_12L;

public static ClientConfig BASE_CONFIG = new ClientConfig()
Expand Down Expand Up @@ -42,4 +43,10 @@ public String getPlayerParams() {
public String getIdentifier() {
return BASE_CONFIG.getName();
}

@Override
@NotNull
protected String extractPlaylistName(@NotNull JsonBrowser json) {
return json.get("header").get("playlistHeaderRenderer").get("title").get("runs").index(0).get("text").text();
}
}
13 changes: 11 additions & 2 deletions common/src/main/java/dev/lavalink/youtube/clients/Ios.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@
import org.jetbrains.annotations.NotNull;

public class Ios extends StreamingNonMusicClient {
public static String CLIENT_VERSION = "19.07.5";
public static String CLIENT_VERSION = "19.45.4";

public static ClientConfig BASE_CONFIG = new ClientConfig()
.withApiKey("AIzaSyB-63vPrdThhKuerbB2N_l7Kwwcxj6yUAc")
.withUserAgent(String.format("com.google.ios.youtube/%s (iPhone14,5; U; CPU iOS 15_6 like Mac OS X)", CLIENT_VERSION))
.withUserAgent(String.format("com.google.ios.youtube/%s (iPhone16,2; U; CPU iOS 18_1_0 like Mac OS X;)", CLIENT_VERSION))
.withClientName("IOS")
.withClientField("clientVersion", CLIENT_VERSION)
.withUserField("lockedSafetyMode", false);
Expand Down Expand Up @@ -49,6 +49,15 @@ protected JsonBrowser extractPlaylistVideoList(@NotNull JsonBrowser json) {
.get("playlistVideoListRenderer");
}

@Override
@NotNull
protected String extractPlaylistName(@NotNull JsonBrowser json) {
return json.get("header")
.get("pageHeaderRenderer")
.get("pageTitle")
.text();
}

@Override
@NotNull
public String getPlayerParams() {
Expand Down
67 changes: 67 additions & 0 deletions common/src/main/java/dev/lavalink/youtube/clients/MWeb.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
package dev.lavalink.youtube.clients;

import com.sedmelluq.discord.lavaplayer.tools.JsonBrowser;
import com.sedmelluq.discord.lavaplayer.tools.io.HttpInterface;
import org.jetbrains.annotations.NotNull;

public class MWeb extends Web {
public static ClientConfig BASE_CONFIG = new ClientConfig()
.withApiKey("AIzaSyAO_FJ2SlqU8Q4STEHLGCilw_Y9_11qcW8")
.withClientName("MWEB")
.withClientField("clientVersion", "2.20240726.11.00");

public MWeb() {
super();
}

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

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

@Override
@NotNull
protected JsonBrowser extractMixPlaylistData(@NotNull JsonBrowser json) {
return json.get("contents")
.get("singleColumnWatchNextResults")
.get("playlist")
.get("playlist");
}

@Override
protected String extractPlaylistName(@NotNull JsonBrowser json) {
return json.get("header")
.get("pageHeaderRenderer")
.get("pageTitle")
.text();
}

@Override
@NotNull
protected JsonBrowser extractPlaylistVideoList(@NotNull JsonBrowser json) {
return json.get("contents")
.get("singleColumnBrowseResultsRenderer")
.get("tabs")
.index(0)
.get("tabRenderer")
.get("content")
.get("sectionListRenderer")
.get("contents")
.index(0)
.get("itemSectionRenderer")
.get("contents")
.index(0)
.get("playlistVideoListRenderer");
}

@Override
@NotNull
public String getIdentifier() {
return BASE_CONFIG.getName();
}
}
Loading

0 comments on commit b516a09

Please sign in to comment.