/**
  * Class constructor. See parent constructor for further reference.
  *
  * @param string $clientId Application client id
  * @param string $clientSecret Application client secret
  * @param string $redirectUri Application redirect uri
  * @param boolean $development Sandbox mode
  *
  * @return void
  * @see Soundcloud
  */
 function __construct($clientId, $clientSecret, $redirectUri = null, $development = false)
 {
     parent::__construct($clientId, $clientSecret, $redirectUri, $development);
 }
Exemplo n.º 2
0
 function process_delete_action()
 {
     $track = isset($_GET['track']) ? $_GET['track'] : '';
     $track_id = isset($_GET['id']) ? $_GET['id'] : '';
     if ('delete' === $this->current_action()) {
         //check if the individual delete link was clicked
         if ($_GET['track'] != '') {
             //get soundcloud options
             $sc_options = get_option('soundcloud_settings');
             if ($sc_options) {
                 $sc_id = $sc_options['sc_client_id'];
                 $sc_secret = $sc_options['sc_client_secret'];
                 $sc_token = $sc_options['sc_client_access_token'];
                 $sc_redirect_uri = $sc_options['sc_redirect_uri'];
             }
             $soundcloud = new Services_Soundcloud($sc_id, $sc_secret, $sc_redirect_uri);
             if ($sc_token) {
                 $soundcloud->setAccessToken($sc_token);
             } else {
                 //TODO display an error stating that the user needs to authenticate first
                 return 0;
             }
             try {
                 $response = $soundcloud->delete('tracks/' . $track_id);
                 return 1;
             } catch (Services_Soundcloud_Invalid_Http_Response_Code_Exception $e) {
                 exit($e->getMessage());
             }
             echo '<div id="message" class="updated fade"><p>The track "' . $track . '" was deleted from your SoundCloud account.</p></div>';
         }
     }
 }
Exemplo n.º 3
0
 /**
  * Gets track by url
  * @param  string $url
  * @return string
  */
 public static function search($query)
 {
     // create a client object with your app credentials
     $client = new Services_Soundcloud(Base::$g['soundcloud_client'], '');
     // find all sounds
     $tracks = $client->get('tracks', array('q' => $query, 'limit' => 40));
     $tracks = json_decode($tracks);
     $ret = array();
     foreach ($tracks as $track) {
         $table = Track::create();
         $table->scid = $track->id;
         $table->name = $track->title;
         $table->scurl = $track->permalink_url;
         $table->duration = round($track->duration / 1000);
         $table->save();
         $ret[] = $table->orm->asArray();
     }
     return $ret;
 }
 public function soundcloud_access_token_callback()
 {
     require_once plugin_dir_path(__FILE__) . '../public/assets/php-soundcloud-master/Services/Soundcloud.php';
     $options = get_option('hbi_soundcloud_podcasts_settings');
     if (empty($options['soundcloud_client_id']) || empty($options['soundcloud_client_secret'])) {
         echo "<em>Please enter your Client ID and Secret before attempting to create your access token.</em>";
         return;
     }
     $client = new Services_Soundcloud($options['soundcloud_client_id'], $options['soundcloud_client_secret'], $options['soundcloud_redirect_uri']);
     echo '<p class="description">Click the Connect button below if you have not already created an access token, or if you need to re-create your acccess token.</p>';
     echo "<a id='soundcloud_connect' target='_blank' href='{$client->getAuthorizeUrl()}'><img width='242' height='29' src='http://connect.soundcloud.com/2/btn-connect-sc-l.png' alt='' title='' /></a>";
     echo '<p><input size="50" placeholder="Paste Access Code Here" id="soundcloud_access_code" type="text" name="hbi_soundcloud_podcasts_settings[soundcloud_access_code]" value="" /></p>';
 }
Exemplo n.º 5
0
 public function createClient()
 {
     if ($this->authcode) {
         $this->completeAuthToken();
     }
     if (!$this->authtoken) {
         $this->showAuthToken();
         return null;
     }
     $api = new Services_Soundcloud($this->userid, $this->secret);
     $api->setAccessToken($this->authtoken);
     return $api;
 }
Exemplo n.º 6
0
function wp_scu_authenticate()
{
    //get soundcloud options
    $sc_options = get_option('soundcloud_settings');
    if ($sc_options) {
        $sc_id = $sc_options['sc_client_id'];
        $sc_secret = $sc_options['sc_client_secret'];
        $sc_token = $sc_options['sc_client_access_token'];
        $sc_redirect_uri = $sc_options['sc_redirect_uri'];
    }
    $soundcloud = new Services_Soundcloud($sc_id, $sc_secret, $sc_redirect_uri);
    if (!$sc_token) {
        $params = array('scope' => 'non-expiring');
        $authorizeUrl = $soundcloud->getAuthorizeUrl($params);
        echo '<br /><a id="scu_connect_url" style="border-style:solid; padding:5px; border-color:orange;" href="' . $authorizeUrl . '">Click Here To Connect To SoundCloud</a>';
        try {
            //TODO: tighten up code - use isset to check if "code" param below exists
            $post_data = array();
            $curl_opts = array(CURLOPT_SSL_VERIFYPEER => false, CURLOPT_SSL_VERIFYHOST => false);
            $accessToken = $soundcloud->accessToken($_GET['code'], $post_data, $curl_opts);
            echo scu_jquery_snippet();
        } catch (Services_Soundcloud_Invalid_Http_Response_Code_Exception $e) {
            //exit($e->getMessage());
            echo '<div style="color:red;"><p><strong>SoundCloud Ultimate Error: Could not process the request - Error code (' . $e->getHttpCode() . ').</strong></p></div>';
            return;
        }
        //var_dump($accessToken);
        //store the token in tyhe options
        $sc_redirect_uri = site_url() . '/wp-admin/admin.php?page=wpshq_scu_plugin_options';
        $param = array('sc_client_id' => $sc_id, 'sc_client_secret' => $sc_secret, 'sc_client_access_token' => $accessToken['access_token'], 'sc_redirect_uri' => $sc_redirect_uri);
        update_option('soundcloud_settings', $param);
        //store the results in WP options table
        $soundcloud->setAccessToken($accessToken['access_token']);
    } else {
        if ($sc_token) {
            $soundcloud->setAccessToken($sc_token);
        }
    }
}
Exemplo n.º 7
0
function mg_get_soundcloud_embed($track_url)
{
    include_once MG_DIR . '/classes/soundcloud-api/Services/Soundcloud.php';
    $pub = '69c06a70f88e8ec80a414ae55dab369c';
    $sec = 'f7fe291ae99ef71d3fd81c084897309e';
    $callback = 'http://www.lcweb.it/';
    $client = new Services_Soundcloud($pub, $sec, $callback);
    $client->setCurlOptions(array(CURLOPT_FOLLOWLOCATION => 1));
    $track = json_decode($client->get('resolve', array('url' => $track_url)));
    $autoplay = get_option('mg_audio_autoplay') ? 'true' : 'false';
    return '<iframe width="100%" height="166" scrolling="no" frameborder="no" src="//w.soundcloud.com/player/?url=https%3A//api.soundcloud.com/tracks/' . $track->id . '&amp;color=ff5500&amp;auto_play=' . $autoplay . '&amp;hide_related=true&amp;show_artwork=true" style="margin-top: 7px;"></iframe>';
}
Exemplo n.º 8
0
<?php

session_start();
error_reporting(E_ALL & ~E_NOTICE ^ E_DEPRECATED);
$clientId = "10795ee3fb0bc2f1ba76f33d92e75ac7";
$clientSecret = "b1bb0d93211f90dd1648a76947bd4b9d";
$callback = "http://localhost/sound/sound.php";
require_once 'lib/Soundcloud.php';
$soundcloud = new Services_Soundcloud($clientId, $clientSecret, $callback);
$soundcloud->setDevelopment(false);
$soundcloud->setCurlOptions(array(CURLOPT_FOLLOWLOCATION => 1, CURLOPT_SSL_VERIFYPEER => 0));
$authorizeUrl = $soundcloud->getAuthorizeUrl();
?>


  <a class="login"href="<?php 
echo $authorizeUrl;
?>
">Connect to Souncloud</a>


<?php 
try {
    // if(!isset($_SESSION['token']))
    // {
    //      print_r($_SESSION);
    $accessToken = $soundcloud->accessToken($_GET['code']);
    //       $_SESSION['token'] = $accessToken['access_token'];
    // }
    // else
    // {
<?php

//start session
session_start();
// soundcloud api wrapper
require 'Soundcloud.php';
// credentials for new instance of services soundcloud
require 'credScUser.php';
//create new instance
$scUser = new Services_Soundcloud(CLIENT_ID, CLIENT_SECRET, REDIRECT_URI);
//get oauth code
$authorizeUrl = $scUser->getAuthorizeUrl();
echo "<pre>";
echo "<a href='{$authorizeUrl}'> Connect with SoundCloud</a><br>";
//set session to token returned from array
try {
    //check if SESSION is set to access token returned from sc. will only work if code is returned in URL
    if (!isset($_SESSION['token'])) {
        /*Obtain 'code' in order to request a access token. input this into function. 
         * returns array which includes access token*/
        $accessToken = $scUser->accessToken($_GET['code']);
        //set SESSION to access token(from accesstoken array)
        $_SESSION['token'] = $accessToken['access_token'];
    } else {
        /*set our classes accesstoken property to the session data(set after following initial
        		connect to soundcloud link) this will happen on refresh of page
        		 */
        $scUser->setAccessToken($_SESSION['token']);
    }
} catch (Services_Soundcloud_Invalid_Http_Response_Code_Exception $e) {
    exit($e->getMessage());
Exemplo n.º 10
0
 public function uploadAudio()
 {
     //        return view('soundcloud');
     $sc_client_id = "a44837441b00a082d5674ed6457f91a5";
     $sc_secret = "5c3305ecb0320334718eb70f5bc13a3c";
     $sc_user = "******";
     $sc_pass = "******";
     //      create client object and set access token
     $client = new Services_Soundcloud($sc_client_id, $sc_secret);
     //      login
     $client->credentialsFlow($sc_user, $sc_pass);
 }
Exemplo n.º 11
0
function sc_render_manager_page()
{
    require_once plugin_dir_path(__FILE__) . 'includes/Services/Soundcloud.php';
    require_once plugin_dir_path(__FILE__) . 'includes/class/pagination.class.php';
    $options = get_option('sc_options');
    $client = new Services_Soundcloud($options['client_id'], $options['client_secret'], $options['callback_url']);
    // Error message if app settings are not filled in.
    if ($options['client_id'] == "Your client ID goes here" || $options['client_secret'] == "Your client secret goes here" || $options['callback_url'] == "Your callback url goes here") {
        echo '<div class="error fade"><p>Warning: One or more of the required fields have not been set. Please insure that your cliend ID, client secret, and callback url are defined <a href="' . admin_url('options-general.php?page=soundcloud/soundcloud.php') . '">HERE</a>.</br>Soundcloud functionality will not be available until these fields are set.</p></div></br>';
    }
    // SoundCloud login/logout
    if (isset($_GET['code']) || get_option('soundcloud_access_token')) {
        echo '<a href="' . admin_url('admin.php?page=soundcloud-disconnect') . '" class="soundcloud-icon"><img src="' . plugins_url() . '/soundcloud/includes/images/btn-disconnect-l.png" alt="Disconnect"/></a>';
        try {
            $client = new Services_Soundcloud($options['client_id'], $options['client_secret'], $options['callback_url']);
            if (isset($_GET['code'])) {
                $accessToken = $client->accessToken($_GET['code']);
                update_option('soundcloud_access_token', $accessToken['access_token']);
                update_option('soundcloud_refresh_token', $accessToken['refresh_token']);
                update_option('soundcloud_token_expiration', time() + $accessToken['expires_in']);
            } else {
                if (get_option('soundcloud_access_token')) {
                    // refresh token code deprecated due to non-expiring tokens
                    /*if (time() > get_option('soundcloud_token_expiration')) {
                    			$client->setAccessToken(get_option('soundcloud_access_token'));
                    			
                    			// refresh access token
                    			$accessToken = $client->accessTokenRefresh(get_option('soundcloud_refresh_token'));	
                    			//$client->setAccessToken($accessToken['access_token']);							
                    			update_option('soundcloud_access_token', $accessToken['access_token']);
                    			update_option('soundcloud_refresh_token', $accessToken['refresh_token']);
                    			update_option('soundcloud_token_expiration', time() + $accessToken['expires_in']);
                    		}
                    		else
                    		{*/
                    $client->setAccessToken(get_option('soundcloud_access_token'));
                    //}
                }
            }
        } catch (Services_Soundcloud_Invalid_Http_Response_Code_Exception $e) {
            var_dump($e->getMessage());
            exit;
        }
    } else {
        echo '<a href="' . $client->getAuthorizeUrl(array('scope' => 'non-expiring')) . '" class="soundcloud-icon"><img src="' . plugins_url() . '/soundcloud/includes/images/btn-connect-sc-l.png" alt="Connect with Soundcloud"/></a>';
    }
    // tab switching
    if (isset($_GET['tab'])) {
        sc_admin_tabs($_GET['tab']);
        $tab = $_GET['tab'];
    } else {
        sc_admin_tabs('user');
        $tab = 'user';
    }
    if (get_option('soundcloud_access_token')) {
        try {
            $me = json_decode($client->get('me'), true);
        } catch (Services_Soundcloud_Invalid_Http_Response_Code_Exception $e) {
            var_dump($e->getMessage());
            exit;
        }
        echo '<h3>Logged in as: ' . $me['username'] . '</h3>';
    } else {
        echo '<h3>Not logged in.</h3>';
    }
    switch ($tab) {
        case 'user':
            try {
                $me = json_decode($client->get('me'), true);
                ?>
				<form action="" method="post">
					<table class="form-table">
						<tr valign="top">
						  <th scope="row"><label for="username">Username:</label></th>
						  <td><input type="text" name="username" value="<?php 
                echo $me['username'];
                ?>
" size="30" class="regular-text code"></td>
						</tr>
						<tr valign="top">
						  <th scope="row"><label for="permalink">Permalink:</label></th>
						  <td><input type="text" name="permalink" value="<?php 
                echo $me['permalink'];
                ?>
" size="30" class="regular-text code"></td>
						</tr>
						<tr valign="top">
						  <th scope="row"><label for="description">Description:</label></th>
						  <td><input type="text" name="description" value="<?php 
                echo $me['description'];
                ?>
" size="30" class="regular-text code"></td>
						</tr>
						<tr valign="top">
						  <th scope="row"><label for="website">Website:</label></th>
						  <td><input type="text" name="website" value="<?php 
                echo $me['website'];
                ?>
" size="30" class="regular-text code"></td>
						</tr>
						<tr valign="top">
						  <th scope="row"><label for="website_title">Website Name:</label></th>
						  <td><input type="text" name="website_title" value="<?php 
                echo $me['website_title'];
                ?>
" size="30" class="regular-text code"></td>
						</tr>
					</table>
					<p class="submit"><input type="submit" value="Update Account" class="button-primary"></p>
					
				</form>
				<?php 
                if (isset($_POST['username']) || isset($_POST['permalink']) || isset($_POST['description']) || isset($_POST['website']) || isset($_POST['website_title'])) {
                    $response = json_decode($client->put('me', array('user[username]' => $_POST['username'], 'user[permalink]' => $_POST['permalink'], 'user[description]' => $_POST['description'], 'user[website]' => strlen($_POST['website']) ? $_POST['website'] : null, 'user[website_title]' => strlen($_POST['website_title']) ? $_POST['website_title'] : null)));
                }
            } catch (Services_Soundcloud_Invalid_Http_Response_Code_Exception $e) {
                var_dump($e->getMessage());
                exit;
            }
            break;
        case 'upload':
            ?>
	
			<form action="" enctype="multipart/form-data" method="post" id ="add_track">
				<table class="form-table">
					<tr valign="top">
					  <th scope="row"><label for="track_title">Track title:</label></th>
					  <td><input type="text" name="track_title" size="30" class="regular-text code"></td>
					</tr>
					<tr valign="top">
					  <th scope="row"><label for="track_file">Please specify a track:</label></th>
					  <td><input type="file" name="track_file" id="track_file" size="40" accept="audio/*" class="regular-text code"></td>
					</tr>
					<tr valign="top">
					  <th scope="row"><label for="track_art">Please specify track artwork:</label></th>
					  <td><input type="file" name="track_art" id="track_art" size="40" accept="image/*" class="regular-text code"></td>
					</tr>
					<tr valign="top">
					  <th scope="row"><label for="tag">Track tags:</label></th>
					  <td><input type="text" name="tag" id="tag" size="30"><input type="button" id="add_tag" name="add_tag" class="button" value="Add Tag" />
						<br><ul id="tags"></ul></td>
					</tr>
					<tr valign="top">
					  <th scope="row"><label for="sharing">Track privacy:</label></th>
					  <td><select name="sharing">
						<option value="public">Public</option>
						<option value="private">Private</option>
					  </select></td>
					</tr>
					</table>
			<p class="submit"><input type="submit" value="Upload" class="button-primary"></p>
			</form>					
			<?php 
            try {
                $tmp_file = '/tmp/' . stripslashes($_FILES['track_file']['name']);
                $tmp_art_file = '/tmp/' . stripslashes($_FILES['track_art']['name']);
                if (move_uploaded_file($_FILES['track_file']['tmp_name'], $tmp_file) && move_uploaded_file($_FILES['track_art']['tmp_name'], $tmp_art_file)) {
                    // upload audio file
                    $track = json_decode($client->post('tracks', array('track[title]' => $_POST['track_title'], 'track[asset_data]' => '@' . $tmp_file, 'track[artwork_data]' => '@' . $tmp_art_file, 'track[tags]' => strlen($_POST['tags']) ? $_POST['tags'] : null, 'track[sharing]' => $_POST['sharing'])));
                    unlink(realpath($tmp_file));
                    unlink(realpath($tmp_art_file));
                }
            } catch (Services_Soundcloud_Invalid_Http_Response_Code_Exception $e) {
                var_dump($e->getMessage());
                exit;
            }
            break;
        case 'tracks':
            try {
                echo '</br>';
                $page_size = 5;
                // Pagination code
                $p = new pagination();
                $p->items($me['track_count']);
                $p->limit($page_size);
                // Limit entries per page
                $p->target("admin.php?page=soundcloud-manager&tab=tracks");
                $p->currentPage($_GET[$p->paging]);
                // Gets and validates the current page
                $p->calculate();
                // Calculates what to show
                $p->parameterName('paging');
                $p->adjacents(1);
                //No. of page away from the current page
                if (!isset($_GET['paging'])) {
                    $p->page = 1;
                } else {
                    $p->page = $_GET['paging'];
                }
                if ($p->page == 1) {
                    // get first page of tracks
                    $tracks = json_decode($client->get('users/' . $me['id'] . '/tracks', array('order' => 'created_at', 'limit' => $page_size)));
                } else {
                    // get additional pages of tracks
                    $tracks = json_decode($client->get('users/' . $me['id'] . '/tracks', array('order' => 'created_at', 'limit' => $page_size, 'offset' => $page_size * $page)));
                }
                ?>
				<div class="tablenav">
					<div class='tablenav-pages'>
						<?php 
                echo $p->show();
                ?>
					</div>
				</div>
				<?php 
                foreach ($tracks as $track) {
                    $client->setCurlOptions(array(CURLOPT_FOLLOWLOCATION => 1));
                    $embed_info = json_decode($client->get('oembed', array('url' => $track->permalink_url)));
                    // render the html for the player widget
                    echo $embed_info->html . '</br></br>';
                }
            } catch (Services_Soundcloud_Invalid_Http_Response_Code_Exception $e) {
                var_dump($e->getMessage());
                exit;
            }
            break;
    }
}
Exemplo n.º 12
0
        function get_soundcloud_widget_code($track, $auto_play = false)
        {
            //get soundcloud options
            require_once 'includes/Services/Soundcloud.php';
            $sc_options = get_option('soundcloud_settings');
            if ($sc_options) {
                $sc_id = $sc_options['sc_client_id'];
                $sc_secret = $sc_options['sc_client_secret'];
                $sc_token = $sc_options['sc_client_access_token'];
                $sc_redirect_uri = $sc_options['sc_redirect_uri'];
            }
            $soundcloud = new Services_Soundcloud($sc_id, $sc_secret, $sc_redirect_uri);
            if ($sc_token && $sc_id && $sc_secret) {
                $soundcloud->setAccessToken($sc_token);
            } else {
                //display an error stating that the user needs to authenticate first
                return '<div style="color:red;"><p><strong>SoundCloud Ultimate Error: You need to authenticate your connection to the SoundCloud API.
				<br />Please go to the SoundCloud Ultimate plugin settings and configure your API credentials.</strong></p></div>';
            }
            //first check if track has finished uploading
            //$tracks = $soundcloud->get('tracks/');
            $soundcloud->setCurlOptions(array(CURLOPT_FOLLOWLOCATION => 1));
            try {
                $track_list = $soundcloud->get('me/tracks');
            } catch (Services_Soundcloud_Invalid_Http_Response_Code_Exception $e) {
                if ($e->getHttpCode() == '302') {
                    //Special case - 302 received - continue to try and render the widget.....
                    $track_widget = $this->track_widget($soundcloud, $track, $auto_play);
                    return $track_widget;
                } else {
                    return '<div style="color:red;"><p><strong>SoundCloud Ultimate Error: Could not display your SoundCloud track - Error code (' . $e->getHttpCode() . ').</strong></p></div>';
                }
            }
            $tracks = json_decode($track_list, true);
            foreach ($tracks as $item) {
                if ($item['permalink_url'] == $track && $item['state'] != 'finished') {
                    return false;
                }
            }
            try {
                $track_embed_data = $soundcloud->get('oembed', array('url' => $track, 'auto_play' => $auto_play));
            } catch (Services_Soundcloud_Invalid_Http_Response_Code_Exception $e) {
                if ($e->getHttpCode() == '302') {
                    //Special case - 302 received - continue to try and render the widget.....
                    $track_widget = $this->track_widget($soundcloud, $track, $auto_play);
                    return $track_widget;
                } else {
                    if ($e->getHttpCode() == '404') {
                        return '<div style="color:red;"><p><strong>SoundCloud Ultimate Error: The track you specified in the shortcode does not exist in your account.</strong></div>';
                    } else {
                        return '<div style="color:red;"><p><strong>SoundCloud Ultimate Error: Could not display your SoundCloud track - Error code (' . $e->getHttpCode() . ').</strong></p></div>';
                    }
                }
            }
            //$embed_info = json_decode($soundcloud->get('oembed', array('url' => $track)));
            $embed_info = json_decode($track_embed_data);
            //now get the html code for the player widget
            //print $embed_info->html;
            $track_widget = $embed_info->html;
            return $track_widget;
        }
    /**
     * Import the podcasts using the SoundCloud API
     * 
     * @since   1.0.0
     */
    public function import_podcasts()
    {
        require_once plugin_dir_path(__FILE__) . 'assets/php-soundcloud-master/Services/Soundcloud.php';
        $output = '';
        $options = get_option('hbi_soundcloud_podcasts_settings');
        $client = new Services_Soundcloud($options['soundcloud_client_id'], $options['soundcloud_client_secret'], $options['soundcloud_redirect_uri']);
        $soundcloud_user_id = $options['soundcloud_user_id'];
        $access_token = $client->setAccessToken();
        $current_time = current_time('timestamp') - 21600;
        // grab the tracks
        $tracks = json_decode($client->get('users/' . $soundcloud_user_id . '/tracks', array('created_at[from]' => date('Y-m-d', $current_time))));
        if (count($tracks)) {
            $output .= "Currently processing " . count($tracks) . " tracks.\r\n";
            $totalimport = 0;
            // loop through the tracks
            foreach ($tracks as $track) {
                if ($track->downloadable != 1) {
                    $output .= "Track " . $track->id . " is not set to downloadable. \r\n";
                    $downloadable = <<<EOH
<track>
    <downloadable>true</downloadable>
</track>
EOH;
                    try {
                        $client->put('tracks/' . $track->id, $downloadable, array(CURLOPT_HTTPHEADER => array('Content-Type: application/xml')));
                        $output .= "Updated Track " . $track->id . " in SoundCloud to make sure it was downloadable.\r\n\r\n";
                    } catch (Services_Soundcloud_Invalid_Http_Response_Code_Exception $e) {
                        $output .= "Error setting track " . $track->id . "to be downloadable. " . $e->getMessage() . "\r\n\r\n";
                    }
                }
                $args = array('post_type' => 'podcasts', 'meta_key' => 'soundcloud-track-id', 'post_status' => 'any', 'meta_value' => $track->id);
                $test = get_posts($args);
                if (count($test) == 0) {
                    $downloadURL = 'http://feeds.soundcloud.com/stream/' . $track->id . '-101sports-' . $track->permalink . '.mp3';
                    $show = 'zach-and-rammer';
                    // Added in trim to try to fix all of the wrong things happening from extra spaces
                    $release = str_replace(' ', '-', strtolower(trim($track->release)));
                    $release = str_replace('&', 'and', $release);
                    if ($release != '') {
                        $show = $release;
                    }
                    $content = array('post_type' => 'podcasts', 'post_status' => 'publish', 'post_title' => $track->title, 'post_content' => $track->description, 'tax_input' => array('podcast-segment' => array(trim(strtolower($track->label_name)))));
                    $post_id = wp_insert_post($content);
                    $term = term_exists($track->label_name, 'podcast_segment');
                    wp_set_post_terms($post_id, $term['term_id'], 'podcast_segment');
                    add_post_meta($post_id, 'soundcloud-file', $downloadURL);
                    add_post_meta($post_id, 'use-soundcloud', 1);
                    add_post_meta($post_id, 'soundcloud-shortcode', '[soundcloud url="http://api.soundcloud.com/tracks/' . $track->id . '" params="" width=" 100%" height="166" iframe="true" /]');
                    add_post_meta($post_id, 'soundcloud-track-id', $track->id);
                    add_post_meta($post_id, 'podcast-show', $show);
                    $totalimport++;
                    $output .= "Imported " . $track->title . "(" . $track->id . ") into the system.\r\n";
                }
            }
            $output .= "Finished processing " . count($tracks) . " tracks. " . $totalimport . " have been imported into the system.\r\n";
        }
    }