Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix youtube #1126

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>com.jagrosh</groupId>
<artifactId>JMusicBot</artifactId>
<version>Snapshot</version>
<version>0.3.6.1</version>
<packaging>jar</packaging>

<repositories>
Expand All @@ -27,7 +27,7 @@
<dependency>
<groupId>net.dv8tion</groupId>
<artifactId>JDA</artifactId>
<version>4.3.0_324</version>
<version>4.4.0_352</version>
</dependency>
<!-- using a fork of this to fix some issues faster -->
<!-- dependency>
Expand All @@ -36,9 +36,9 @@
<version>1.3.78</version>
</dependency -->
<dependency>
<groupId>com.github.jagrosh</groupId>
<artifactId>lavaplayer</artifactId>
<version>jmusicbot-SNAPSHOT</version>
<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>
Expand Down Expand Up @@ -66,22 +66,22 @@
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<version>1.2.3</version>
<version>1.2.10</version>
</dependency>
<dependency>
<groupId>com.typesafe</groupId>
<artifactId>config</artifactId>
<version>1.3.2</version>
<version>1.4.2</version>
</dependency>
<dependency>
<groupId>org.jsoup</groupId>
<artifactId>jsoup</artifactId>
<version>1.14.2</version>
<version>1.14.3</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.13.1</version>
<version>4.13.2</version>
<scope>test</scope>
</dependency>
<dependency>
Expand Down
14 changes: 13 additions & 1 deletion src/main/java/com/jagrosh/jmusicbot/BotConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public class BotConfig

private Path path = null;
private String token, prefix, altprefix, helpWord, playlistsFolder,
successEmoji, warningEmoji, errorEmoji, loadingEmoji, searchingEmoji;
successEmoji, warningEmoji, errorEmoji, loadingEmoji, searchingEmoji, PAPISID, PSID;
private boolean stayInChannel, songInGame, npImages, updatealerts, useEval, dbots;
private long owner, maxSeconds, aloneTimeUntilStop;
private OnlineStatus status;
Expand Down Expand Up @@ -98,6 +98,8 @@ public void load()
playlistsFolder = config.getString("playlistsfolder");
aliases = config.getConfig("aliases");
transforms = config.getConfig("transforms");
PAPISID = config.getString("PAPISID");
PSID = config.getString("PSID");
dbots = owner == 113156185389092864L;

// we may need to write a new config file
Expand Down Expand Up @@ -329,4 +331,14 @@ public Config getTransforms()
{
return transforms;
}

public String getPAPISID()
{
return PAPISID;
}

public String getPSID()
{
return PSID;
}
}
6 changes: 6 additions & 0 deletions src/main/java/com/jagrosh/jmusicbot/audio/PlayerManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import com.sedmelluq.discord.lavaplayer.player.DefaultAudioPlayerManager;
import com.sedmelluq.discord.lavaplayer.source.AudioSourceManagers;
import com.sedmelluq.discord.lavaplayer.source.youtube.YoutubeAudioSourceManager;
import com.sedmelluq.discord.lavaplayer.source.youtube.YoutubeHttpContextFilter;
import com.typesafe.config.Config;
import net.dv8tion.jda.api.entities.Guild;

Expand All @@ -41,6 +42,11 @@ public void init()
TransformativeAudioSourceManager.createTransforms(bot.getConfig().getTransforms()).forEach(t -> registerSourceManager(t));
AudioSourceManagers.registerRemoteSources(this);
AudioSourceManagers.registerLocalSource(this);
if (bot.getConfig().getPAPISID() != null && bot.getConfig().getPSID() != null)
{
YoutubeHttpContextFilter.setPAPISID(bot.getConfig().getPAPISID());
YoutubeHttpContextFilter.setPSID(bot.getConfig().getPSID());
}
source(YoutubeAudioSourceManager.class).setPlaylistPageCount(10);
}

Expand Down
6 changes: 6 additions & 0 deletions src/main/resources/reference.conf
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,12 @@ token = BOT_TOKEN_HERE

owner = 0 // OWNER ID

// These set the tokens needed for proper Youtube age restrictions handeling.
// Age restricted videos from Youtube will not play.
// Consult the wiki on how to get these tokens.

PAPISID = "" //PAPI SID
PSID = "" //P SID

// This sets the prefix for the bot
// The prefix is used to control the commands
Expand Down