1
0
Fork 0

Merge branch 'master' of github.com:magnolia-fan/BeatHaven

This commit is contained in:
magnolia-fan 2011-04-04 22:08:16 +04:00
commit cd1dad39fc
5 changed files with 17 additions and 56 deletions

View File

@ -1,45 +0,0 @@
#!/opt/local/bin/php
<?php
chdir('..');
require_once 'common.php';
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, status ASC, times_failed ASC LIMIT 100"));
if (!$queue || count($queue) == 0) {
$continue = false;
} else {
foreach ($queue as $t) {
echo "#{$t['track_id']} {$t['track_title']}\n";
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";
$tmp = explode(' - ', $t['track_title']); $artist_name = $tmp[0]; unset($tmp[0]); $track_name = implode(' - ', $tmp);
$files = VkontakteMP3::check($files, $artist_name, $track_name, $t['track_length']);
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 < VKTIMEOUT) {
sleep(ceil(VKTIMEOUT - ($t2 - $t1)));
}
}
sleep(5);
}
}

View File

@ -1,8 +1,7 @@
#!/opt/local/bin/php
<?php
chdir('../..');
require_once 'common.php';
require_once '/www/server/php/common.php';
$tmp = array_slice(scandir(Config::get('app:Parser:bot_stats_dir')), 2);
$bots = array();
@ -28,14 +27,14 @@ switch ($argv[1]) {
echo $bot_name ." is working already\n";
} else {
echo "Launching ". $bot_name ."\n";
shell_exec("./worker_html_grabber.php ". $bot_name ." > /www/parser_data/log/". $bot_name .".log &");
shell_exec(ROOT_DIR ."/bin/parser/worker_html_grabber.php ". $bot_name ." > /www/parser_data/log/". $bot_name .".log &");
}
} else {
$bots = custom_shuffle($bots);
foreach ($bots as $name => $bot) {
if (!$bot->active) {
echo "Launching ". $name ."\n";
shell_exec("./worker_html_grabber.php ". $name ." > /www/parser_data/log/". $name .".log &");
shell_exec(ROOT_DIR ."/bin/parser/worker_html_grabber.php ". $name ." > /www/parser_data/log/". $name .".log &");
die;
}
}

View File

@ -1,8 +1,7 @@
#!/opt/local/bin/php
<?php
chdir('../..');
require_once 'common.php';
require_once '/www/server/php/common.php';
// Минимальный интервал между запросами
define('VKTIMEOUT', 10);

View File

@ -1,13 +1,13 @@
<?php
define('ROOT_DIR', getcwd());
define('ROOT_DIR', dirname(__FILE__));
require_once ROOT_DIR .'/autoload.php';
// Конфиг приложения
Config::loadFile('app', 'config/app.ini');
Config::loadFile('app', ROOT_DIR .'/config/app.ini');
// Конфиг ботов
Config::loadFile('bot', 'config/accounts.ini');
Config::loadFile('bot', ROOT_DIR .'/config/accounts.ini');
date_default_timezone_set('Europe/Moscow');

View File

@ -26,7 +26,7 @@ user_agent = "Mozilla/5.0 (Macintosh; U; PPC Max OS X Mach-O; en-US; rv:1.8.0.7)
user_id = "382067"
email = ""
password = ""
remixsid = "cb644ff8d678979d7c3ce56344a2ffdcca5091c032fffbe367d420221a1f"
remixsid = "9afa6f2e6d352b01d1a3742b2c0f6c09dbefe2158f3dcb61d30fe438dbc2"
remixchk = "5"
user_agent = "Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_6; en-US) AppleWebKit/534.16 (KHTML, like Gecko) Chrome/10.0.648.204 Safari/534.16"
@ -36,4 +36,12 @@ email = ""
password = ""
remixsid = "832fae47c8dfc8df66551b8c72927ca26f6ee49f5754b24e9a9a317805c5"
remixchk = "5"
user_agent = "Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0; WebMoney Advisor; GTB6.3; InfoPath.2; .NET CLR 1.1.4322; .NET CLR 2.0.50727; .NET CLR 3.0.04506.648; .NET CLR 3.5.21022; OfficeLiveConnector.1.3; OfficeLivePatch.0.0; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729)"
user_agent = "Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0; WebMoney Advisor; GTB6.3; InfoPath.2; .NET CLR 1.1.4322; .NET CLR 2.0.50727; .NET CLR 3.0.04506.648; .NET CLR 3.5.21022; OfficeLiveConnector.1.3; OfficeLivePatch.0.0; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729)"
[Paganini] ; Tom_Orrow
user_id = "1554168"
email = "agent_smith@gmail.ru"
password = "GoTo17db14DB"
remixsid = "cf89c2e8ef6ab2337c3b4ef22bdd38be70c880da7f9ef73ff7d02ff9608e"
remixchk = "5"
user_agent = "Mozilla/5.0 (X11; U; Linux i686; en-US) AppleWebKit/534.16 (KHTML, like Gecko) Chrome/10.0.648.204 Safari/534.16"