function powerpress_admin_queue_files($extensions = array())
{
    $add_urls = '';
    $extensions_preg_match = '';
    while (list($extension, $null) = each($extensions)) {
        if ($extension == '*') {
            $extensions_preg_match = '.*';
            break;
            // Lets just match everything
        }
        if (!empty($extensions_preg_match)) {
            $extensions_preg_match .= '|';
        }
        $extensions_preg_match .= $extension;
    }
    if (empty($extensions_preg_match)) {
        // No files specified, no error message needed
        return;
    }
    $files = powerpress_admin_migrate_get_files(true, true);
    // Keep the URLs clean, excude blubrry media URLs
    $QueuedFiles = array();
    $Update = false;
    $update_option = true;
    $PastResults = get_option('powerpress_migrate_queued');
    if ($PastResults == false) {
        $update_option = false;
    }
    if (is_array($PastResults)) {
        $QueuedFiles = $PastResults;
    }
    $AddedCount = 0;
    $AlreadyAddedCount = 0;
    while (list($meta_id, $row) = each($files)) {
        $parts = pathinfo($row['src_url']);
        if (preg_match('/(' . $extensions_preg_match . ')/i', $parts['extension'])) {
            if (!empty($QueuedFiles[$meta_id]) && $QueuedFiles[$meta_id] == $row['src_url']) {
                $AlreadyAddedCount++;
                continue;
                // Already queued
            }
            $QueuedFiles[$meta_id] = $row['src_url'];
            if (!empty($add_urls)) {
                $add_urls .= "\n";
            }
            $add_urls .= $row['src_url'];
            $Update = true;
            $AddedCount++;
        }
    }
    if ($Update) {
        // Make API CALL to add files to queue here!
        $UpdateResults = powepress_admin_migrate_add_urls($add_urls);
        if (empty($UpdateResults)) {
            $Update = false;
        }
    }
    if ($Update) {
        // IF the API call was successful, lets save the list locally
        if ($update_option) {
            update_option('powerpress_migrate_queued', $QueuedFiles);
        } else {
            add_option('powerpress_migrate_queued', $QueuedFiles, '', 'no');
        }
        powerpress_page_message_add_notice(sprintf(__('%d media files added to migration queue.', 'powerpress'), $AddedCount));
    }
    if ($AlreadyAddedCount > 0) {
        powerpress_page_message_add_notice(sprintf(__('%d media files were already added to migration queue.', 'powerpress'), $AlreadyAddedCount));
    }
}
        function import()
        {
            ?>
	
<div class="wrap">
<h3><?php 
            _e('Importing Podcast', 'powerpress');
            ?>
</h3>
<?php 
            $result = false;
            if (empty($_POST['podcast_feed_url'])) {
                ?>
<p><?php 
                _e('From Uploaded file...', 'powerpress');
                ?>
</p><?php 
                $result = $this->_import_handle_upload();
            } else {
                ?>
<p><?php 
                _e('From URL', 'powerpress');
                ?>
 <?php 
                echo esc_html($_POST['podcast_feed_url']);
                ?>
</p><?php 
                $result = $this->_import_handle_url();
            }
            if ($result == false) {
                return;
            }
            $import_strict = !empty($_POST['import_strict']) ? true : false;
            $import_blog_posts = !empty($_POST['import_blog_posts']) ? true : false;
            $import_item_limit = !empty($_POST['import_item_limit']) ? intval($_POST['import_item_limit']) : 0;
            if (preg_match('/^(.*)<item>/is', $this->m_content, $matches)) {
                $overwrite_program_info = !empty($_POST['import_overwrite_program_info']) ? true : false;
                $import_itunes_image = !empty($_POST['import_itunes_image']) ? true : false;
                $this->import_program_info($matches[1], $overwrite_program_info, $import_itunes_image);
            }
            $this->import_episodes($import_strict, $import_blog_posts, $import_item_limit);
            $migrated_to_blubrry = false;
            if (!empty($_POST['migrate_to_blubrry']) && !empty($GLOBALS['pp_migrate_media_urls'])) {
                require_once POWERPRESS_ABSPATH . '/powerpressadmin-migrate.php';
                $migrated_to_blubrry = true;
                $update_option = true;
                $QueuedFiles = get_option('powerpress_migrate_queued');
                if (!is_array($QueuedFiles)) {
                    $QueuedFiles = array();
                    $update_option = false;
                }
                $add_urls = '';
                while (list($meta_id, $url) = each($GLOBALS['pp_migrate_media_urls'])) {
                    if (!empty($add_urls)) {
                        $add_urls .= "\n";
                    }
                    $add_urls .= $url;
                }
                $UpdateResults = powepress_admin_migrate_add_urls($add_urls);
                if (!empty($UpdateResults)) {
                    // Queued ok...
                    if ($update_option) {
                        update_option('powerpress_migrate_queued', $QueuedFiles);
                    } else {
                        add_option('powerpress_migrate_queued', $QueuedFiles, '', 'no');
                    }
                }
            }
            powerpress_page_message_print();
            echo '<h3>';
            echo __('Import Completed!', 'powerpress');
            echo '</h3>';
            echo '<p>' . sprintf(__('Items Skipped: %d', 'powerpress'), $this->m_item_skipped_count) . '</p>';
            echo '<p>' . sprintf(__('Items Inserted: %d', 'powerpress'), $this->m_item_inserted_count) . '</p>';
            echo '';
            if ($migrated_to_blubrry) {
                echo '<p>' . sprintf(__('Visit %s to monitor the migration process.', 'powerpress'), '<strong><a href="' . admin_url('admin.php?page=powerpress/powerpressadmin_migrate.php') . '">' . __('Migrate Media', 'powerpress') . '</a></strong>') . '</p>';
            } else {
                echo '<p>' . sprintf(__('You may now migrate your media manually or use the %s tool.', 'powerpress'), '<strong><a href="' . admin_url('admin.php?page=powerpress/powerpressadmin_migrate.php') . '">' . __('Migrate Media', 'powerpress') . '</a></strong>') . '</p>';
            }
        }