August 2005
Beginner
464 pages
12h 36m
English
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]
.
Save this file as ap.pl:
use Net::MovableType; use MP3::Info; use Net::SFTP; use strict; # The specifics of your MovableType bloguse 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 gouse constant PODCAST_URL_BASE =>"http://myhost.com/podcast/"; # The remote directories for SFTP to use to login and upload # the fileuse 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 ); } ...
Read now
Unlock full access