forked from MrBesen/YoutubeCrawler
nocrawl
This commit is contained in:
parent
a5abe7f08e
commit
10fdcda095
|
@ -259,11 +259,12 @@ public class DB implements Runnable {
|
|||
*/
|
||||
@Override
|
||||
public void run() {
|
||||
ResultSet count = query("SELECT `" + db + "`.`getLimit`();");
|
||||
log.info("Started Refilling.");
|
||||
ResultSet count = query("SELECT `" + db + "`.`getLimit`() as 'l';");
|
||||
if(count != null) {
|
||||
try {
|
||||
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;");
|
||||
if(set != null) {
|
||||
while(set.next()) {
|
||||
|
|
|
@ -25,15 +25,27 @@ public class Main implements CommandHandler, EventListener{
|
|||
private TelegramAPI tapi;
|
||||
private Thread mainthread;
|
||||
private static Main main;
|
||||
private boolean startcrawler = true;
|
||||
|
||||
public static Main getMain() {
|
||||
return main;
|
||||
}
|
||||
|
||||
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();
|
||||
}
|
||||
|
||||
public Main(boolean startcra) {
|
||||
startcrawler = startcra;
|
||||
}
|
||||
|
||||
private Crawler cra;
|
||||
|
||||
|
@ -50,7 +62,9 @@ public class Main implements CommandHandler, EventListener{
|
|||
//starting crawler
|
||||
cra = new Crawler();
|
||||
Thread t = new Thread(cra, "Crawler");
|
||||
t.start();
|
||||
if(startcrawler) {
|
||||
t.start();
|
||||
}
|
||||
|
||||
//starting BOT API
|
||||
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")) {
|
||||
log.info(line);
|
||||
}
|
||||
} else if(in.equalsIgnoreCase("crastop")) {
|
||||
log.info("Stop crawler");
|
||||
cra.stop();
|
||||
}
|
||||
}
|
||||
s.close();
|
||||
|
|
|
@ -36,8 +36,8 @@ public class Server implements Runnable {
|
|||
public void run() {
|
||||
try {
|
||||
final int port = 2419;
|
||||
ssoc = new ServerSocket();
|
||||
ssoc.bind(new InetSocketAddress(InetAddress.getByName("::1"), port));
|
||||
ssoc = new ServerSocket(port, -1, InetAddress.getByName("::1"));
|
||||
//ssoc.bind(new InetSocketAddress(, port));
|
||||
ssoc.setSoTimeout(5);
|
||||
log.info("opened Server at port " + port);
|
||||
while(run) {
|
||||
|
|
Loading…
Reference in New Issue