$t->is($result->scan_id, 3, 'expected scan id'); $result = $playlist_files->createQuery()->where('playlist_id=?', $result->id)->fetchArray(); $t->is(count($result), '2', 'Playlist files updated'); $t->comment('Updating Existing Playlist with an extra song'); $rock_files = array(array('filename' => 'file://localhost/E:/music/TheKingOfLimbs-MP3/The%20King%20Of%20Limbs/01%20Bloom.MP3'), array('filename' => 'file://localhost/E:/music/TheKingOfLimbs-MP3/some%20rock.MP3')); $update_playlist_id = $playlist_scan->is_scanned($playlist_scan->get_service_name(), '90\'s Rock', 'B16E9C5DFFC4695D'); $playlist_id = $playlist_scan->add_playlist('90\'s Rock', $rock_files, $update_playlist_id, $playlist_scan->get_last_scan_id(), 'itunes', 'B16E9C5DFFC4695D'); $t->is($playlist_scan->get_updated_playlists(), '1', 'Updated 90\'s Rock Playlist'); $t->is($playlist_id, 1, 'updated playlist entry 1'); $result = $playlist->find($playlist_id); $t->is($result->name, '90\'s Rock', 'Targeted correct title'); $t->is($result->scan_id, 3, 'expected scan id'); $result = $playlist_files->createQuery()->where('playlist_id=?', $result->id)->fetchArray(); $t->is(count($result), '2', 'Playlist files updated'); $t->comment('Find reasons to skip scanning'); $playlist_id = $playlist_scan->add_playlist('', $rock_files, $update_playlist_id, $playlist_scan->get_last_scan_id(), 'itunes', 'B16E9C5DFFC4695D'); $t->is($playlist_scan->get_skipped_playlists(), 1, 'Skipped due to empty filename'); $playlist_id = $playlist_scan->add_playlist('Soft Jazz Mix', array(), $update_playlist_id, $playlist_scan->get_last_scan_id(), 'itunes', 'B16E9C5DFFC4695D'); $t->is($playlist_scan->get_skipped_playlists(), 2, 'Skipped due to empty file set'); $playlist_id = $playlist_scan->add_playlist('Soft Jazz Mix', '', $update_playlist_id, $playlist_scan->get_last_scan_id(), 'itunes', 'B16E9C5DFFC4695D'); $t->is($playlist_scan->get_skipped_playlists(), 3, 'Skipped due to wrong file set type'); $t->comment('->finalize_scan()'); $result = $playlist_files->createQuery()->where('playlist_id=?', 3)->fetchArray(); $t->is(count($result), 1, 'files still exist for playlist 3'); $count = $playlist_scan->finalize_scan($playlist_files); $t->is($count, 1, 'Removed out of date record 3'); $result = $playlist_files->createQuery()->where('playlist_id=?', 3)->fetchArray(); $t->is(count($result), 0, 'Playlist files removed'); $t->comment('->get_summary()'); $t->ok($playlist_scan->get_summary(), 'got summary detail string');
* @author Richard Hoar * @version SVN: $Id: Builder.php 7490 2010-03-29 19:53:27Z jwage $ */ $itunes_music_library = sfConfig::get('app_itunes_xml_location'); $mapped_drive_locations = sfConfig::get('app_mdl_mapped_drive_locations'); $allowed_filetypes = array_map('strtolower', sfConfig::get('app_aft_allowed_file_types')); $itunes_parser = new StreemeItunesPlaylistParser($itunes_music_library); $playlist_scan = new PlaylistScan('itunes'); $playlist_name = $itunes_playlist_id = null; $playlist_songs = array(); function mapItunes($collection) { return array('filename' => iconv(sfConfig::get(app_filesystem_encoding, 'ISO-8859-1'), 'UTF-8//TRANSLIT', StreemeUtil::itunes_format_decode($collection['filename'], StreemeUtil::is_windows(), sfConfig::get('app_mdl_mapped_drive_locations')))); } while ($itunes_parser->getPlaylist($playlist_name, $itunes_playlist_id, $playlist_songs)) { //There's no point scanning the entire library again, so we'll exclude the first record in iTunes if (!isset($first_skipped)) { $first_skipped = true; continue; } //convert itunes filenames to system specific paths $playlist_songs = array_map(mapItunes, $playlist_songs); //update playlists if (count($playlist_songs) > 0) { $playlist_id = $playlist_scan->is_scanned($playlist_scan->get_service_name(), $playlist_name, $itunes_playlist_id); $playlist_id = $playlist_scan->add_playlist($playlist_name, $playlist_songs, $playlist_id, $playlist_scan->get_last_scan_id(), $playlist_scan->get_service_name(), $itunes_playlist_id); } } $playlist_scan->finalize_scan(PlaylistFilesTable::getInstance()); echo $playlist_scan->get_summary();