/**
 * Converts a category slug into its numerical category ID for lookup.
 *
 * @author Alex Andrews (alex@recordsonribs.com)
 * @param string $slug The slug of the category.
 * @return int ID of category.
 **/
function dbem_category_slug_to_id($slug)
{
    $categories = dbem_get_categories();
    foreach ($categories as $category) {
        if (ribcage_slugize($category['category_name']) == $slug) {
            return $category['category_id'];
        }
    }
    return null;
}
Exemple #2
0
/**
 * Administration panel for adding a release.
 *
 * @return void
 */
function ribcage_add_release()
{
    global $release, $artist, $tracks, $track;
    ?>
	<div class="wrap">
	<div id="icon-options-general" class="icon32"><br /></div>
	<?php 
    if (isset($_POST['release'])) {
        $release = $_POST['release'];
        $release = stripslashes($release);
        $release = unserialize($release);
    }
    unset($_POST['release']);
    unset($_POST['Submit']);
    // Stage 4 - Add the release to the database.
    if (isset($_REQUEST['ribcage_action']) && $_REQUEST['ribcage_action'] == 'add_release' && $_REQUEST['ribcage_step'] == '4') {
        ?>
		<h2>Add Release - Adding To Database</h2>
		<?php 
        // Load everything we have so far.
        $release = get_transient('ribcage_temp_data');
        $release = unserialize($release);
        $tracks = get_transient('ribcage_temp_tracks');
        $tracks = unserialize($tracks);
        // Correct the data we have here with additions from the previous form.
        foreach ($_POST as $key => $var) {
            if (preg_match("/^track_stream_/", $key)) {
                $number = str_replace('track_stream_', '', $key);
                $number = $number - 1;
                $tracks[$number]['track_stream'] = $var;
                continue;
            }
            $release[$key] = $var;
        }
        // Save all of this just in case we have a problem.
        set_transient('ribcage_temp_data', serialize($release), 60 * 60);
        set_transient('ribcage_temp_tracks', serialize($release), 60 * 60);
        // Checks on the data so far.
        foreach ($tracks as $track) {
            if (false === @file_get_contents($track['track_stream'])) {
                $errors[] = '<p>The streaming file for the track ' . $track['track_title'] . ' does not exist at <code>' . $track['track_stream'] . '</code>.</p>';
                //$fatal_error = true;
            }
        }
        $formats = array('mp3', 'ogg', 'flac');
        foreach ($formats as $format) {
            if ($release["release_{$format}"]) {
                if (!file_exists(ABSPATH . $release["release_{$format}"])) {
                    $errors[] = '<p>The file you set for the ' . $format . ' downloads does not exist at <code>' . $release["release_{$format}"] . '</code>.</p>';
                    $missing_uploads = true;
                }
            }
        }
        if ($release["release_one_sheet"]) {
            if (!file_exists(ABSPATH . $release["release_one_sheet"])) {
                $errors[] = '<p>The file you set for the one sheet does not exist at <code>' . $release["release_one_sheet"] . '</code>.</p>';
                $missing_uploads = 1;
            }
        }
        foreach ($formats as $format) {
            if ($release["release_torrent_{$format}"]) {
                if (false === @file_get_contents($release["release_torrent_{$format}"], 0, null, 0, 1)) {
                    $errors[] = '<p>The file you set for the ' . $format . ' torrent does not exist at <code>' . $release["release_torrent_{$format}"] . '</code>.</p>';
                }
            }
        }
        $sizes = array('tiny', 'large', 'huge');
        foreach ($sizes as $size) {
            if ($release["release_cover_image_{$size}"]) {
                if (false === @file_get_contents($release["release_cover_image_{$size}"], 0, null, 0, 1)) {
                    $errors[] = '<p>The ' . $size . ' cover image does not exist at <code>' . $release["release_cover_image_{$size}"] . '</code>.</p>';
                    $missing_uploads = true;
                }
                $check_images = true;
            }
        }
        if (!$check_images) {
            $errors[] = '<p>No cover images have been set!</p>';
        }
        if ($missing_uploads) {
            $errors[] = "<p>We've got missing files here, don't forget to upload them!</p>";
        }
        // Show errors.
        if (is_array($errors)) {
            ?>
			<h3>Errors</h3>
			<p>The following errors have been found in what you have entered.</p> 
			<?php 
            foreach ($errors as $error) {
                print $error;
            }
            // TODO Set some kind of flag to remind the user that their are incomplete elements of the release.
            if ($fatal_error) {
                ?>
				<p>There are too many errors to continue, please go back and correct them.</p>
				<p class="submit">
					<input type="submit" name="Submit" class="button-primary" value="Back" />
				</p>
				<?php 
                return;
            }
        }
        ?>
		<p>Added <?php 
        release_title();
        ?>
 to the database.</p>
		<?php 
        global $wpdb;
        $wpdb->show_errors();
        // Add release to database
        $string_keys = implode(array_keys($release), ",");
        $string_values = "'" . implode(array_values($release), "','") . "'";
        $sql = "INSERT INTO " . $wpdb->prefix . "ribcage_releases\n\t\t\t\t\t({$string_keys})\n\t\t\t\t\tVALUES\n\t\t\t\t\t({$string_values})";
        //echo $sql;
        $results = $wpdb->query($sql);
        // Add tracks to database
        foreach ($tracks as $tr) {
            $tr['track_title'] = mysql_real_escape_string($tr['track_title']);
            $string_keys = implode(array_keys($tr), ",");
            $string_values = "'" . implode(array_values($tr), "','") . "'";
            $sql = " \n\t\t\tINSERT INTO wp_ribcage_tracks \n\t\t\t({$string_keys})\n\t\t\tVALUES\n\t\t\t({$string_values})\n\t\t\t";
            //echo $sql;
            $results = $wpdb->query($sql);
        }
        delete_transient('ribcage_temp_tracks');
        delete_transient('ribcage_temp_data');
        delete_transient('ribcage_allow_download');
        delete_transient('ribcage_allow_torrent');
        $wpdb->hide_errors();
        if (!$release['release_mbid']) {
            echo "<p>Don't forget to add the release to <a href=\"http://musicbrainz.org\">MusicBrainz</a>. It will make your life a lot easier!</p>";
        }
        return 0;
    } elseif (isset($_REQUEST['ribcage_action']) && $_REQUEST['ribcage_action'] == 'add_release' && $_REQUEST['ribcage_step'] == '3') {
        // Load everything up of any interest. By now we should have a fair bit.
        $release = get_transient('ribcage_temp_data');
        $release = unserialize($release);
        $allow_download = get_transient('ribcage_allow_download');
        $allow_torrent = get_transient('ribcage_allow_torrent');
        // Set the tracks from the previous stage $_POST
        $total_tracks = $release['release_tracks_no'];
        $t = 1;
        $artist = get_artist($release['release_artist']);
        $artist_slug = $artist['artist_slug'];
        while (count($tracks) != $total_tracks) {
            $tracks[] = array('track_number' => $_POST["track_number_{$t}"], 'track_title' => $_POST["track_title_{$t}"], 'track_time' => $_POST["track_time_{$t}"], 'track_release_id' => $release['release_id'], 'track_mbid' => $_POST["track_mbid_{$t}"], 'track_slug' => ribcage_slugize($_POST["track_title_{$t}"]), 'track_stream' => get_option('siteurl') . get_option('ribcage_file_location') . 'audio' . ribcage_slugize($_POST['track_title_$t']) . "/{$artist_slug}/" . ribcage_slugize($release['release_title']) . '/stream/' . str_pad($t, 2, "0", STR_PAD_LEFT) . '.mp3');
            $t++;
        }
        set_transient('ribcage_temp_tracks', serialize($tracks), 60 * 60);
        ?>
		<h2>Add Release - Upload Files</h2>
		<form action="<?php 
        echo str_replace('%7E', '~', $_SERVER['REQUEST_URI']);
        ?>
&ribcage_action=add_release&ribcage_step=4" method="post" id="ribcage_add_release" name="add_release">
		<?php 
        if ($allow_download == 1) {
            ?>
		<h3>Downloads</h3>
		<p>At the moment Ribcage has no facility to upload downloads for your release. But it has made the following guess as to where your downloads might be - please check them.</p>
		<table class="form-table">             
		<?php 
            if ($release['release_mp3']) {
                ?>
			<tr valign="top">
				<th scope="row"><label for="release_mp3">.zip Location For MP3</label></th> 
				<td>
				<input type="text" style="width:480px;" class="regular-text code" value="<?php 
                print $release['release_mp3'];
                ?>
" name="release_mp3" id="release_mp3" maxlength="200" />
				</td> 
			</tr>
			<?php 
            }
            if ($release['release_ogg']) {
                ?>
			<tr valign="top">
				<th scope="row"><label for="release_ogg">.zip Location For Ogg</label></th> 
				<td>
				<input type="text" style="width:480px;" class="regular-text code" value="<?php 
                print $release['release_ogg'];
                ?>
" name="release_ogg" id="release_ogg" maxlength="200" />
				</td> 
			</tr>
			<?php 
            }
            if ($release['release_flac']) {
                ?>
			<tr valign="top">
				<th scope="row"><label for="release_ogg">.zip Location For Flac</label></th> 
				<td>
				<input type="text" style="width:480px;" class="regular-text code" value="<?php 
                print $release['release_flac'];
                ?>
" name="release_flac" id="release_flac" maxlength="200" />
				</td> 
			</tr>
			<?php 
            }
        } else {
            unset($release['release_mp3']);
            unset($release['release_ogg']);
            unset($release['release_flac']);
        }
        ?>
		</table>
		<?php 
        if ($allow_torrent == 1) {
            ?>
		<h3>Torrents</h3>
		<p>The locations of your torrents for those downloads.</p>
		<table class="form-table">
			<tr valign="top">
				<th scope="row"><label for="release_torrent_mp3">Torrent For MP3</label></th> 
				<td>
				<input type="text" style="width:480px;" class="regular-text code" value="<?php 
            print $release['release_torrent_mp3'];
            ?>
" name="release_torrent_mp3" id="release_torrent_mp3" maxlength="200" />
				</td> 
			</tr>
			<tr valign="top">
				<th scope="row"><label for="release_torrent_ogg">Torrent For Ogg</label></th> 
				<td>
				<input type="text" style="width:480px;" class="regular-text code" value="<?php 
            print $release['release_torrent_ogg'];
            ?>
" name="release_torrent_ogg" id="release_torrent_ogg" maxlength="200" />
				</td> 
			</tr>
			<tr valign="top">
				<th scope="row"><label for="release_torrent_flac">Torrent For Flac</label></th> 
				<td>
				<input type="text" style="width:480px;" class="regular-text code" value="<?php 
            print $release['release_torrent_flac'];
            ?>
" name="release_torrent_flac" id="release_torrent_flac" maxlength="200" />
				</td> 
			</tr>
		</table>
		<?php 
        } else {
            unset($release['release_torrent_mp3']);
            unset($release['release_torrent_ogg']);
            unset($release['release_torrent_flac']);
        }
        ?>
		<h3>Streams</h3>
		<p>The following is our guess where the files to stream your release are located.</p>
		<table width="800px"> 
			<thead>
			<tr>
				<td>No</td>
				<td>Track Name</td>
				<td>Stream Location</td>		
			</tr>
			</thead>
			<?php 
        $track_count = 1;
        ?>
			<?php 
        while (have_tracks()) {
            the_track();
            ?>
			<tr>
				<th scope="row">
					<?php 
            track_no();
            ?>
				</th>
				<td>
					<?php 
            track_title();
            ?>
				</td>
				<td>
					<input type="text" style="width:500px;" class="regular-text" value="<?php 
            echo $track['track_stream'];
            ?>
" name="track_stream_<?php 
            echo $track_count;
            ?>
" id="track_stream_<?php 
            echo $track_count;
            ?>
" maxlength="200" />											
				</td>
			</tr>
			<?php 
            $track_count++;
            ?>
			<?php 
        }
        ?>
		</table>
		<h3>Artwork</h3>
		<p>The following is our guess where the images for the artwork for your release are located.</p>
		<table class="form-table">
			<tr valign="top">
				<th scope="row"><label for="release_cover_image_tiny">Tiny Cover Image</label></th> 
				<td>
				<input type="text" style="width:480px;" class="regular-text code" value="<?php 
        print $release['release_cover_image_tiny'];
        ?>
" name="release_cover_image_tiny" id="release_cover_image_tiny" maxlength="200" />
				</td> 
			</tr>
			<tr valign="top">
				<th scope="row"><label for="release_cover_image_large">Large Cover Image</label></th> 
				<td>
				<input type="text" style="width:480px;" class="regular-text code" value="<?php 
        print $release['release_cover_image_large'];
        ?>
" name="release_cover_image_large" id="release_cover_image_large" maxlength="200" />
				</td> 
			</tr>
			<tr valign="top">
				<th scope="row"><label for="release_cover_image_huge">Huge Cover Image</label></th> 
				<td>
				<input type="text" style="width:480px;" class="regular-text code" value="<?php 
        print $release['release_cover_image_huge'];
        ?>
" name="release_cover_image_huge" id="release_cover_image_huge" maxlength="200" />
				</td> 
			</tr>
		</table>
		<h3>Press</h4>
		<p>Release One Sheet  <input type="text" style="width:480px;" class="regular-text code" value="<?php 
        print $release['release_one_sheet'];
        ?>
" name="release_one_sheet" id="release_one_sheet" maxlength="200" /></p>
		<p class="submit">
			<input type="submit" name="Submit" class="button-primary" value="Next" />
		</p>
		</form>
		<?php 
        set_transient('ribcage_temp_data', serialize($release), 60 * 60);
    } elseif (isset($_REQUEST['ribcage_action']) && $_REQUEST['ribcage_action'] == 'add_release') {
        // Get the tracks that have been set, if we have been sent any.
        $tracks = get_transient('ribcage_temp_tracks');
        $tracks = unserialize($tracks);
        if (!$tracks) {
            $track_count = 0;
            while ($track_count < $_POST['release_tracks_no']) {
                $track_count++;
                $tracks[] = array('track_title' => '', 'track_time' => '', 'track_release_id' => $release['release_id'], 'track_mbid' => '', 'track_slug' => '', 'track_number' => $track_count, 'track_stream' => '');
            }
        }
        $artist = get_artist($_POST['release_artist']);
        $release['release_artist'] = $_POST['release_artist'];
        $release['release_tracks'] = $tracks;
        set_transient('ribcage_allow_download', $_POST['allow_download'], 60 * 60);
        set_transient('ribcage_allow_torrent', $_POST['allow_torrent'], 60 * 60);
        unset($_POST['allow_download']);
        unset($_POST['allow_torrent']);
        // Whack all the inputed variables into $release
        foreach ($_POST as $key => $var) {
            $release[$key] = $var;
        }
        // If we don't have any data from Musicbrainz then this is the time to guess some stuff.
        $test = get_transient('ribcage_got_mb');
        if ($test != 1) {
            $artist = get_artist($release['release_artist']);
            $artist_slug = $artist['artist_slug'];
            $release = array_merge($release, array('release_cover_image_tiny' => get_option('siteurl') . get_option('ribcage_image_location') . 'covers/tiny/' . $release['release_slug'] . '.jpg', 'release_cover_image_large' => get_option('siteurl') . get_option('ribcage_image_location') . 'covers/large/' . $release['release_slug'] . '.jpg', 'release_cover_image_huge' => get_option('siteurl') . get_option('ribcage_image_location') . 'covers/huge/' . $release['release_slug'] . '.jpg', 'release_mp3' => get_option('ribcage_file_location') . $artist_slug . '/' . $release['release_slug'] . '/download/zip/' . $release['release_slug'] . '-mp3.zip', 'release_ogg' => get_option('ribcage_file_location') . $artist_slug . '/' . $release['release_slug'] . '/download/zip/' . $release['release_slug'] . '-ogg.zip', 'release_flac' => get_option('ribcage_file_location') . $artist_slug . '/' . $release['release_slug'] . '/download/zip/' . $release['release_slug'] . '-flac.zip', 'release_torrent_mp3' => '', 'release_torrent_ogg' => '', 'release_torrent_flac' => '', 'release_one_sheet' => get_option('siteurl') . get_option('ribcage_file_location') . 'pdf/onesheets/' . $release['release_slug'] . '.pdf'));
        }
        ?>
		<h2>Add Release - Track Details</h2>
		<p>Please check the following details for <?php 
        artist_name();
        ?>
 - <?php 
        release_title();
        ?>
.</p>
		<?php 
        ribcage_tracks_form();
        ?>
		</div>
		<?php 
        // Dump this because we already have tracks save in $tracks, hased in the database as ribcage_temp_tracks.
        unset($release['release_tracks']);
        // Save data.
        $saved_temp = unserialize(get_transient('ribcage_temp_data'));
        if ($saved_temp) {
            $temp = array_merge($release, $saved_temp);
            $temp = serialize($temp);
        } else {
            $temp = serialize($release);
        }
        set_transient('ribcage_temp_data', $temp, 60 * 60);
        return 0;
    } else {
        if (isset($_POST['lookup']) && $_POST['lookup'] != '') {
            ?>
		<h2>Add Release - Release Details</h2> <?php 
            if ($_POST['lookup'] == 'Lookup') {
                $mbid = $_POST['musicbrainz_id'];
                $result = mb_get_release($mbid);
                if (is_wp_error($result)) {
                    ?>
				<?php 
                    switch ($result->get_error_code()) {
                        case 'mb_not_found':
                            ?>
						<p>Ribcage could not find a release with a MBID of <?php 
                            echo $mbid;
                            ?>
 in the Musicbrainz database.</p>
						<p>Please enter the release manually, but don't forget to add it to Musicbrainz afterwards.</p>
						<?php 
                            break;
                        case 'artist_not_found':
                            ?>
						// TODO Find out if we don't have this artist.
						<p><?php 
                            echo $artist;
                            ?>
 is not an artist in the Ribcage database. Yet.</p>
						<p>You need to <a href="admin.php?page=add_artist">add an artist</a> before you can add their releases.</p>
						<?php 
                            return 1;
                            break;
                    }
                    ?>
				</div>
				<?php 
                }
                $artist_slug = $artist['artist_slug'];
                // Let people know we got some interesting things from Musicbrainz.
                set_transient('ribcage_got_mb', '1', 60 * 60);
                // Guess some things about our release.
                $release = array_merge($release, array('release_cover_image_tiny' => get_option('siteurl') . get_option('ribcage_image_location') . 'covers/tiny/' . $release['release_slug'] . '.jpg', 'release_cover_image_large' => get_option('siteurl') . get_option('ribcage_image_location') . 'covers/large/' . $release['release_slug'] . '.jpg', 'release_cover_image_huge' => get_option('siteurl') . get_option('ribcage_image_location') . 'covers/huge/' . $release['release_slug'] . '.jpg', 'release_mp3' => get_option('ribcage_file_location') . $artist_slug . '/' . $release['release_slug'] . '/download/zip/' . $release['release_slug'] . '-mp3.zip', 'release_ogg' => get_option('ribcage_file_location') . $artist_slug . '/' . $release['release_slug'] . '/download/zip/' . $release['release_slug'] . '-ogg.zip', 'release_flac' => get_option('ribcage_file_location') . $artist_slug . '/' . $release['release_slug'] . '/download/zip/' . $release['release_slug'] . '-flac.zip', 'release_torrent_mp3' => '', 'release_torrent_ogg' => '', 'release_torrent_flac' => '', 'release_one_sheet' => get_option('siteurl') . get_option('ribcage_file_location') . 'pdf/onesheets/' . $release['release_slug'] . '.pdf'));
            }
            $tracks = serialize($release['release_tracks']);
            // Stage 1 - Add the details of the release or correct those from Musicbrainz
            ribcage_release_form();
            // Anything else goes in a transient until further notice.
            if ($release) {
                set_transient('ribcage_temp_tracks', $tracks, 60 * 60);
                $temp = array('release_mbid' => $release['release_mbid'], 'release_physical_cat_no' => $release['release_physical_cat_no'], 'release_cover_image_tiny' => $release['release_cover_image_tiny'], 'release_cover_image_large' => $release['release_cover_image_large'], 'release_cover_image_huge' => $release['release_cover_image_huge'], 'release_mp3' => $release['release_mp3'], 'release_ogg' => $release['release_ogg'], 'release_flac' => $release['release_flac'], 'release_one_sheet' => $release['release_one_sheet']);
                $temp = serialize($temp);
                set_transient('ribcage_temp_data', $temp, 60 * 60);
            }
        } else {
            // Clear the memory decks, in case we have a half finished transaction.
            delete_transient('ribcage_temp_tracks');
            delete_transient('ribcage_temp_data');
            delete_transient('ribcage_allow_download');
            delete_transient('ribcage_allow_torrent');
            ?>
		<h2>Add Release - Musicbrainz Lookup</h2>
		<form method="post" action="<?php 
            echo str_replace('%7E', '~', $_SERVER['REQUEST_URI']);
            ?>
">
		<p>Please enter the <a href="http://musicbrainz.org">Musicbrainz</a> ID and Ribcage will lookup the release and fill in the details automtically. This should be the Musicbrainz ID of the specific release, not the release group.</p> 
		<p>If your release does not have a Musicbrainz ID, or if you wish to enter the release entirely manually, click on Skip.</p>
		<p>Adding a track to Musicbrainz and then adding it to Ribcage makes it so you only have to type out the details of your release once. It also means that details of your release will be available on a central database, accessible to all.</p>
		<table class="form-table">
		<tr valign="top">
		<th scope="row"><label for="musicbrainz_id">Musicbrainz ID</label></th>
		<td><input type="text" name="musicbrainz_id" value="bce40d0a-6b5f-4d75-97c7-916d67d584f6" class="regular-text code"/></td>
		</tr>
		</table>
		<p class="submit">
		<input type="submit" name="lookup" class="button-primary" value="<?php 
            _e('Lookup');
            ?>
" /><input type="submit" name="lookup" class="button-secondary" value="<?php 
            _e('Skip');
            ?>
" />
		</p>
		</form>
	<?php 
        }
    }
    ?>
	</div>
	<?php 
}
Exemple #3
0
/**
 * Gets a release from Musicbrainz then puts the values of it into the global $release variable.
 * Uses a simple XML get to avoid the bloat of loading huge Musicbrainz object infested libraries.
 *
 * @author Alex Andrews <*****@*****.**>
 * @param string $mbid Musicbrainz ID to get.
 * @return array The details of the release.
 */
function mb_get_release($mbid)
{
    global $release, $artist;
    $request_url = "http://musicbrainz.org/ws/1/release/{$mbid}?type=xml&inc=release-events+tracks+artist";
    $xml = simplexml_load_file($request_url);
    if (!$xml) {
        return new WP_Error('ribcage-not-found', __("The MBID {$mbid} couldn't be found in the Musicbrainz database."));
    }
    $xml = object_to_array($xml);
    $release_physical = NULL;
    $release_physical_id = NULL;
    if (count($xml['release']['release-event-list']['event']) > 1) {
        foreach ($xml['release']['release-event-list']['event'] as $release_event) {
            if ($release_event['@attributes']['format'] == 'Digital') {
                $release_id = cat_to_release_id($release_event['@attributes']['catalog-number']);
                $release_date = $release_event['@attributes']['date'];
            } elseif ($release_event['@attributes']['format'] == 'CD') {
                // I'm assuming here that you aren't going to have loads of release events for CDs etc, but just one.
                $release_physical = 1;
                $release_physical_id = cat_to_release_id($release_event['@attributes']['catalog-number']);
            }
        }
    } else {
        $release_id = cat_to_release_id($xml['release']['release-event-list']['event']['@attributes']['catalog-number']);
        $release_date = $xml['release']['release-event-list']['event']['@attributes']['date'];
    }
    $release_artist_id = slug_to_artist_id(ribcage_slugize($xml['release']['artist']['name']));
    $release_slug = ribcage_slugize($xml['release']['title']);
    $artist_slug = ribcage_slugize($xml['release']['artist']['name']);
    $artist = get_artist($release_artist_id);
    // If we can't put anything in the artist, then the artist is actually not in the database. Bail out.
    if (!$artist) {
        $artist = $xml['release']['artist']['name'];
        return new WP_Error('ribcage-artist-not-found', __("Sorry, {$artist} is not in the Ribcage database"));
    }
    $track_no = 1;
    $total_time = 0;
    // Add tracks to $release
    foreach ($xml['release']['track-list']['track'] as $track) {
        $total_time = $total_time + $track['duration'];
        $tracks[] = array('track_title' => $track['title'], 'track_time' => miliseconds_to_sql($track['duration']), 'track_release_id' => $release_id, 'track_mbid' => $track['@attributes']['id'], 'track_slug' => ribcage_slugize($track['title']), 'track_number' => $track_no, 'track_stream' => 'http://recordsonribs.com/files/audio/' . $artist_slug . '/' . $release_slug . '/stream/' . str_pad($track_no, 2, "0", STR_PAD_LEFT) . '.mp3');
        ++$track_no;
    }
    $release = array('release_id' => $release_id, 'release_tracks_no' => $track_no - 1, 'release_artist' => $release_artist_id, 'release_date' => $release_date, 'release_title' => $xml['release']['title'], 'release_slug' => $release_slug, 'release_time' => miliseconds_to_sql($total_time), 'release_mbid' => $xml['release']['@attributes']['id'], 'release_physical' => $release_physical, 'release_physical_cat_no' => $release_physical_id, 'release_tracks' => $tracks);
    return $release;
}