Skip to content

Commit

Permalink
Removed ffmpeg/youtube-dl win executables.
Browse files Browse the repository at this point in the history
They should now be available on the PATH of the system.

Added a packaging build phase.
  • Loading branch information
marlind89 committed Aug 11, 2016
1 parent 494fd3a commit 26429f9
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 22 deletions.
29 changes: 27 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@
<maven.compiler.target>1.8</maven.compiler.target>
</properties>

<repositories>

<repositories>
<repository>
<id>jcenter</id>
<url>http://jcenter.bintray.com</url>
Expand All @@ -24,6 +25,7 @@
</repository>
</repositories>


<dependencies>
<dependency>
<groupId>com.github.austinv11</groupId>
Expand All @@ -43,4 +45,27 @@
<version>1.3.2</version>
</dependency>
</dependencies>
</project>

<build>
<plugins>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<version>2.6</version>
<configuration>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
</configuration>
<executions>
<execution>
<id>make-assembly</id> <!-- this is used for inheritance merges -->
<phase>package</phase> <!-- bind to the packaging phase -->
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
11 changes: 3 additions & 8 deletions src/main/java/com/github/langebangen/kensa/AudioStreamer.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@

import javax.sound.sampled.AudioSystem;
import javax.sound.sampled.UnsupportedAudioFileException;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
Expand Down Expand Up @@ -95,16 +94,12 @@ private static void streamYoutube(String url, AudioPlayer player, MessageBuilder
UnsupportedAudioFileException
{
//Credits to pangeacake: https://gist.github.com/pangeacake/1fbad48728d56f563cbbdba23243423b
File resourceFolder = new File("src/main/resources").getAbsoluteFile();
String youtubeDlPath = new File(resourceFolder, "youtube-dl.exe").getPath();
String ffmpegPath = new File(resourceFolder, "ffmpeg.exe").getPath();

final String[] title = new String[1];
final String[] readableDuration = new String[1];
new Thread(() ->
{
ProcessBuilder info = new ProcessBuilder(
youtubeDlPath,
"youtube-dl",
"-q", //quiet. No standard out.
"-j", //Print JSON
"--flat-playlist", //Get ONLY the urls of the playlist if this is a playlist.
Expand Down Expand Up @@ -153,15 +148,15 @@ private static void streamYoutube(String url, AudioPlayer player, MessageBuilder


ProcessBuilder youtube = new ProcessBuilder(
youtubeDlPath,
"youtube-dl",
"-q",
"-f", "mp3/bestaudio/best",
"--no-playlist",
"-o", "-",
"--", url
);
ProcessBuilder ffmpeg = new ProcessBuilder(
ffmpegPath,
"ffmpeg",
"-i", "-",
"-f", "mp3", //Format. mp3
"-movflags", "+faststart",
Expand Down
14 changes: 2 additions & 12 deletions src/main/java/com/github/langebangen/kensa/KensaApp.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
import org.slf4j.LoggerFactory;
import sx.blah.discord.api.ClientBuilder;
import sx.blah.discord.api.IDiscordClient;
import sx.blah.discord.api.internal.Opus;
import sx.blah.discord.util.DiscordException;
import sx.blah.discord.util.RateLimitException;

/**
* Main class for Kensa.
Expand Down Expand Up @@ -40,16 +40,6 @@ public static void main(String[] args)
dcClient.getDispatcher().registerListener(new EventListener(dcClient));
dcClient.login();

Runtime.getRuntime().addShutdownHook(new Thread(() ->
{
try
{
dcClient.logout();
}
catch (DiscordException | RateLimitException e)
{
logger.error("Error logging out.", e);
}
}));
logger.info("Opus version:" + Opus.INSTANCE.opus_get_version_string());
}
}
Binary file removed src/main/resources/ffmpeg.exe
Binary file not shown.
Binary file removed src/main/resources/youtube-dl.exe
Binary file not shown.

0 comments on commit 26429f9

Please sign in to comment.