Of the nature of old school blogging is quaint and dated, podcasting may not be far behind.

Ever since the start of a podcasting project interrupted by a hurricane Antonio Vantaggiato and I have been hodgepodging a podcast series we call “The Puerto Rico Connection” (yes the play on the movie title was deliberate but there is no overlap of plots).

I suggested maybe we not worry about committing to a platform, it seems like everywhere you run into a great service that ultimately limits what you can do for free before asking for $. We did four episodes on TapeWrite which we enjoyed, but the overhead of adding media cards took us down time sinkholes, especially when we yacked for over an hour.

Our cheaptech setup is to record from Skype using the Ecamm Call Recorder (useful as it splits our calls into separate audio tracks), and edited with Audacity.

My next idea was to serve them from my Reclaim Hosting account using Podcast Generator, which I had used as the audio source for a web site client. I though we would write up our shows as a publication on Medium.

I’ve used some of my March travel opportunities to connect with Antonio while in Guadalajara with Brian Lamb and Grant Potter and in Fredericksburg with Jim Groom. Look for some summer episodes when Antonio is traveling in Italy.

But then, as pften as not, Blog Struck Again, with Adam Croom’s post about his workflow using Amazon S3 (for media storage) and a web site and PowerPress plugin to manage the feeds.

I was inspired to try, for the sale of earning some new things, but also, of not relying on third party publishing platforms that may bite the dust someday.

So cut to the chance, welcome to our new Puerto Rico Connection site

I’ve mixed together the podcast episodes as a category of posts along with other related non-podcast ones. The Podcast feed is https://prconnection.cogdog.casa/feed/podcast/ (still waiting to hear back from iTunes of our submission).

A while ago I played every so slightly with Amazon Web Services, but never with S3; the tutorial Adam linked to was direct enough for me to get set up. For uploading the mp3s, I did find out the Firefox extension mentioned did not work with Quantum, and that I had trued and used a Chrome Extension (the web is moving and morphing always, friends).

The one thing to remember is always going to the AWS console to set the upload as public (it does not seem to inherit the bucket’s settings to be public, or I am a dolt and missed something).

But as is our audio have elegant URLs like https://s3.amazonaws.com/prconnection/ep003.mp3

For the WordPress web site I went back to an Anders Noren theme I know well, Garfunkel, that is the parent them for the SPLOTbox theme.

For SPLOTbox I had already figured out how to add an HTML5 audio player which is not supported in the parent theme- this is where if the format type is audio, I use a function I wrote that checks if it has an mp3 url in the part above the more tag, and if so, embeds the player. For this site I also added support for featured images so the player is tucked below it.

So on the front page, you get a player:

as well as on a single post.

If you want to gaze at code…

<?php elseif ( $format == 'audio' ) : ?> 

<div class="featured-media">

	<?php if ( has_post_thumbnail() ) : ?>
		<?php the_post_thumbnail( 'post-image' ); ?>
	
		<?php if ( ! empty( get_post( get_post_thumbnail_id() )->post_excerpt ) ) : ?>
					
			<div class="media-caption-container">
		
				<p class="media-caption"><?php echo get_post( get_post_thumbnail_id() )->post_excerpt; ?></p>
			
			</div>
		<?php endif; ?>
	<?php endif; ?>	

	<?php

	// Fetch post content
	$content = get_post_field( 'post_content', get_the_ID() );

	// Get content parts
	$content_parts = get_extended( $content );
	
	$media_url = $content_parts['main'];  // for reference below
	

	// can we embed this audio url?
	if ( is_url_embeddable( $media_url ) ) {

		// then do it
		// oEmbed part before <!--more--> tag
		$embed_code = wp_oembed_get( $media_url ); 

		echo $embed_code;


	} else {
		// then we have a sound file so show it as a player
		
		echo prconnection_get_audioplayer( $media_url );
		
	}
	

	?>

</div><!-- .featured-media -->

These are the helper functions I also brought over, they might be more than this site needs, but they do work.

function prconnection_get_audioplayer( $url ) {
	// output the  audio player
	
	$audioplayer = '
<audio controls="controls" class="audio-player">
	<source src="' . $url . '" />
</audio>' . "\n";
	return ($audioplayer);
}

function url_is_audio ( $url ) {
// tests urls to see if they point to an audio type

	if ( is_in_url( 'soundcloud.com', $url ) or url_is_audio_link( $url ) ) return true;
	
}

function url_is_audio_link ( $url ) {

	$fileExtention 	= pathinfo ( $url, PATHINFO_EXTENSION ); 	// get file extension for url	
	$allowables 	= 	array( 'mp3', 'm4a'); 	// allowable file extensions
	
	// check the url file extension to ones we will allow
	return ( in_array( strtolower( $fileExtention) ,  $allowables  ) );
}

// check if $url contacts a string (like domain name) 
function is_in_url ( $pattern, $url ) {

	if ( strpos( $url, $pattern) === false ) {
		return (false);
	} else {
		return (true);
	}
}

function is_url_embeddable( $url ) {
// test if URL matches the ones that WordPress can do oembed on
// test by by string matching
	
	$allowed_embeds = array(
					'youtube.com/watch?',
					'youtu.be',
					'vimeo.com', 
					'soundcloud.com',
	);
	
	// walk the array til we get a match
	foreach( $allowed_embeds as $fragment ) {
  		if  (strpos( $url, $fragment ) !== false ) {
			return ( true );
		}
	}	
	
	// no matches, no embeds for you
	return ( false );
}

I also added to the meta data in the footer a link to download the audio (it also makes sure the URL gets in the feed)

With this bit of code in the single.php template

<?php 
	if ( isset($media_url) AND  url_is_audio_link ( $media_url )   ) 
			echo '<p><a href="' . $media_url . '" 
			class="download-link pretty-button pretty-button-gray" 
			download>Download "' . get_the_title() . '"</a></p>';
?>

And following Adam’s lead, the PowerPress podcast plugin seems to add the necessary iTunes meta data to the feed. This is a nice trick to preface the Amazon S3 links with https://dts.podtrac.com/redirect.mp3/ to work as the Media URL

I also decided to enable the link style format types, so we could include references to wonderful posts like this one:

on our site as

We are still checking the tires, but I’m pretty happy with both what we have as a site we own and as always a few more skills, tricks, and technical card games I learned along the way.


Featured Image: Could not resist a classic Brian Lamb photo from the heady days of blogging AND podcasting in 2006:

Man With a Microphone

Man With a Microphone flickr photo by cogdogblog shared into the public domain using Creative Commons Public Domain Dedication (CC0)