started migrating to a database
Some checks failed
Locusworks Team/eight-track/pipeline/head There was a failure building this commit
Some checks failed
Locusworks Team/eight-track/pipeline/head There was a failure building this commit
This commit is contained in:
254
pom.xml
254
pom.xml
@ -18,11 +18,18 @@
|
||||
</scm>
|
||||
|
||||
<properties>
|
||||
<log4j.version>2.11.2</log4j.version>
|
||||
<slf4j.version>1.7.26</slf4j.version>
|
||||
<nexus.repo>http://nexus.locusworks.net</nexus.repo>
|
||||
<flyway.version>6.0.3</flyway.version>
|
||||
<mariadb.version>2.4.4</mariadb.version>
|
||||
<hibernate.version>5.4.4.Final</hibernate.version>
|
||||
<spring.version>5.1.9.RELEASE</spring.version>
|
||||
<spring.boot.version>2.1.8.RELEASE</spring.boot.version>
|
||||
<spring.data.version>2.1.10.RELEASE</spring.data.version>
|
||||
<log4j.version>2.12.1</log4j.version>
|
||||
<slf4j.version>1.7.28</slf4j.version>
|
||||
<maven.enforcer.version>3.0.0-M2</maven.enforcer.version>
|
||||
<dep.check.version>5.2.2</dep.check.version>
|
||||
<license-maven-plugin.version>3.0</license-maven-plugin.version>
|
||||
<nexus.repo>http://nexus.locusworks.net</nexus.repo>
|
||||
</properties>
|
||||
|
||||
<build>
|
||||
@ -64,33 +71,18 @@
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-shade-plugin</artifactId>
|
||||
<version>3.2.1</version>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||
<version>${spring.boot.version}</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<phase>package</phase>
|
||||
<goals>
|
||||
<goal>shade</goal>
|
||||
<goal>repackage</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<finalName>EightTrack-${project.version}</finalName>
|
||||
<transformers>
|
||||
<transformer
|
||||
implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
|
||||
<mainClass>net.locusworks.discord.eighttrack.main.Entry</mainClass>
|
||||
</transformer>
|
||||
</transformers>
|
||||
<filters>
|
||||
<filter>
|
||||
<artifact>*:*</artifact>
|
||||
<excludes>
|
||||
<exclude>META-INF/*.SF</exclude>
|
||||
<exclude>META-INF/*.DSA</exclude>
|
||||
<exclude>META-INF/*.RSA</exclude>
|
||||
</excludes>
|
||||
</filter>
|
||||
</filters>
|
||||
<finalName>EightTrackApp</finalName>
|
||||
<layout>JAR</layout>
|
||||
<executable />
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
@ -118,21 +110,78 @@
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.flywaydb</groupId>
|
||||
<artifactId>flyway-maven-plugin</artifactId>
|
||||
<version>${flyway.version}</version>
|
||||
<configuration>
|
||||
<url>jdbc:mariadb://devops.locusworks.net:3306/</url>
|
||||
<outOfOrder>false</outOfOrder>
|
||||
<schemas>
|
||||
<schema>eighttrack</schema>
|
||||
</schemas>
|
||||
<table>_flyway_migration</table>
|
||||
<locations>
|
||||
<location>filesystem:${basedir}/src/main/resources/database/migration</location>
|
||||
</locations>
|
||||
</configuration>
|
||||
<!-- <executions> <execution> <phase>process-sources</phase> <goals>
|
||||
<goal>migrate</goal> </goals> </execution> </executions> -->
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.mariadb.jdbc</groupId>
|
||||
<artifactId>mariadb-java-client</artifactId>
|
||||
<version>${mariadb.version}</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
<dependencies>
|
||||
<!-- https://mvnrepository.com/artifact/net.dv8tion/JDA2 -->
|
||||
<dependency>
|
||||
<groupId>net.dv8tion</groupId>
|
||||
<artifactId>JDA</artifactId>
|
||||
<version>4.0.0_46</version>
|
||||
<groupId>net.locusworks</groupId>
|
||||
<artifactId>applogger</artifactId>
|
||||
<version>1.0.3-RELEASE</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>net.locusworks</groupId>
|
||||
<artifactId>applogger</artifactId>
|
||||
<version>1.0.1-RELEASE</version>
|
||||
<artifactId>crypto</artifactId>
|
||||
<version>1.0.3-RELEASE</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.apache.tika</groupId>
|
||||
<artifactId>tika-core</artifactId>
|
||||
<version>1.22</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.apache.tika</groupId>
|
||||
<artifactId>tika-parsers</artifactId>
|
||||
<version>1.22</version>
|
||||
</dependency>
|
||||
|
||||
<!-- https://mvnrepository.com/artifact/net.dv8tion/JDA2 -->
|
||||
<dependency>
|
||||
<groupId>net.dv8tion</groupId>
|
||||
<artifactId>JDA</artifactId>
|
||||
<version>4.0.0_47</version>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>com.fasterxml.jackson.core</groupId>
|
||||
<artifactId>jackson-annotations</artifactId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<groupId>com.fasterxml.jackson.core</groupId>
|
||||
<artifactId>jackson-core</artifactId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<groupId>com.fasterxml.jackson.core</groupId>
|
||||
<artifactId>jackson-databind</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
@ -141,6 +190,149 @@
|
||||
<version>1.3.22</version>
|
||||
</dependency>
|
||||
|
||||
<!-- https://mvnrepository.com/artifact/org.flywaydb/flyway-core -->
|
||||
<dependency>
|
||||
<groupId>org.flywaydb</groupId>
|
||||
<artifactId>flyway-core</artifactId>
|
||||
<version>${flyway.version}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.mariadb.jdbc</groupId>
|
||||
<artifactId>mariadb-java-client</artifactId>
|
||||
<version>${mariadb.version}</version>
|
||||
</dependency>
|
||||
|
||||
<!-- https://mvnrepository.com/artifact/mysql/mysql-connector-java -->
|
||||
<dependency>
|
||||
<groupId>mysql</groupId>
|
||||
<artifactId>mysql-connector-java</artifactId>
|
||||
<version>8.0.17</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.hibernate</groupId>
|
||||
<artifactId>hibernate-entitymanager</artifactId>
|
||||
<version>${hibernate.version}</version>
|
||||
</dependency>
|
||||
|
||||
<!-- https://mvnrepository.com/artifact/org.apache.commons/commons-dbcp2 -->
|
||||
<dependency>
|
||||
<groupId>org.apache.commons</groupId>
|
||||
<artifactId>commons-dbcp2</artifactId>
|
||||
<version>2.7.0</version>
|
||||
</dependency>
|
||||
|
||||
|
||||
<!-- https://mvnrepository.com/artifact/org.springframework.boot/spring-boot -->
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot</artifactId>
|
||||
<version>${spring.boot.version}</version>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>org.springframework</groupId>
|
||||
<artifactId>spring-context</artifactId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<groupId>org.springframework</groupId>
|
||||
<artifactId>spring-core</artifactId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<groupId>org.hibernate</groupId>
|
||||
<artifactId>hibernate-core</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
|
||||
<!-- https://mvnrepository.com/artifact/org.springframework.boot/spring-boot-autoconfigure -->
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-autoconfigure</artifactId>
|
||||
<version>${spring.boot.version}</version>
|
||||
</dependency>
|
||||
|
||||
<!-- Spring Framework jars to be shared across projects -->
|
||||
<dependency>
|
||||
<groupId>org.springframework</groupId>
|
||||
<artifactId>spring-core</artifactId>
|
||||
<version>${spring.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework</groupId>
|
||||
<artifactId>spring-aop</artifactId>
|
||||
<version>${spring.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework</groupId>
|
||||
<artifactId>spring-context</artifactId>
|
||||
<version>${spring.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework</groupId>
|
||||
<artifactId>spring-jdbc</artifactId>
|
||||
<version>${spring.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework</groupId>
|
||||
<artifactId>spring-tx</artifactId>
|
||||
<version>${spring.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.data</groupId>
|
||||
<artifactId>spring-data-jpa</artifactId>
|
||||
<version>${spring.data.version}</version>
|
||||
</dependency>
|
||||
|
||||
<!-- https://mvnrepository.com/artifact/javax.annotation/javax.annotation-api -->
|
||||
<dependency>
|
||||
<groupId>javax.annotation</groupId>
|
||||
<artifactId>javax.annotation-api</artifactId>
|
||||
<version>1.3.2</version>
|
||||
</dependency>
|
||||
|
||||
<!-- https://mvnrepository.com/artifact/com.fasterxml.jackson.core/jackson-core -->
|
||||
<dependency>
|
||||
<groupId>com.fasterxml.jackson.core</groupId>
|
||||
<artifactId>jackson-core</artifactId>
|
||||
<version>2.10.0.pr3</version>
|
||||
</dependency>
|
||||
|
||||
<!-- https://mvnrepository.com/artifact/com.fasterxml.jackson.core/jackson-databind -->
|
||||
<dependency>
|
||||
<groupId>com.fasterxml.jackson.core</groupId>
|
||||
<artifactId>jackson-databind</artifactId>
|
||||
<version>2.10.0.pr3</version>
|
||||
</dependency>
|
||||
|
||||
<!-- https://mvnrepository.com/artifact/com.fasterxml.jackson.core/jackson-annotations -->
|
||||
<dependency>
|
||||
<groupId>com.fasterxml.jackson.core</groupId>
|
||||
<artifactId>jackson-annotations</artifactId>
|
||||
<version>2.10.0.pr3</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>javax.xml.bind</groupId>
|
||||
<artifactId>jaxb-api</artifactId>
|
||||
<version>2.2.11</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.sun.xml.bind</groupId>
|
||||
<artifactId>jaxb-core</artifactId>
|
||||
<version>2.2.11</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.sun.xml.bind</groupId>
|
||||
<artifactId>jaxb-impl</artifactId>
|
||||
<version>2.2.11</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>javax.activation</groupId>
|
||||
<artifactId>activation</artifactId>
|
||||
<version>1.1.1</version>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
<repositories>
|
||||
|
@ -0,0 +1,60 @@
|
||||
package net.locusworks.discord.eighttrack.handlers;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.Paths;
|
||||
|
||||
import org.apache.tika.exception.TikaException;
|
||||
import org.apache.tika.metadata.Metadata;
|
||||
import org.apache.tika.parser.ParseContext;
|
||||
import org.apache.tika.parser.mp3.LyricsHandler;
|
||||
import org.apache.tika.parser.mp3.Mp3Parser;
|
||||
import org.apache.tika.sax.BodyContentHandler;
|
||||
import org.xml.sax.SAXException;
|
||||
|
||||
public class Mp3UploadHandler {
|
||||
|
||||
private Path file;
|
||||
|
||||
public Mp3UploadHandler(Path file) {
|
||||
this.file = file;
|
||||
}
|
||||
|
||||
public void parse() throws IOException, SAXException, TikaException {
|
||||
|
||||
InputStream is = Files.newInputStream(file);
|
||||
|
||||
BodyContentHandler handler = new BodyContentHandler();
|
||||
Metadata metadata = new Metadata();
|
||||
ParseContext context = new ParseContext();
|
||||
|
||||
Mp3Parser parser = new Mp3Parser();
|
||||
|
||||
parser.parse(is, handler, metadata, context);
|
||||
|
||||
LyricsHandler lyrics = new LyricsHandler(is, handler);
|
||||
|
||||
while(lyrics.hasLyrics()) {
|
||||
System.out.println(lyrics.toString());
|
||||
}
|
||||
|
||||
System.out.println("Contents of the document:" + handler.toString());
|
||||
System.out.println("Metadata of the document:");
|
||||
String[] metadataNames = metadata.names();
|
||||
|
||||
for(String name : metadataNames) {
|
||||
System.out.println(name + ": " + metadata.get(name));
|
||||
}
|
||||
}
|
||||
|
||||
public static void main(String args[]) throws IOException, SAXException, TikaException {
|
||||
String file = "S:\\Music\\Alan Walker\\01 Diamond Heart.mp3";
|
||||
Path path = Paths.get(file);
|
||||
|
||||
Mp3UploadHandler fuh = new Mp3UploadHandler(path);
|
||||
fuh.parse();
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,15 @@
|
||||
package net.locusworks.discord.eighttrack.handlers;
|
||||
|
||||
import org.apache.tika.metadata.Metadata;
|
||||
|
||||
public class Mp3UploadResults {
|
||||
|
||||
public Mp3UploadResults( Metadata metadata) {
|
||||
parseResults(metadata);
|
||||
}
|
||||
|
||||
private void parseResults(Metadata metadata) {
|
||||
|
||||
}
|
||||
|
||||
}
|
@ -31,6 +31,10 @@ import java.io.IOException;
|
||||
import java.nio.file.Paths;
|
||||
import javax.security.auth.login.LoginException;
|
||||
|
||||
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.scheduling.annotation.EnableScheduling;
|
||||
|
||||
import net.dv8tion.jda.api.AccountType;
|
||||
import net.dv8tion.jda.api.JDA;
|
||||
import net.dv8tion.jda.api.JDABuilder;
|
||||
@ -38,12 +42,15 @@ import net.locusworks.discord.eighttrack.adaptors.MusicListenerAdaptor;
|
||||
import net.locusworks.logger.ApplicationLogger;
|
||||
import net.locusworks.logger.ApplicationLoggerFactory;
|
||||
|
||||
public class Entry {
|
||||
@SpringBootApplication(scanBasePackages = {"net.locusworks.discord.pseudobot"})
|
||||
@EnableAutoConfiguration
|
||||
@EnableScheduling
|
||||
public class EightTrackLauncher {
|
||||
|
||||
public static void main(String[] args) throws LoginException, IOException {
|
||||
if (args.length < 1) throw new RuntimeException("no token provided");
|
||||
|
||||
ApplicationLogger logger = ApplicationLoggerFactory.getLogger(Entry.class);
|
||||
ApplicationLogger logger = ApplicationLoggerFactory.getLogger(EightTrackLauncher.class);
|
||||
logger.info("Starting Eight-Track");
|
||||
|
||||
JDA client = new JDABuilder(AccountType.BOT).setToken(args[0]).build();
|
@ -0,0 +1,8 @@
|
||||
CREATE TABLE eighttrack.discord_guild (
|
||||
id bigint(20) NOT NULL AUTO_INCREMENT COMMENT 'Auto increment primary key',
|
||||
guild_id bigint(20) NOT NULL COMMENT 'id of the discord guild',
|
||||
guild_name varchar(100) NOT NULL COMMENT 'name of the discord guild',
|
||||
date_joined datetime DEFAULT NULL COMMENT 'date the guild joined',
|
||||
PRIMARY KEY (id),
|
||||
UNIQUE KEY guild_UN (guild_id)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Information about discord guild';
|
@ -0,0 +1,34 @@
|
||||
USE pseudobot;
|
||||
|
||||
DELIMITER $$
|
||||
CREATE PROCEDURE set_optimizer_switch_on()
|
||||
BEGIN
|
||||
IF SUBSTRING(@@version,1,3) = '5.7' THEN
|
||||
SET optimizer_switch = 'derived_merge=on';
|
||||
END IF;
|
||||
END;$$
|
||||
|
||||
CREATE PROCEDURE create_user()
|
||||
BEGIN
|
||||
DECLARE foo BIGINT DEFAULT 0;
|
||||
SELECT COUNT(*) INTO foo FROM mysql.user WHERE User = 'eighttrackAdmin' and Host = 'localhost';
|
||||
IF foo = 0 THEN
|
||||
CREATE USER 'eighttrackAdmin'@'localhost' IDENTIFIED BY 'eighttrackAdmin2017!';
|
||||
END IF;
|
||||
SELECT COUNT(*) INTO foo FROM mysql.user WHERE User = 'eighttrackAdmin' and Host = '%';
|
||||
IF foo = 0 THEN
|
||||
CREATE USER 'eighttrackAdmin'@'%' IDENTIFIED BY 'eighttrackAdmin2017!';
|
||||
END IF;
|
||||
END ;$$
|
||||
|
||||
DELIMITER ;
|
||||
|
||||
CALL set_optimizer_switch_on();
|
||||
DROP PROCEDURE set_optimizer_switch_on;
|
||||
|
||||
CALL create_user();
|
||||
DROP PROCEDURE create_user;
|
||||
|
||||
GRANT SELECT,INSERT,UPDATE,DELETE ON pseudobot.* TO 'eighttrackAdmin'@'localhost';
|
||||
GRANT SELECT,INSERT,UPDATE,DELETE ON pseudobot.* TO 'eighttrackAdmin'@'%';
|
||||
FLUSH PRIVILEGES;
|
Reference in New Issue
Block a user