Skip to content

Commit

Permalink
Switch to lavalink's lavaplayer fork (#1490)
Browse files Browse the repository at this point in the history
* Switch to lavalink's lavaplayer fork

* Create logback turbofilter to suppress YouTube auth tokens warning

* added license header

---------

Co-authored-by: unknown <[email protected]>
  • Loading branch information
MichailiK and jagrosh authored Mar 5, 2024
1 parent 6752695 commit 49c3ec7
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 11 deletions.
21 changes: 10 additions & 11 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,11 @@
<name>m2-duncte123</name>
<url>https://m2.duncte123.dev/releases</url>
</repository>
<repository>
<id>arbjergDev-snapshots</id>
<name>Lavalink Repository</name>
<url>https://maven.lavalink.dev/snapshots</url>
</repository>
</repositories>

<dependencies>
Expand All @@ -47,17 +52,11 @@
</dependency>

<!-- Music Dependencies -->
<!-- using a fork of this to fix some issues faster -->
<!-- dependency>
<groupId>com.sedmelluq</groupId>
<artifactId>lavaplayer</artifactId>
<version>1.3.78</version>
</dependency -->
<dependency>
<groupId>com.github.jagrosh</groupId>
<artifactId>lavaplayer</artifactId>
<version>jmusicbot-SNAPSHOT</version>
</dependency>
<groupId>dev.arbjerg</groupId>
<artifactId>lavaplayer</artifactId>
<version>727959e9f621fc457b3a5adafcfffb55fdeaa538-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>com.github.jagrosh</groupId>
<artifactId>JLyrics</artifactId>
Expand All @@ -68,7 +67,7 @@
<artifactId>sourcemanagers</artifactId>
<version>1.9.0</version>
</dependency>

<!-- Misc Internal Dependencies -->
<dependency>
<groupId>ch.qos.logback</groupId>
Expand Down
44 changes: 44 additions & 0 deletions src/main/java/com/jagrosh/jmusicbot/utils/LogBackTurboFilter.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
/*
* Copyright 2024 John Grosh <[email protected]>.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.jagrosh.jmusicbot.utils;

import ch.qos.logback.classic.Level;
import ch.qos.logback.classic.Logger;
import ch.qos.logback.classic.turbo.TurboFilter;
import ch.qos.logback.core.spi.FilterReply;
import org.slf4j.Marker;

/**
* A TurboFilter, currently only used to suppress specific log messages from libraries.
*
* @author Michaili K. <[email protected]>
*/
public class LogBackTurboFilter extends TurboFilter
{
@Override
public FilterReply decide(Marker marker, Logger logger, Level level, String format, Object[] params, Throwable t)
{
// Suppresses the auth token warning from the YoutubeAudioSourceManager
// https://github.com/jagrosh/MusicBot/pull/1490#issuecomment-1974070225
if (logger.getName().equals("com.sedmelluq.discord.lavaplayer.source.youtube.YoutubeAccessTokenTracker")
&& format.equals("YouTube auth tokens can't be retrieved because email and password is not set in YoutubeAudioSourceManager, age restricted videos will throw exceptions.")
) {
return FilterReply.DENY;
}

return FilterReply.NEUTRAL;
}
}
2 changes: 2 additions & 0 deletions src/main/resources/logback.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,6 @@
<appender-ref ref="Simple"/>
</root>

<turboFilter class="com.jagrosh.jmusicbot.utils.LogBackTurboFilter" />

</configuration>

0 comments on commit 49c3ec7

Please sign in to comment.