Queue + new parser
This commit is contained in:
parent
78da6e4f11
commit
3bca154729
|
@ -0,0 +1,40 @@
|
|||
#!/opt/local/bin/php
|
||||
<?php
|
||||
|
||||
chdir('..');
|
||||
require_once 'common.php';
|
||||
Config::loadFile('app', 'config/app.ini');
|
||||
|
||||
$artist_name = $argv[1];
|
||||
|
||||
$db = Db::getInstance();
|
||||
$a_model = Model::factory('musicbrainz', 'Artist');
|
||||
$rg_model = Model::factory('musicbrainz', 'ReleaseGroup');
|
||||
$r_model = Model::factory('musicbrainz', 'Release');
|
||||
$t_model = Model::factory('musicbrainz', 'Track');
|
||||
|
||||
$artist_id = $a_model->getId($artist_name);
|
||||
|
||||
if (!$artist_id) {
|
||||
echo "Bad artist name!\n\n\n"; die;
|
||||
}
|
||||
|
||||
$albums = $rg_model->getArtistAlbums($artist_id);
|
||||
$release_groups = $r_model->getReleases(array_keys($albums), true);
|
||||
|
||||
$g_tracks = array();
|
||||
foreach ($release_groups as $release_group => $releases) {
|
||||
$g_tracks[$release_group] = $t_model->getUniqueReleaseTracks(array_keys($releases));
|
||||
}
|
||||
|
||||
foreach($g_tracks as $release_group => $tracks) {
|
||||
$tracks = $tracks['tracks'] + $tracks['bonus'];
|
||||
foreach ($tracks as $track) {
|
||||
$track_id = $track['id'];
|
||||
$track_title = addslashes($artist_name .' - '. $track['name']);
|
||||
$track_length = $track['length'];
|
||||
$q = "INSERT INTO beathaven.queue VALUES({$track_id}, 0, E'{$track_title}', {$track_length});";
|
||||
echo $q."\n";
|
||||
$db->q($q);
|
||||
}
|
||||
}
|
|
@ -1,4 +0,0 @@
|
|||
#!/usr/bin/php
|
||||
<?php
|
||||
|
||||
echo 1;
|
|
@ -0,0 +1,35 @@
|
|||
#!/opt/local/bin/php
|
||||
<?php
|
||||
|
||||
chdir('..');
|
||||
require_once 'common.php';
|
||||
Config::loadFile('app', 'config/app.ini');
|
||||
|
||||
$db = Db::getInstance();
|
||||
$vk = new Vkontakte();
|
||||
|
||||
$continue = true;
|
||||
while ($continue) {
|
||||
$queue = $db->getRows($db->q("SELECT * FROM beathaven.queue WHERE status=0 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: ";
|
||||
$vk->parse($t['track_title']);
|
||||
$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']);
|
||||
} else {
|
||||
echo "FAILED\n\n";
|
||||
$db->q("UPDATE beathaven.queue SET status=2 WHERE track_id=". $t['track_id']);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -5,7 +5,7 @@
|
|||
|
||||
$vk_parser = new Vkontakte();
|
||||
$vk_parser->parse('Blondie - Call Me');
|
||||
$files = $weight_calc->getFiles();
|
||||
$files = $vk_parser->getFiles();
|
||||
*****************************************************************/
|
||||
|
||||
/**
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
|
||||
$vk_parser = new Vkontakte();
|
||||
$vk_parser->parse('Blondie - Call Me');
|
||||
$files = $weight_calc->getFiles();
|
||||
$files = $vk_parser->getFiles();
|
||||
*****************************************************************/
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in New Issue