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) {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user