} if (!isset($imageurls['medium'])) { $imageurls['medium'] = (string) $v->MediumImage->URL; } if (!isset($imageurls['large'])) { $imageurls['large'] = (string) $v->LargeImage->URL; } } //Load the selected image url contents into a buffer $images = array(); $images['small'] = @file_get_contents($imageurls['small']); $images['medium'] = @file_get_contents($imageurls['medium']); $images['large'] = @file_get_contents($imageurls['large']); //create a specially encoded directory: an md5 hash of the artist and album if (!file_exists($art_dir)) { if (!mkdir($art_dir, 0777, true)) { die('The album art directory: ' . $art_dir . ' Could not be created. This could be because one or more of the the folders is not writable'); } } //write all the sizes to the directory foreach ($images as $k => $v) { file_put_contents($art_dir . '/' . $k . '.jpg', $v); } //don't scan further files in this album $current_album_id = $value['album_id']; $artwork_scanner->flag_as_added($value['album_id']); } //summarize the results of the scan echo "\r\n"; echo $artwork_scanner->get_summary();
//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'); $t->is($album->has_art, 1, 'Album 2 has art'); $t->comment('->get_summary()'); $t->is(is_string($artwork_scan->get_summary()), true, 'returned string');