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:
@ -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