Preparing to multi-account search
This commit is contained in:
@@ -3,14 +3,15 @@
|
||||
|
||||
chdir('..');
|
||||
require_once 'common.php';
|
||||
Config::loadFile('app', 'config/app.ini');
|
||||
define('VKTIMEOUT', 1);
|
||||
|
||||
|
||||
$db = Db::getInstance();
|
||||
$vk = new Vkontakte();
|
||||
|
||||
$continue = true;
|
||||
while ($continue) {
|
||||
$queue = $db->getRows($db->q("SELECT * FROM beathaven.queue WHERE status=0 OR status=2 ORDER BY priority DESC, times_failed ASC LIMIT 10"));
|
||||
$queue = $db->getRows($db->q("SELECT * FROM beathaven.queue WHERE status=0 OR status=2 ORDER BY priority DESC, status ASC, times_failed ASC LIMIT 100"));
|
||||
if (!$queue || count($queue) == 0) {
|
||||
$continue = false;
|
||||
} else {
|
||||
@@ -19,6 +20,7 @@ while ($continue) {
|
||||
echo "Loading file list: ";
|
||||
$t1 = microtime(true);
|
||||
$vk->parse($t['track_title']);
|
||||
$vk->parseHtml();
|
||||
$files = $vk->getFiles();
|
||||
if ($files && count($files) > 0) {
|
||||
echo "OK (".count($files).")\n";
|
||||
@@ -27,14 +29,17 @@ while ($continue) {
|
||||
BeatDB::set($t['track_id'], $files);
|
||||
echo "Good files: ". count($files) ."\n\n";
|
||||
$db->q("UPDATE beathaven.queue SET status=1 WHERE track_id=". $t['track_id']);
|
||||
@unlink('/www/parser_data/html/'. $t['track_id'] .'.html');
|
||||
} else {
|
||||
file_put_contents('/www/parser_data/html/'. $t['track_id'] .'.html', $vk->getHtml());
|
||||
echo "FAILED\n\n";
|
||||
$db->q("UPDATE beathaven.queue SET status = 2, times_failed = times_failed + 1 WHERE track_id=". $t['track_id']);
|
||||
}
|
||||
$t2 = microtime(true);
|
||||
if ($t2 - $t1 < 5) {
|
||||
sleep(ceil(5 - ($t2 - $t1)));
|
||||
if ($t2 - $t1 < VKTIMEOUT) {
|
||||
sleep(ceil(VKTIMEOUT - ($t2 - $t1)));
|
||||
}
|
||||
}
|
||||
sleep(5);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
[
|
||||
{
|
||||
"email" : "chezzzy@yandex.ru",
|
||||
"password" : "somepass","user_id":,"remixsid":""}
|
||||
]
|
||||
alexgreen1978@gmail.com
|
||||
fbcn136
|
||||
|
||||
bc5386a4f49f8bf7df20e11bdd311a7120818d83c23d93cd08177d5d3674
|
||||
69139853
|
||||
Executable
+30
@@ -0,0 +1,30 @@
|
||||
#!/opt/local/bin/php
|
||||
<?php
|
||||
|
||||
chdir('../..');
|
||||
require_once 'common.php';
|
||||
|
||||
$workers = json_decode(file_get_contents('/www/parser_data/pid'));
|
||||
if (!$workers) {
|
||||
$workers = array('html_grabber' => array(), 'curl_mtgrabber' => array());
|
||||
}
|
||||
|
||||
switch ($argv[1]) {
|
||||
case 'add':
|
||||
shell_exec("./worker_". $argv[2] .".php > /www/parse.log &");
|
||||
break;
|
||||
case 'remove':
|
||||
if (isset($workers[$argv[2]]) && count($workers[$argv[2]]) > 0) {
|
||||
$pid = $workers[$argv[2]][0];
|
||||
shell_exec("kill $pid");
|
||||
}
|
||||
case 'status':
|
||||
|
||||
case 'list':
|
||||
foreach($workers as $type => $pids) {
|
||||
echo "$type: ". count($pids) ."\n";
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
#!/opt/local/bin/php
|
||||
<?php
|
||||
|
||||
chdir('../..');
|
||||
require_once 'common.php';
|
||||
|
||||
$db = Db::getInstance();
|
||||
$vk = new Vkontakte();
|
||||
|
||||
$continue = true;
|
||||
while ($continue) {
|
||||
$queue = $db->getRows($db->q("SELECT * FROM beathaven.queue WHERE status=0 OR status=2 ORDER BY priority DESC, times_failed ASC LIMIT 10"));
|
||||
if (!$queue || count($queue) == 0) {
|
||||
$continue = false;
|
||||
} else {
|
||||
foreach ($queue as $t) {
|
||||
echo "#{$t['track_id']} {$t['track_title']}\n";
|
||||
|
||||
$vk->parse($t['track_title']);
|
||||
echo $vk->getHtml();
|
||||
|
||||
$db->q("UPDATE beathaven.queue SET status=1 WHERE track_id=". $t['track_id']);
|
||||
} else {
|
||||
echo "FAILED\n\n";
|
||||
$db->q("UPDATE beathaven.queue SET status = 2, times_failed = times_failed + 1 WHERE track_id=". $t['track_id']);
|
||||
}
|
||||
$t2 = microtime(true);
|
||||
if ($t2 - $t1 < 5) {
|
||||
sleep(ceil(5 - ($t2 - $t1)));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user