* * Read album art from Amazon PAS service * Be sure to review and complete the cloudfusion configuration in config/ * * @package streeme * @author Richard Hoar */ if (sfConfig::get('sf_environment') === 'test') { //load a mock for testing - simulates the expected response from amazon for integration tests require_once dirname(__FILE__) . '/../../../test/files/cloudfusion.php'; require_once dirname(__FILE__) . '/../../../test/files/cloudfusion.class.php'; } else { require_once dirname(__FILE__) . '/../../../config/cloudfusion.php'; require_once dirname(__FILE__) . '/../../vendor/cloudfusion/cloudfusion.class.php'; } $artwork_scanner = new ArtworkScan('amazon'); $associate_services = new AmazonPAS(); $artwork_list = $artwork_scanner->get_unscanned_artwork_list(); $current_album_id = 0; if (count($artwork_list) == 0) { echo "*** Songs have all been cross-checked with Amazon ***"; } foreach ($artwork_list as $key => $value) { //this album has copied art, skip to the next album if ($current_album_id == $value['album_id']) { continue; } $art_dir = dirname(__FILE__) . '/../../../data/album_art/' . md5($value['artist_name'] . $value['album_name']); echo 'Scanning: ' . $value['album_name'] . ' by: ' . $value['artist_name'] . "\r\n"; $opts = array('Artist' => $value['artist_name'], 'Creator' => $value['artist_name'], 'SearchIndex' => 'Music', 'ResponseGroup' => 'Medium'); //Sometimes Amazon returns malformed xml, so we need to catch exceptions. We'll try again on a later scan.
<?php include dirname(__FILE__) . '/../bootstrap/doctrine.php'; // Initialize the test object $t = new lime_test(12, new lime_output_color()); //add the required fixtures Doctrine::loadData(sfConfig::get('sf_test_dir') . '/fixtures/40_ArtworkScan'); $artwork_scan = new ArtworkScan('meta'); $t->comment('->construct() ->get_last_scan_id() ->get_source()'); $t->like($artwork_scan->get_last_scan_id(), '/\\d+/', 'Entered a new scan id successfully.'); $t->is($artwork_scan->get_source(), 'meta', 'Source identifier passed'); $t->comment('->get_unscanned_artwork_list()'); $list = $artwork_scan->get_unscanned_artwork_list(); $count = count($list); $t->is($count, 2, 'Got the unscanned album list for ID3 metadata'); $t->comment('->flag_as_skipped()'); $t->is($artwork_scan->flag_as_skipped(1), true, 'flagged album 1 as skipped for meta'); $list = $artwork_scan->get_unscanned_artwork_list(); $count = count($list); $t->is($count, 1, 'Listing is up to date'); $t->comment('->flag_as_added()'); $t->is($artwork_scan->flag_as_added(2), true, 'flagged album 2 as added for meta'); $list = $artwork_scan->get_unscanned_artwork_list(); $count = count($list); $t->is($count, 0, 'Listing is up to date'); //test integrity $album_table = Doctrine_Core::getTable('Album'); $album = $album_table->find(1); $t->is($album->meta_flagged, 1, 'Album 1 was scanned'); $t->is($album->has_art, 0, 'Album 1 does not have art'); $album = $album_table->find(2);