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