Feed Your MP3s to Movable Type

Use Movable Type’s XML-RPC support to podcast your MP3s automatically.

Perl makes it easy to create a script that will podcast an MP3 for you automatically, using Movable Type’s support for automatic blogging through its XML-RPC mechanism. This is partnered on the Perl side by the Net:: MovableType module [Hack #7] .

The Code

Save this file as ap.pl:

		use Net::MovableType;
		use MP3::Info;
		use Net::SFTP;
		use strict;
		# The specifics of your MovableType blog
use constant MT_XMLRPC_SERVICE => "http://myhost.com/mt/mt-xmlrpc.cgi";
use constant MT_LOGIN => "Melody";
use constant MT_PASSWORD => "Nelson";	
use constant MT_BLOGID => 
               1;
# The base URL of the directory where the podcasts go
use constant PODCAST_URL_BASE => "http://myhost.com/podcast/"; 
# The remote directories for SFTP to use to login and upload
# the file
use constant REMOTE_DIRECTORY => "html/podcast/
>";
use constant REMOTE_HOST => "localhost
>";
use constant REMOTE_LOGIN =>" 
               username
>";
use constant REMOTE_PASSWORD => "password
>";
# Post an entry to the blog using MovableType's XML-RPC mechanism
# through Net::MovableType
 sub postToBlog($$$) { my ( $title, $comment, $podcastURL ) = @_; my $mt = new Net::MovableType( MT_XMLRPC_SERVICE, MT_LOGIN, MT_PASSWORD ); $mt->blogId( MT_BLOGID ); my $description = $comment; $description .= "\n\n"; $description .= "<a href=\"$podcastURL\">Listen to '$title'</a>"; my $entry = { title => $title, description => $description }; $mt->newPost( $entry, 1 ); } ...

Get Podcasting Hacks now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.