YoutubeCrawler/src/de/mrbesen/youtubecrawler/Main.java

42 lines
915 B
Java

package de.mrbesen.youtubecrawler;
import java.io.File;
import java.util.Scanner;
import org.apache.log4j.Logger;
public class Main {
public static void main(String[] args) {
//init Logger
new Log(); // init logging, set format etc
Logger log = Logger.getLogger(Main.class.getName());
//loading config
new Config(new File("crawl.conf"));
//starting crawler
Crawler cra = new Crawler();
Thread t = new Thread(cra, "Crawler");
t.start();
//CLI
Scanner s = new Scanner(System.in);
String in;
while((in= s.nextLine()) != null && t.isAlive()) {
if(in.equalsIgnoreCase("stop")) {
cra.stop();
break;
} else if(in.equalsIgnoreCase("add")) {
log.info("please enter ytid:");
String id = s.nextLine().trim();
if(id.length() > 9 && id.length() < 13) {
cra.addtoCrawl(id);
log.info("added.");
}
}
}
s.close();
log.info("Terminated.");
}
}