예제 #1
0
 * @package    streeme
 * @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'));
$media_scanner = new MediaScan();
$itunes_parser = new StreemeItunesTrackParser($itunes_music_library);
while ($value = $itunes_parser->getTrack()) {
    //if it's not a valid filetype, ignore
    if (!in_array(strtolower(substr($value['Location'], -3)), $allowed_filetypes)) {
        continue;
    }
    //decode the itunes file scheme for checking is_readable
    $location = StreemeUtil::itunes_format_decode($value['Location'], StreemeUtil::is_windows(), $mapped_drive_locations);
    //convert it from user's filesystem value to UTF-8 for the database
    $value['Location'] = iconv(sfConfig::get(app_filesystem_encoding, 'ISO-8859-1'), 'UTF-8//TRANSLIT', $location);
    //if this file's scanned already and nothing about the file has been modified, ignore
    if ($media_scanner->is_scanned($value['Location'], strtotime($value['Date Modified']))) {
        continue;
    }
    //smooth times from itunes format to minutes:seconds
    $minutes = floor($value['Total Time'] / 1000 / 60);
    $seconds = str_replace('.', '0', substr(($value['Total Time'] - floor($value['Total Time'] / 1000 / 60) * 60 * 1000) / 1000, 0, 2));
    if ($seconds > 60) {
        $seconds = '00';
    }
    //create an array of song information
    $song_array = array();
    $song_array['artist_name'] = @$value['Artist'];
예제 #2
0
<?php

include dirname(__FILE__) . '/../bootstrap/doctrine.php';
include dirname(__FILE__) . '/../../apps/client/lib/StreemeUtil.class.php';
// Initialize the test object
$t = new lime_test(10, new lime_output_color());
$t->comment('->itunes_format_decode()');
$t->is(StreemeUtil::itunes_format_decode('file://localhost/Z:/music/music.mp3', true), 'Z:/music/music.mp3', 'Decoded an itunes path with mapped drive replacements');
$mapped_drive_locations = array('file://localhost/Z:' => '\\mediabox');
$t->is(StreemeUtil::itunes_format_decode('file://localhost/Z:/music/music.mp3', true, array('file://localhost/Z:' => '\\mediabox')), '\\mediabox/music/music.mp3', 'Decoded an iTunes path with mapped drive replacements');
$t->is(StreemeUtil::itunes_format_decode('file://localhost/home/foo/bar%20man', false), '/home/foo/bar man', 'Decoded an itunes formatted path');
$t->comment('->slugify()');
$t->is(StreemeUtil::slugify('stuff & thing fox\'s Name'), 'stuff-thing-fox-s-name', 'Processed sting pattern into valid url');
$t->comment('->xmlize_uf8_string()');
$t->is(StreemeUtil::xmlize_utf8_string(join(range(chr(0), chr(127)))), join(range(chr(1), chr(127))), 'passes printable US-ascii chars');
$t->is(StreemeUtil::xmlize_utf8_string(' 小低胡' . chr(0)), '小低胡', 'passes printable UTF-8 chars');
$t->is(StreemeUtil::xmlize_utf8_string('äöüæøy'), 'äöüæøy', 'passes printable UTF-8 tremas');
$t->is(StreemeUtil::xmlize_utf8_string('m̥mn̥nɲ̊ɲŋ̊ŋðóíáþ'), 'm̥mn̥nɲ̊ɲŋ̊ŋðóíáþ', 'passes printable UTF-8 icelandic chars');
$t->is(StreemeUtil::xmlize_utf8_string('YÿþAÿþ#ÿþÿþ'), '', 'removes id3 signalling leak');
$t->comment('->replace_url_nonfs_chars()');
$t->is(StreemeUtil::replace_url_nonfs_chars('%E2%80%93' . '%E2%80%A6' . '%E2%80%BA'), '%96' . '%85' . '%9B', 'change mb_strings to single byte latin');
예제 #3
0
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'))));
}