I want to publish more interview audio, but I need to make a modification to Drupal before I do -- and I might need some PHP coding help to do it.
I want to be able to have an RSS feed that people can pop into iTunes at any time and download all 86 of my interviews.
UPDATE: I've successfully written a Drupal module to do this. I'll post it below.
I need to have my audience be able to very quickly and easily have access to all of my source material by copying one feed into an audio aggregator and let it do a bulk download of all the files.
Expecting people to download each interview is out of the question -- there are too many. I could split it up separate feed sections, but I want to make downloading all of the files as easy as possible with four easy steps:
1. Copy the feed
2. Paste it in the subscribe window
3. Download all the files
4. There is no step four
And so I imagine that this will require a relatively simple Drupal module or "PHP node" that can produce the necessary XML data to do the trick.
I welcome any help in making this happen since it seems like it should be a pretty useful feature to have.
I specifically need to take all of the nodes that have the "Interview Audio" tag, and produce the RSS code to send down the Feedburner feed.
The issue is that my regular feed is limited to displaying 25 posts -- and I also have the full text selected.
This means that this Drupal only displays the last 25 posts for all of the feeds, but for the posts tagged with "Interview Audio" I want it to display the last 86 posts.
I also don't want to send the full text down the "Interview Audio" feed because I plan on posting the entire transcript with each audio file, and this would inevitably exceed Feedburner's bandwidth limit by the time I would reach the 86th post.
So either I need to dig into the Drupal code myself and hack something together, or I need to find someone who can help out.
I'm going to assess the solution until I run into a road block, and then I can start publishing more interview audio.
Below I've posted the code for the module...
<?php
// $Id: podcastrss.module,v 0.1 2006/02/06 19:48:10 kentbye Exp $
/**
* Implementation of hook_help
*/
function podcastrss_help($section) {
switch ($section) {
case 'admin/modules#description':
return t('Special Podcast Feed');
}
}
/**
* Implementation of hook_perm().
*/
function podcastrss_perm() {
return array('access podcastrss');
}
/**
* Implementation of hook_settings
*/
function podcastrss_settings() {
return $output;
}
/**
* Implementation of hook_menu
*/
function podcastrss_menu($may_cache) {
$items = array();
if ($may_cache) {
$items[] = array('title' => t('Echo Chamber Project Interview Audio'),
'path' => "podcastrss",
'callback' => 'podcastrss_page',
'access' => user_access('access podcastrss'),
'type' => MENU_CALLBACK);
}
return $items;
}
/**
* menu callback renders the XML for an entire audio archive.
*/
function podcastrss_page() {
global $base_url, $locale;
$channel = array();
// SELECT ALL NODES THAT HAVE TERM TID=195 of "InterviewAudio" created by uid=2 (i.e. kentbye)
$nodes = db_query("SELECT n.nid FROM {node} n LEFT JOIN {term_node} t ON n.nid = t.nid WHERE t.tid= %d AND n.status = 1 AND n.uid = %d ORDER BY n.created DESC", 195, 2);
while ($node = db_fetch_object($nodes)) {
// Load the specified node:
$item = node_load($node->nid);
// Filter and prepare node teaser (Use the default of teaser to include full transcript after the break without exceeding Feedburner bandwidth limit
$teaser = TRUE;
if (node_hook($item, 'view')) {
node_invoke($item, 'view', $teaser, FALSE);
}
else {
$item = node_prepare($item, $teaser);
}
// Allow modules to change $node->teaser before viewing.
node_invoke_nodeapi($item, 'view', $teaser, FALSE);
$item_text = $item->teaser;
$item_text .= '<p>'. l(t('read more'), 'node/'. $item->nid, NULL, NULL, NULL, TRUE) .'</p>';
// Automatically include the link to the rest of the post
$item = node_prepare($item, $teaser);
$link = url("node/$node->nid", NULL, NULL, 1);
// Allow modules to add additional item fields
$extra = node_invoke_nodeapi($item, 'rss item');
$extra = array_merge($extra, array(array('key' => 'pubDate', 'value' => date('r', $item->created)), array('key' => 'dc:creator', 'value' => $item->name), array('key' => 'guid', 'value' => $item->nid . ' at ' . $base_url, 'attributes' => array('isPermaLink' => 'false'))));
foreach ($extra as $element) {
if ($element['namespace']) {
$namespaces = array_merge($namespaces, $element['namespace']);
}
}
// This is where all of the specific Podcast info is formatted within the XML data structure -- it is nested below
$items .= format_rss_item($item->title, $link, $item_text, $extra);
}
// Set the DEFAULT VARIABLES
$channel['title'] = "Echo Chamber Project Interview Audio";
// RSS feed will link to http://www.echochamberproject.com/InterviewAudio
$channel['link'] = url("interviewaudio", NULL, NULL, TRUE);
$channel['description'] = "Interview Audio from the Echo Chamber Project";
$channel["version"] = '2.0';
// $locale = 'en'
$channel["language"] = $locale;
$namespaces = array('xmlns:dc="http://purl.org/dc/elements/1.1/"');
// OUTPUT THE RSS
$output = "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n";
$output .= "<rss version=\"". $channel["version"] . "\" xml:base=\"". $base_url ."\" ". implode(' ', $namespaces) .">\n";
// The following line is where the bulk of the RSS feed is generated
$output .= format_rss_channel($channel['title'], $channel['link'], $channel['description'], $items, $channel['language']);
$output .= "</rss>\n";
drupal_set_header('Content-Type: text/xml; charset=utf-8');
print $output;
}
?>