Hello,
Thanks a lot for this plugin. This has helped me create a lot of episodes easily. ^^
I would like to submit a patch to fix a bug and add support for more data columns. I’ve added a rudimentary support for adding Featured image id, series, iTunes season number, iTunes episode number, and iTunes episode type.
The bug fix is around the loop thru data. Somehow there seems to be a trailing newline character that would get added without trimming :
//let's loop thru our data
foreach($data as $rk=>$rd) {//use Row Key and Row Data as key value vars
+ $rd = trim($rd); //need to trim possible trailing newline character
And here’s the rest of the patch.
--- simple-bulk-episodes.php.orig 2019-07-29 13:58:57.340158900 +0700
+++ simple-bulk-episodes.php.tk 2019-07-29 14:16:37.727986900 +0700
@@ -4,8 +4,8 @@
Plugin Name: Simple Bulk Episodes
Plugin URI:
Description: A simple way to add a bulk of episodes for the Seriously Simple Podcasting plugin
- Version: 1.0
- Author: forlogos
+ Version: 1.1
+ Author: forlogos, tkittich
Author URI: https://jasonjalbuena.com
License: GPL V3
*/
@@ -14,7 +14,7 @@
private static $instance = null;
private $plugin_path;
private $plugin_url;
- private $text_domain = '';
+ private $text_domain = '';
/**
* Creates or returns an instance of this class.
@@ -62,7 +62,7 @@
<form method="post" action="edit.php?post_type=podcast&page=bulk_episodes">
<h3>Paste Excel data</h3>
<p>Data should be formatted with each row as one episode. Column data should be in this order:<br/><br/>
- <em>title, publish date time, HTML post content, Audio file URL, Audio duration, date recorded, explicit, block from itunes</em><br/><br/>
+ <em>title, publish date time, HTML post content, Audio file URL, Audio duration, date recorded, explicit, block from itunes, Featured image id, series, iTunes season number, iTunes episode number, iTunes episode type</em><br/><br/>
Leave data blank if you don't need it.
</p>
<textarea name="ep_info" style="width:100%;height:200px;"></textarea>
@@ -94,10 +94,11 @@
//let's loop thru our data
foreach($data as $rk=>$rd) {//use Row Key and Row Data as key value vars
+ $rd = trim($rd); //need to trim possible trailing newline character
if($rd!='' && $rd!=array()) {//verify that there is data for this row
$output.='<tr>';
$cells=explode( "\t", $rd);//get data for each cell
- $i=8;//set a counter for the # of cells we should have
+ $i=13;//set a counter for the # of cells we should have
foreach($cells as $cc=>$c) {//let's loop thru cell data, use Cell Count and Cell as key value vars
if($cc==1) {//if this is the date column use a different format
@@ -135,11 +136,11 @@
<table id="outputable">
<thead><tr>
- <th>title</th><th>publish date time</th><th>HTML post content</th><th>Audio file URL</th><th>Audio duration</th><th>date recorded</th><th>explicit</th><th>block from itunes</th>
+ <th>title</th><th>publish date time</th><th>HTML post content</th><th>Audio file URL</th><th>Audio duration</th><th>date recorded</th><th>explicit</th><th>block from itunes</th><th>Featured image id</th><th>series</th><th>iTunes season number</th><th>iTunes episode number</th><th>iTunes episode type</th>
</tr></thead>
<?php echo $output; ?>
<tfoot><tr>
- <th>title</th><th>publish date time</th><th>HTML post content</th><th>Audio file URL</th><th>Audio duration</th><th>date recorded</th><th>explicit</th><th>block from itunes</th>
+ <th>title</th><th>publish date time</th><th>HTML post content</th><th>Audio file URL</th><th>Audio duration</th><th>date recorded</th><th>explicit</th><th>block from itunes</th><th>Featured image id</th><th>series</th><th>iTunes season number</th><th>iTunes episode number</th><th>iTunes episode type</th>
</tr></tfoot>
</table>
@@ -175,37 +176,33 @@
add_post_meta($post_id, 'enclosure', $ep[3]);
add_post_meta($post_id, 'audio_file', $ep[3]);
- //calculate file size based on the URL
- $file=$ep[3];
-
- //the following code from SSP : seriously-simple-podcasting/includes/class-ssp-frontend.php
- // Include media functions if necessary
- if ( ! function_exists( 'wp_read_audio_metadata' ) ) {
- require_once( ABSPATH . 'wp-admin/includes/media.php' );
- }
- // Get file data (for local file)
- $data = wp_read_audio_metadata( $file );
- $raw = $formatted = '';
- if ( $data ) {
- $raw = $data['filesize'];
- $formatted = $this->format_bytes( $raw );
- } else {
- // get file data (for remote file)
- $data = wp_remote_head( $file, array( 'timeout' => 10, 'redirection' => 5 ) );
- if ( ! is_wp_error( $data ) && is_array( $data ) && isset( $data['headers']['content-length'] ) ) {
- $raw = $data['headers']['content-length'];
-
- $base = log ( $raw ) / log( 1024 );
- $suffixes = array( '' , 'k' , 'M' , 'G' , 'T' );
- $formatted = round( pow( 1024 , $base - floor( $base ) ) , 2 ) . $suffixes[ floor( $base ) ];
- }
+ // call ssp's function to get file size
+ global $ss_podcasting;
+
+ if (isset($ss_podcasting)) {
+ $size = $ss_podcasting->get_file_size( $ep[3] );
+ }
+ if (!empty($size['raw'])) {
+ add_post_meta($post_id, 'filesize_raw', $size['raw']);
+ }
+ if (!empty($size['formatted'])) {
+ add_post_meta($post_id, 'filesize', $size['formatted']);
}
- //end code from SSP
- add_post_meta($post_id, 'filesize_raw', $raw);
- add_post_meta($post_id, 'filesize', $formatted);
}
if(!empty($ep[4])) {//if audio duration provided - add
add_post_meta($post_id, 'duration', $ep[4]);
+ } else {
+ // add audio file duration to a podcast when using Simple Bulk Uploader
+ // code from Jonathan Bossenger (@psykro) https://www.ads-software.com/support/topic/calling-get_file_duration-from-another-plugin-during-bulk-episodes-imports/
+ global $ss_podcasting;
+
+ $duration = false;
+ if (isset($ss_podcasting)) {
+ $duration = $ss_podcasting->get_file_duration( $ep[3] );
+ }
+ if(!empty($duration)) {
+ add_post_meta($post_id, 'duration', $duration);
+ }
}
if(!empty($ep[5])) {//if date recorded provided - add
add_post_meta($post_id, 'date_recorded', $ep[5]);
@@ -216,8 +213,29 @@
if(!empty($ep[7]) && $ep[7]=='no') {//if block from itunes and is "no"- add
add_post_meta($post_id, 'block', $ep[7]);
}
+ if(!empty($ep[8])) {//if featured image url - add
+ //media_sideload_image will add a new image to media library
+ //$image = media_sideload_image($ep[8], $post_id);
+
+ //set thumbnail of image id already in the media library
+ set_post_thumbnail($post_id, (int)$ep[8]);
+ }
+ if(!empty($ep[9])) {//if serie - add
+ //only a single serie is supported now. must be the serie id number.
+ wp_set_post_terms( $post_id, array((int)$ep[9]), 'series' );
+ }
+ if(!empty($ep[10])) {//if iTunes season number - add
+ add_post_meta($post_id, 'itunes_season_number', $ep[10]);
+ }
+ if(!empty($ep[11])) {//if iTunes episode number - add
+ add_post_meta($post_id, 'itunes_episode_number', $ep[11]);
+ }
+ if(!empty($ep[12])) {//if iTunes episode type - add
+ // valid types: full, trailer, bonus
+ add_post_meta($post_id, 'itunes_episode_type', $ep[12]);
+ }
- echo get_the_title($post_id).': <a href="post.php?post='.$post_id.'&action=edit">edit</a> | <a href="'.get_permalink($post_id).'">view</a><br/>';
+ echo 'post_id: ' . $post_id . ': ' . get_the_title($post_id).': <a href="post.php?post='.$post_id.'&action=edit">edit</a> | <a href="'.get_permalink($post_id).'">view</a><br/>';
}
echo '<p><a href="edit.php?post_type=podcast&page=bulk_episodes">Add more!</a></p></div>';
}
]]>
Good day
I’m reaching out to see if you would be interested in me adopting this plugin. I tried reaching you via your website, but I’ve not heard anything back.
Thanks
]]>Hello! I’m about to try out your plugin and I noted that there seem to be a few fields missing in your Screenshots: featured image, tags, category, for example.
Is it possible to simply add those and others to the spreadsheet that’s copy/pasted, or does this require a change to the plugin in order to read them?
I’ve got hundreds of episodes to import and I’d like to figure this out before getting started. I’d hate to have to go in after importing and manually set the fields mentioned above for each one of several hundred episodes. Would kind of defeat the purpose of importing in bulk. ??
Thanks advance!
]]>