forked from MrBesen/YoutubeCrawler
nocrawl
This commit is contained in:
parent
a5abe7f08e
commit
10fdcda095
|
@ -259,11 +259,12 @@ public class DB implements Runnable {
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
ResultSet count = query("SELECT `" + db + "`.`getLimit`();");
|
log.info("Started Refilling.");
|
||||||
|
ResultSet count = query("SELECT `" + db + "`.`getLimit`() as 'l';");
|
||||||
if(count != null) {
|
if(count != null) {
|
||||||
try {
|
try {
|
||||||
if(count.next()) {
|
if(count.next()) {
|
||||||
int max = count.getInt(1);
|
int max = count.getInt("l");
|
||||||
ResultSet set = query("SELECT `id` FROM `videos` LIMIT " + rand.nextInt(max) + ",100;");
|
ResultSet set = query("SELECT `id` FROM `videos` LIMIT " + rand.nextInt(max) + ",100;");
|
||||||
if(set != null) {
|
if(set != null) {
|
||||||
while(set.next()) {
|
while(set.next()) {
|
||||||
|
|
|
@ -25,15 +25,27 @@ public class Main implements CommandHandler, EventListener{
|
||||||
private TelegramAPI tapi;
|
private TelegramAPI tapi;
|
||||||
private Thread mainthread;
|
private Thread mainthread;
|
||||||
private static Main main;
|
private static Main main;
|
||||||
|
private boolean startcrawler = true;
|
||||||
|
|
||||||
public static Main getMain() {
|
public static Main getMain() {
|
||||||
return main;
|
return main;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
main = new Main();
|
boolean startcrawl = true;
|
||||||
|
for(String arg : args) {
|
||||||
|
if(arg.equalsIgnoreCase("--nocrawl")) {
|
||||||
|
startcrawl = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
main = new Main(startcrawl);
|
||||||
main.run();
|
main.run();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Main(boolean startcra) {
|
||||||
|
startcrawler = startcra;
|
||||||
|
}
|
||||||
|
|
||||||
private Crawler cra;
|
private Crawler cra;
|
||||||
|
|
||||||
|
@ -50,7 +62,9 @@ public class Main implements CommandHandler, EventListener{
|
||||||
//starting crawler
|
//starting crawler
|
||||||
cra = new Crawler();
|
cra = new Crawler();
|
||||||
Thread t = new Thread(cra, "Crawler");
|
Thread t = new Thread(cra, "Crawler");
|
||||||
t.start();
|
if(startcrawler) {
|
||||||
|
t.start();
|
||||||
|
}
|
||||||
|
|
||||||
//starting BOT API
|
//starting BOT API
|
||||||
tapi = new TelegramAPI(Config.prop.getProperty("telegramapi.key"));
|
tapi = new TelegramAPI(Config.prop.getProperty("telegramapi.key"));
|
||||||
|
@ -96,6 +110,9 @@ public class Main implements CommandHandler, EventListener{
|
||||||
for(String line : cra.getStats().split("\n")) {
|
for(String line : cra.getStats().split("\n")) {
|
||||||
log.info(line);
|
log.info(line);
|
||||||
}
|
}
|
||||||
|
} else if(in.equalsIgnoreCase("crastop")) {
|
||||||
|
log.info("Stop crawler");
|
||||||
|
cra.stop();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
s.close();
|
s.close();
|
||||||
|
|
|
@ -36,8 +36,8 @@ public class Server implements Runnable {
|
||||||
public void run() {
|
public void run() {
|
||||||
try {
|
try {
|
||||||
final int port = 2419;
|
final int port = 2419;
|
||||||
ssoc = new ServerSocket();
|
ssoc = new ServerSocket(port, -1, InetAddress.getByName("::1"));
|
||||||
ssoc.bind(new InetSocketAddress(InetAddress.getByName("::1"), port));
|
//ssoc.bind(new InetSocketAddress(, port));
|
||||||
ssoc.setSoTimeout(5);
|
ssoc.setSoTimeout(5);
|
||||||
log.info("opened Server at port " + port);
|
log.info("opened Server at port " + port);
|
||||||
while(run) {
|
while(run) {
|
||||||
|
|
Loading…
Reference in New Issue