Merge branch 'main' into release
This commit is contained in:
commit
2e60670ebc
13 changed files with 183 additions and 59 deletions
|
@ -1,4 +0,0 @@
|
||||||
Manifest-Version: 1.0
|
|
||||||
Build-Jdk-Spec: 17
|
|
||||||
Created-By: Maven Integration for Eclipse
|
|
||||||
|
|
|
@ -1,7 +0,0 @@
|
||||||
#Generated by Maven Integration for Eclipse
|
|
||||||
#Sun Mar 03 02:06:38 CET 2024
|
|
||||||
m2e.projectLocation=C\:\\Users\\jansc\\eclipse-workspace\\ExtremeDemonList
|
|
||||||
m2e.projectName=ExtremeDemonList
|
|
||||||
groupId=ExtremeDemonList
|
|
||||||
artifactId=ExtremeDemonList
|
|
||||||
version=0.0.1-SNAPSHOT
|
|
|
@ -1,39 +0,0 @@
|
||||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
|
|
||||||
<modelVersion>4.0.0</modelVersion>
|
|
||||||
<groupId>ExtremeDemonList</groupId>
|
|
||||||
<artifactId>ExtremeDemonList</artifactId>
|
|
||||||
<version>0.0.1-SNAPSHOT</version>
|
|
||||||
<!-- https://mvnrepository.com/artifact/org.json/json -->
|
|
||||||
<dependencies>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.json</groupId>
|
|
||||||
<artifactId>json</artifactId>
|
|
||||||
<version>20140107</version>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.google.code.gson</groupId>
|
|
||||||
<artifactId>gson</artifactId>
|
|
||||||
<version>2.8.6</version>
|
|
||||||
</dependency>
|
|
||||||
<!-- https://mvnrepository.com/artifact/commons-io/commons-io -->
|
|
||||||
<dependency>
|
|
||||||
<groupId>commons-io</groupId>
|
|
||||||
<artifactId>commons-io</artifactId>
|
|
||||||
<version>2.6</version>
|
|
||||||
</dependency>
|
|
||||||
</dependencies>
|
|
||||||
<build>
|
|
||||||
<directory>${project.basedir}/builds</directory>
|
|
||||||
<sourceDirectory>src</sourceDirectory>
|
|
||||||
<plugins>
|
|
||||||
<plugin>
|
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
|
||||||
<artifactId>maven-compiler-plugin</artifactId>
|
|
||||||
<version>3.10.1</version> <!-- Stelle sicher, dass diese Version Java 17 unterstützt -->
|
|
||||||
<configuration>
|
|
||||||
<release>17</release> <!-- Setze dies auf die gewünschte Java-Version -->
|
|
||||||
</configuration>
|
|
||||||
</plugin>
|
|
||||||
</plugins>
|
|
||||||
</build>
|
|
||||||
</project>
|
|
10
pom.xml
10
pom.xml
|
@ -31,6 +31,16 @@
|
||||||
<groupId>com.formdev</groupId>
|
<groupId>com.formdev</groupId>
|
||||||
<artifactId>flatlaf</artifactId>
|
<artifactId>flatlaf</artifactId>
|
||||||
<version>3.4</version>
|
<version>3.4</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.alex1304.jdash</groupId>
|
||||||
|
<artifactId>jdash-client</artifactId>
|
||||||
|
<version>4.0.5</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>javazoom</groupId>
|
||||||
|
<artifactId>jlayer</artifactId>
|
||||||
|
<version>1.0.1</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
<build>
|
<build>
|
||||||
|
|
29
src/api/GetApiData.java
Normal file
29
src/api/GetApiData.java
Normal file
|
@ -0,0 +1,29 @@
|
||||||
|
package api;
|
||||||
|
|
||||||
|
import jdash.client.GDClient;
|
||||||
|
import jdash.common.entity.GDLevel;
|
||||||
|
|
||||||
|
public class GetApiData {
|
||||||
|
|
||||||
|
public String getSongURL(int id) {
|
||||||
|
|
||||||
|
GDClient client = GDClient.create();
|
||||||
|
GDLevel level = client.findLevelById(id).block();
|
||||||
|
|
||||||
|
String url = level.song().get().downloadUrl() + "";
|
||||||
|
url = url.substring(url.indexOf("[") + 1, url.length() - 1);
|
||||||
|
|
||||||
|
return url;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getSongID(int id) {
|
||||||
|
GDClient client = GDClient.create();
|
||||||
|
GDLevel level = client.findLevelById(id).block();
|
||||||
|
|
||||||
|
String songID = level.songId().get() + "";
|
||||||
|
songID = songID.substring(songID.indexOf("[") + 1, songID.length() - 1);
|
||||||
|
|
||||||
|
return songID;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -25,10 +25,6 @@ public class GuiData {
|
||||||
|
|
||||||
private FetchData data = new FetchData();
|
private FetchData data = new FetchData();
|
||||||
|
|
||||||
public void setId(ArrayList<String> id) {
|
|
||||||
this.id = id;
|
|
||||||
}
|
|
||||||
|
|
||||||
private int localLength;
|
private int localLength;
|
||||||
|
|
||||||
public int getLocalLength() {
|
public int getLocalLength() {
|
||||||
|
|
|
@ -28,7 +28,6 @@ public class ManageFiles {
|
||||||
fetch.getGithubString();
|
fetch.getGithubString();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
for(int i = 0; i < fetch.allLevels().size(); i++) {
|
for(int i = 0; i < fetch.allLevels().size(); i++) {
|
||||||
|
|
||||||
File file = new File("C:\\ExtremeDemonList\\levels\\" + fetch.allLevels().get(i) + ".json");
|
File file = new File("C:\\ExtremeDemonList\\levels\\" + fetch.allLevels().get(i) + ".json");
|
||||||
|
|
|
@ -8,6 +8,8 @@ public class CreateFileStructure {
|
||||||
|
|
||||||
File file = new File("C:\\ExtremeDemonList\\levels");
|
File file = new File("C:\\ExtremeDemonList\\levels");
|
||||||
File file2 = new File("C:\\ExtremeDemonList\\completed");
|
File file2 = new File("C:\\ExtremeDemonList\\completed");
|
||||||
|
File file3 = new File("C:\\ExtremeDemonList\\index");
|
||||||
|
File file4 = new File("C:\\ExtremeDemonList\\songs");
|
||||||
|
|
||||||
if(!file.isDirectory()) {
|
if(!file.isDirectory()) {
|
||||||
file.mkdirs();
|
file.mkdirs();
|
||||||
|
@ -17,6 +19,14 @@ public class CreateFileStructure {
|
||||||
file2.mkdirs();
|
file2.mkdirs();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(!file3.exists()) {
|
||||||
|
file3.mkdirs();
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!file4.exists()) {
|
||||||
|
file4.mkdirs();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -204,7 +204,7 @@ public class MainGUI {
|
||||||
public void actionPerformed(ActionEvent e) {
|
public void actionPerformed(ActionEvent e) {
|
||||||
String url = data.getYoutubeLink().get(index);
|
String url = data.getYoutubeLink().get(index);
|
||||||
VerifyInfo ver = VerifyInfo.getInstance();
|
VerifyInfo ver = VerifyInfo.getInstance();
|
||||||
ver.showInfo(url);
|
ver.showInfo(url, Integer.parseInt(data.getId().get(index)));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,9 @@
|
||||||
package gui;
|
package gui;
|
||||||
|
|
||||||
|
import java.awt.Button;
|
||||||
import java.awt.Image;
|
import java.awt.Image;
|
||||||
|
import java.awt.event.ActionEvent;
|
||||||
|
import java.awt.event.ActionListener;
|
||||||
import java.awt.image.BufferedImage;
|
import java.awt.image.BufferedImage;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
|
@ -10,21 +13,46 @@ import javax.swing.ImageIcon;
|
||||||
import javax.swing.JFrame;
|
import javax.swing.JFrame;
|
||||||
import javax.swing.JLabel;
|
import javax.swing.JLabel;
|
||||||
|
|
||||||
|
import api.GetApiData;
|
||||||
|
import media.PlaySong;
|
||||||
|
|
||||||
public class VerifyInfo {
|
public class VerifyInfo {
|
||||||
|
|
||||||
private static VerifyInfo instance = null;
|
private static VerifyInfo instance = null;
|
||||||
|
|
||||||
private JFrame frame;
|
private JFrame frame;
|
||||||
private JLabel ytthumbnail;
|
private JLabel ytthumbnail;
|
||||||
|
private Button playsong;
|
||||||
|
private int currentSongId; // Instanzvariable für die ID
|
||||||
|
|
||||||
|
private PlaySong player;
|
||||||
|
private GetApiData data;
|
||||||
|
|
||||||
private VerifyInfo() {
|
private VerifyInfo() {
|
||||||
frame = new JFrame("Verifikationsinfos");
|
frame = new JFrame("Mehr Infos");
|
||||||
ytthumbnail = new JLabel();
|
ytthumbnail = new JLabel();
|
||||||
|
playsong = new Button("Songpreview abspielen");
|
||||||
|
|
||||||
|
playsong.setBounds(90, 200, 200 ,30);
|
||||||
|
|
||||||
frame.setSize(400, 300);
|
frame.setSize(400, 300);
|
||||||
frame.setResizable(false);
|
frame.setResizable(false);
|
||||||
frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
|
frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
|
||||||
frame.setLayout(null);
|
frame.setLayout(null);
|
||||||
|
|
||||||
|
player = new PlaySong();
|
||||||
|
data = new GetApiData();
|
||||||
|
|
||||||
|
playsong.addActionListener(new ActionListener() {
|
||||||
|
@Override
|
||||||
|
public void actionPerformed(ActionEvent e) {
|
||||||
|
playSongAction();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
private void playSongAction() {
|
||||||
|
player.play(data.getSongURL(currentSongId), data.getSongID(currentSongId)); // Verwende die Instanzvariable für die ID
|
||||||
}
|
}
|
||||||
|
|
||||||
public static VerifyInfo getInstance() {
|
public static VerifyInfo getInstance() {
|
||||||
|
@ -34,10 +62,11 @@ public class VerifyInfo {
|
||||||
return instance;
|
return instance;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void showInfo(String url) {
|
public void showInfo(String url, int id) {
|
||||||
frame.getContentPane().removeAll(); // Clear previous content
|
frame.getContentPane().removeAll(); // Clear previous content
|
||||||
|
|
||||||
ytthumbnail.setBounds(90, 70, 200, 110);
|
ytthumbnail.setBounds(90, 70, 200, 110);
|
||||||
|
currentSongId = id; // Setze die Instanzvariable auf die aktuelle ID
|
||||||
|
|
||||||
if (url != null && url.contains("v=")) {
|
if (url != null && url.contains("v=")) {
|
||||||
int startIndex = url.indexOf("v=") + 2;
|
int startIndex = url.indexOf("v=") + 2;
|
||||||
|
@ -69,6 +98,7 @@ public class VerifyInfo {
|
||||||
}
|
}
|
||||||
|
|
||||||
frame.add(ytthumbnail);
|
frame.add(ytthumbnail);
|
||||||
|
frame.add(playsong);
|
||||||
frame.setVisible(true);
|
frame.setVisible(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,6 +4,7 @@ import java.io.IOException;
|
||||||
|
|
||||||
import javax.swing.UnsupportedLookAndFeelException;
|
import javax.swing.UnsupportedLookAndFeelException;
|
||||||
|
|
||||||
|
import api.GetApiData;
|
||||||
import data.FetchData;
|
import data.FetchData;
|
||||||
import data.ManageFiles;
|
import data.ManageFiles;
|
||||||
import filestructure.CreateFileStructure;
|
import filestructure.CreateFileStructure;
|
||||||
|
@ -29,7 +30,7 @@ public class Main {
|
||||||
load.updateBar("Liste wird auf Updates geprüft...");
|
load.updateBar("Liste wird auf Updates geprüft...");
|
||||||
|
|
||||||
ManageFiles manager = new ManageFiles();
|
ManageFiles manager = new ManageFiles();
|
||||||
manager.compareArrays();
|
manager.compareArrays();
|
||||||
|
|
||||||
load.updateBar("Ladevorgang abgeschlossen");
|
load.updateBar("Ladevorgang abgeschlossen");
|
||||||
load.close();
|
load.close();
|
||||||
|
|
96
src/media/PlaySong.java
Normal file
96
src/media/PlaySong.java
Normal file
|
@ -0,0 +1,96 @@
|
||||||
|
package media;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.FileInputStream;
|
||||||
|
import java.io.FileNotFoundException;
|
||||||
|
import java.io.FileOutputStream;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.InputStream;
|
||||||
|
import java.net.HttpURLConnection;
|
||||||
|
import java.net.URL;
|
||||||
|
|
||||||
|
import javazoom.jl.decoder.JavaLayerException;
|
||||||
|
import javazoom.jl.player.advanced.AdvancedPlayer;
|
||||||
|
|
||||||
|
public class PlaySong {
|
||||||
|
|
||||||
|
public void play(String link, String id) {
|
||||||
|
checkExisting(id, link);
|
||||||
|
}
|
||||||
|
|
||||||
|
private synchronized void checkExisting(String songId, String link) {
|
||||||
|
String path = "C:/ExtremeDemonList/songs/" + songId + ".mp3";
|
||||||
|
File file = new File(path);
|
||||||
|
|
||||||
|
if(file.exists()) {
|
||||||
|
playSong(path);
|
||||||
|
} else {
|
||||||
|
downloadSong(link, songId);
|
||||||
|
playSong(path);
|
||||||
|
System.out.println("nein");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void playSong(String path) {
|
||||||
|
String filePath = path; // Passe den Pfad zu deiner MP3-Datei an
|
||||||
|
|
||||||
|
try {
|
||||||
|
FileInputStream fis = new FileInputStream(filePath);
|
||||||
|
AdvancedPlayer player = new AdvancedPlayer(fis);
|
||||||
|
|
||||||
|
// Starte das Abspielen in einem neuen Thread, damit der Hauptthread nicht blockiert wird
|
||||||
|
Thread playerThread = new Thread(() -> {
|
||||||
|
try {
|
||||||
|
player.play();
|
||||||
|
} catch (JavaLayerException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
playerThread.start();
|
||||||
|
|
||||||
|
// Gib dem Player Zeit, die MP3-Datei abzuspielen
|
||||||
|
Thread.sleep(10000); // Zum Beispiel 10 Sekunden abwarten
|
||||||
|
|
||||||
|
// Beende den Player und schließe die FileInputStream
|
||||||
|
player.close();
|
||||||
|
fis.close();
|
||||||
|
} catch (FileNotFoundException | JavaLayerException | InterruptedException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
} catch (IOException e) {
|
||||||
|
// TODO Auto-generated catch block
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private void downloadSong(String link, String id) {
|
||||||
|
try {
|
||||||
|
URL url = new URL(link);
|
||||||
|
HttpURLConnection httpConn = (HttpURLConnection) url.openConnection();
|
||||||
|
int responseCode = httpConn.getResponseCode();
|
||||||
|
|
||||||
|
if (responseCode == HttpURLConnection.HTTP_OK) {
|
||||||
|
InputStream inputStream = httpConn.getInputStream();
|
||||||
|
String saveFilePath = "C:/ExtremeDemonList/songs/" + id + ".mp3";
|
||||||
|
|
||||||
|
FileOutputStream outputStream = new FileOutputStream(saveFilePath);
|
||||||
|
|
||||||
|
int bytesRead;
|
||||||
|
byte[] buffer = new byte[4096];
|
||||||
|
while ((bytesRead = inputStream.read(buffer)) != -1) {
|
||||||
|
outputStream.write(buffer, 0, bytesRead);
|
||||||
|
}
|
||||||
|
|
||||||
|
outputStream.close();
|
||||||
|
inputStream.close();
|
||||||
|
|
||||||
|
} else {
|
||||||
|
System.out.println("Der Server hat mit dem Statuscode " + responseCode + " geantwortet.");
|
||||||
|
}
|
||||||
|
httpConn.disconnect();
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -10,4 +10,7 @@
|
||||||
requires org.apache.commons.io;
|
requires org.apache.commons.io;
|
||||||
requires java.datatransfer;
|
requires java.datatransfer;
|
||||||
requires com.formdev.flatlaf;
|
requires com.formdev.flatlaf;
|
||||||
|
requires jdash.client;
|
||||||
|
requires jdash.common;
|
||||||
|
requires jlayer;
|
||||||
}
|
}
|
Loading…
Reference in a new issue