コード例 #1
0
 } catch (Exception $e) {
     echo sprintf('Error: Amazon returned invalid response for %s by: %s', $value['album_name'], $value['artist_name']) . "\r\n";
     continue;
 }
 //error codes - just show the error and skip
 if (isset($result->body->Error->Code) || !empty($result->body->Error->Code)) {
     //don't scan further files in this album
     $current_album_id = $value['album_id'];
     echo "Error: " . (string) $result->body->Error->Message . "\r\n";
     continue;
 }
 //Mark failed search requests as skipped - product likely doesn't exist in amazon catalog
 if (@(string) $result->body->Items->Request->Errors->Error->Code == "AWS.ECommerceService.NoExactMatches") {
     //don't scan further files in this album
     $current_album_id = $value['album_id'];
     $artwork_scanner->flag_as_skipped($value['album_id']);
     continue;
 }
 //loop through the amazon imagesets until the array has an entry for every image
 //prefer the first results in each imageset as they tend to be front box art
 $imageurls = array();
 if (!isset($result->body->Items->Item->ImageSets->ImageSet)) {
     //there's no art to use
     $current_album_id = $value['album_id'];
     $artwork_scanner->flag_as_skipped($value['album_id']);
     continue;
 }
 foreach ($result->body->Items->Item->ImageSets->ImageSet as $v) {
     if (!isset($imageurls['small'])) {
         $imageurls['small'] = (string) $v->SmallImage->URL;
     }
コード例 #2
0
ファイル: ArtworkScanTest.php プロジェクト: Alenpiera/streeme
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);
$t->is($album->meta_flagged, 1, 'Album 2 was scanned');