Skip to content
This repository has been archived by the owner on Apr 6, 2024. It is now read-only.

Commit

Permalink
fix age restricted videos
Browse files Browse the repository at this point in the history
Swapped out lavaplayer branches.
Hooked PAPISID and PSID keys to the config.

In order to use this, add the following variables to the config:
papisid =
psid =

and set their value by looking at your Youtube cookies.
In Firefox, open up the dev tools (inspect element),
go to the Network tab,
filter for youtubei
refresh the page,
select the first POST message,
select the Cookies tab,
and grab __Secure-3PAPISID and __Secure-3PSID

See the official guide for that:
Walkyst/lavaplayer-fork#18
  • Loading branch information
Amavect committed May 9, 2022
1 parent 2696f04 commit 5c1c6d7
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 6 deletions.
15 changes: 11 additions & 4 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,18 @@
<artifactId>lavaplayer</artifactId>
<version>1.3.78</version>
</dependency -->
<!--dependency>
<groupId>com.github.jagrosh</groupId>
<artifactId>lavaplayer</artifactId>
<version>jmusicbot-SNAPSHOT</version>
</dependency-->
<!-- Use this fork to get age restricted videos -->
<dependency>
<groupId>com.github.jagrosh</groupId>
<artifactId>lavaplayer</artifactId>
<version>jmusicbot-SNAPSHOT</version>
</dependency>
<groupId>com.github.walkyst</groupId>
<artifactId>lavaplayer-fork</artifactId>
<version>1.3.97</version>
</dependency>

<!-- this is needed, but isn't actually hosted anywhere anymore... uh -->
<!--dependency>
<groupId>com.sedmelluq</groupId>
Expand Down
29 changes: 28 additions & 1 deletion src/main/java/com/jagrosh/jmusicbot/BotConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public class BotConfig
private final static String END_TOKEN = "/// END OF JMUSICBOT CONFIG ///";

private Path path = null;
private String token, prefix, altprefix, helpWord, playlistsFolder,
private String token, papisid, psid, prefix, altprefix, helpWord, playlistsFolder,
successEmoji, warningEmoji, errorEmoji, loadingEmoji, searchingEmoji;
private boolean stayInChannel, songInGame, npImages, updatealerts, useEval, dbots;
private long owner, maxSeconds, aloneTimeUntilStop;
Expand Down Expand Up @@ -70,6 +70,8 @@ public void load()

// set values
token = config.getString("token");
papisid = config.getString("papisid");
psid = config.getString("psid");
prefix = config.getString("prefix");
altprefix = config.getString("altprefix");
helpWord = config.getString("help");
Expand Down Expand Up @@ -113,6 +115,15 @@ public void load()
write = true;
}
}

if(papisid==null || papisid.isEmpty())
{
warn("No PAPISID provided! Age-restricted videos will not work. Continuing.");
}
if(psid==null || psid.isEmpty())
{
warn("No PSID provided! Age-restricted videos will not work. Continuing.");
}

// validate bot owner
if(owner<=0)
Expand Down Expand Up @@ -205,6 +216,12 @@ public static void writeDefaultConfig()
prompt.alert(Prompt.Level.ERROR, "JMusicBot Config", "An error occurred writing the default config file: " + ex.getMessage());
}
}

private void warn(String msg)
{
prompt.alert(Prompt.Level.WARNING, CONTEXT, msg + "\nConfig Location: " + path.toAbsolutePath().toString());
return;
}

public boolean isValid()
{
Expand Down Expand Up @@ -349,4 +366,14 @@ public Config getTransforms()
{
return transforms;
}

public String getPapisid()
{
return papisid;
}

public String getPsid()
{
return psid;
}
}
2 changes: 1 addition & 1 deletion src/main/java/com/jagrosh/jmusicbot/JMusicBot.java
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ private static void startBot()
if(!config.isValid())
return;
LOG.info("Loaded config from " + config.getConfigLocation());

// set up the listener
EventWaiter waiter = new EventWaiter();
SettingsManager settings = new SettingsManager();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
import com.sedmelluq.discord.lavaplayer.tools.FriendlyException;
import com.sedmelluq.discord.lavaplayer.track.AudioPlaylist;
import com.sedmelluq.discord.lavaplayer.track.AudioTrack;
import com.sedmelluq.discord.lavaplayer.source.youtube.YoutubeHttpContextFilter;
import com.sedmelluq.discord.lavaplayer.source.youtube.YoutubeHttpContextFilter;
import java.io.File;
import java.io.IOException;
import java.nio.file.Files;
Expand All @@ -40,6 +42,12 @@ public class PlaylistLoader
public PlaylistLoader(BotConfig config)
{
this.config = config;

// set up age restrction workaround from config
println("papisid: " + config.getPapisid());
YoutubeHttpContextFilter.setPAPISID(config.getPapisid());
println("psid" + config.getPsid());
YoutubeHttpContextFilter.setPSID(config.getPsid());
}

public List<String> getPlaylistNames()
Expand Down

0 comments on commit 5c1c6d7

Please sign in to comment.