podcasting with Movable Type

I’ve been fooling around with using Movable Type to generate a podcast feed. (Are people still using pre-3.0 versions of MT? I am.) First I took an RSS 2.0 template (here’s one). Then I added some “enclosure” bits. But an enclosure wants to provide a “length” field (the file size), so I hacked up a quick MT plugin:

# FileSize.pl
# Movable Type plugin tag to print a file size
use strict;
use MT::Template::Context;
MT::Template::Context->add_container_tag('FileSize' => sub{&_hdlr_file_size;});
sub _hdlr_file_size {
  my ($ctx, $args, $cond) = @_;
  defined(my $text = $ctx->stash('builder')->build($ctx, $ctx->stash('tokens'), $cond)) || return $ctx->error($ctx->errstr);
  $text =~ s/^\s+//;
  if (-f $text) {
    return (stat($text))[7];
  } else {
    return "-1";

Now MT can generate an RSS 2.0 feed with enclosures.

Filed under technology · Tagged with

Comments are closed.