Skip to content

Commit

Permalink
Another one possible workaround for 403 errors
Browse files Browse the repository at this point in the history
  • Loading branch information
Walkyst committed Oct 31, 2022
1 parent 7f8e2bd commit ea43154
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 6 deletions.
2 changes: 1 addition & 1 deletion main/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ plugins {
}

val moduleName = "lavaplayer"
version = "1.3.99-original"
version = "1.3.99.1-original"

dependencies {
api("com.sedmelluq:lava-common:1.1.2")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

import static com.sedmelluq.discord.lavaplayer.source.youtube.YoutubeConstants.CLIENT_SCREEN_EMBED;
import static com.sedmelluq.discord.lavaplayer.source.youtube.YoutubeConstants.CLIENT_THIRD_PARTY_EMBED;
import static com.sedmelluq.discord.lavaplayer.source.youtube.YoutubeConstants.PLAYER_PARAMS;
import static com.sedmelluq.discord.lavaplayer.source.youtube.YoutubeConstants.PLAYER_URL;
import static com.sedmelluq.discord.lavaplayer.tools.ExceptionTools.throwWithDebugInfo;
import static com.sedmelluq.discord.lavaplayer.tools.FriendlyException.Severity.COMMON;
Expand Down Expand Up @@ -209,26 +210,28 @@ protected JsonBrowser loadTrackInfoFromInnertube(

if (infoStatus == InfoStatus.PREMIERE_TRAILER) {
// Android client gives encoded Base64 response to trailer which is also protobuf so we can't decode it
clientConfig = YoutubeClientConfig.WEB.copy().setAttribute(httpInterface);
clientConfig = YoutubeClientConfig.WEB.copy();
} else if (infoStatus == InfoStatus.NON_EMBEDDABLE) {
// Used when age restriction bypass failed, if we have valid auth then most likely this request will be successful
clientConfig = YoutubeClientConfig.ANDROID.copy().setAttribute(httpInterface);
clientConfig = YoutubeClientConfig.ANDROID.copy()
.withRootField("params", PLAYER_PARAMS);
} else if (infoStatus == InfoStatus.REQUIRES_LOGIN) {
// Age restriction bypass
clientConfig = YoutubeClientConfig.TV_EMBEDDED.copy().setAttribute(httpInterface);
clientConfig = YoutubeClientConfig.TV_EMBEDDED.copy();
} else {
// Default payload from what we start trying to get required data
clientConfig = YoutubeClientConfig.ANDROID.copy()
.withClientField("clientScreen", CLIENT_SCREEN_EMBED)
.withThirdPartyEmbedUrl(CLIENT_THIRD_PARTY_EMBED)
.setAttribute(httpInterface);
.withRootField("params", PLAYER_PARAMS);
}

clientConfig
.withRootField("racyCheckOk", true)
.withRootField("contentCheckOk", true)
.withRootField("videoId", videoId)
.withPlaybackSignatureTimestamp(playerScriptTimestamp.scriptTimestamp);
.withPlaybackSignatureTimestamp(playerScriptTimestamp.scriptTimestamp)
.setAttribute(httpInterface);

log.debug("Loading track info with payload: {}", clientConfig.toJsonString());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ public class YoutubeConstants {

static final String CLIENT_SCREEN_EMBED = "EMBED";
static final String CLIENT_THIRD_PARTY_EMBED = "https://google.com";
static final String PLAYER_PARAMS = "8AEB";
static final String SEARCH_PARAMS = "EgIQAQ==";

static final String SEARCH_URL = BASE_URL + "/search?key=" + INNERTUBE_ANDROID_API_KEY;
Expand Down

0 comments on commit ea43154

Please sign in to comment.