I want my users to be able to take their podcast content type created by the audio module and create podcast feeds.
This functionality is not very apparent in the 5.x version of Drupal. The 4.7 version was much different and worked well. Is this possible or do I have to re-write the audio_feeds module to output the xml for individual podcasts? I was able to configure views so that each user could have a personal podcast of their audio but not specific to individual podcasts.
Has this issue ever been addressed before?
Thank you,
Matthew Ross
mross@mypodworks.com
http://www.mypodworks.com/
| Comment | File | Size | Author |
|---|---|---|---|
| #2 | CCK_fields_podcasts.jpg | 38.9 KB | podworks |
Comments
Comment #1
zirafa commentedThe reason this functionality has changed is because podcasts require storing metadata per feed. In the past this was accomplished with a playlist node type, but this isn't a good long term solution.
One idea: Have a configuration page to decide what CCK fields should be used to output the metadata part of the feed, and re-use audio_itunes code to build the actual feed.
This way you could create a new CCK type called "playlist" and create the fields you want for it. Then you assign which fields are used to generate the podcast metadata.
Idea #2: Expose audio_attach relationships to views, so for a given view it would return all audio nodes that belong to that playlist, and then use audio_itunes to generate the feed.
Comment #2
podworks commentedHi Zirafa,
I have configured the CCK fields for my "Podcast" content type but am having problems with rewriting the audio_itunes.module to output the feed correctly and how to put this feed on same line as other audio feeds.
I have attached an image of the fields I created.
Could you help with this issue?
Thank you,
Matthew S. Ross
Comment #3
zirafa commentedHi, Take a look at the audio_playlist_podcast_feed function here.
Then look at the audio_playlist.module in the audio/contrib directory, which shows how to build a feed for m3u, pls xspf. You can basically do the same thing and modify the audio_playlist module you have to support this and load in your custom metadata.
Comment #4
podworks commentedHi Zirafa,
Were you speaking of the audio_feeds.module or audio_playlist.module? I found what you spoke about in the audio feeds module and will try to modify.
Thank,
Matthew S. Ross
Comment #5
zirafa commentedaudio_feeds.module, yes.
Comment #6
podworks commentedHi zirafa,
I have made changes to functions in both feeds.inc and audio_feeds.module. I can't seem to pull the right values from the database. Is my syntax wrong or is $node incorrect. I am able to pull info from the $item array but not the $node. Is there a special way to pull info from the newly created CCK fields in my "Podcast" content type?
Thanks,
Matthew S. Ross
feeds.inc
/**
* Return XML for podcast feed
*/
function audio_feeds_generate_podcast($items = array(), $metadata = array()) {
// Metadata about this feed
$output = '<?xml version="1.0" encoding="UTF-8"?>' . " \n";
$output .= '' . " \n";
$output .= " \n";
$output .= "60 \n";
$output .= "". $metadata['title'] ." \n";
$output .= "
". $metadata['link'] ." \n";
$output .= "". $metadata['generator'] ."";
$output .= "". $metadata['owner_email'] ." (". $metadata['owner_name'] .")";
$output .= "
" . $metadata['created'] . " \n";
$output .= "". $metadata['language'] ."";
$output .= "". $metadata['copyright'] ."";
$output .= "". $metadata['explicit'] ."";
$output .= "". $metadata['subtitle'] ."";
$output .= "". $metadata['author'] ."";
$output .= "" . $metadata['summary'] . "";
$output .= "" . $metadata['description'] ."";
$output .= "";
$output .= "". $metadata['owner_name'] ."";
$output .= "". $metadata['owner_email'] ."";
$output .= "";
$output .= "";
$output .= "". $metadata['image']['image_url'] ."". $metadata['image']['width'] ."". $metadata['image']['height'] ."";
if (is_array($metadata['categories'])) {
foreach ($metadata['categories'] as $category) {
$output .= ""; // used for subcategories
$output .= "". $category .""; // RSS categories
}
}
// Cycle through all the items in this feed
foreach ($items as $item) {
$output .= " \n";
$output .= " ". $item['title'] ." \n";
$output .= " ". $item['guid'] ." \n";
$output .= "
". $item['link'] ." \n";
$output .= " ". $item['author'] ." \n";
$output .= " ". $item['subtitle'] ." \n";
$output .= " ". $item['creator'] ." \n";
$output .= " ". $item['content'] ." \n";
$output .= " ". $item['summary'] ." \n";
$output .= " ". $item['description'] ." \n";
$output .= " ". $item['comments'] ."";
$output .= " ". $item['summary'] ." \n";
$output .= " \n";
$keywords = implode(", ", $item['keywords']);
$output .= "". $keywords ."";
$output .= " ". $keywords ." \n";
$output .= " ". $item['duration'] ." \n";
$output .= "
" . $item['created'] . " \n";
$output .= " \n";
}
$output .= " \n";
$output .= " \n";
drupal_set_header('Content-Type: text/xml; charset=UTF-8');
print $output;
exit();
}
audio_feeds.module
/**
* Menu Callback to generate PODCAST feed
*/
function audio_feeds_podcast($nid) {
global $base_url;
$node = node_load($nid);
$children = $node->audio_attach;
//$copyright = $node->field_copyright;
// prepare feed metadata
$metadata = array('title' =>$node->title,
'author' => $node->name,
'link' => url('node/'.$node->nid, NULL,NULL, TRUE),
'feed_url' => url('node/'.$node->nid.'/podcast', NULL,NULL, TRUE),
'generator' => $node->generator,
'owner_email' => $node->field_owner_email,
'created' => $node->created,
'language' => $node->language,
'copyright' => $node->field_copyright['value'],
'explicit' => $node->field_explicit,
'subtitle' => $node->field_subtitle,
'author' => $node->field_author,
'summary' => $node->field_summary,
'description' => $node->field_description,
'owner_name' => $node->field_owner_name['value'],
'owner_email' => $node->field_owner_email,
'image_url' => $node->field_image_url,
'categories' => $node->field_categories
);
// prepare feed items
$items = array();
foreach ($children as $child) {
$audio = node_load($child);
if (node_access('view', $audio)) {
// use the first image uploaded as the included image
$image = is_array($audio->audio_images) ? current($audio->audio_images) : '';
$items[] = array('title' => $audio->audio_tags['title'],
'author' => $audio->audio_tags['artist'],
'subtitle' =>$audio->audio_itunes['subtitle'],
'summary' =>$audio->audio_itunes['summary'],
'album' => $audio->audio_tags['album'],
'duration' => $audio->audio_file['playtime'],
'link' => url('node/'.$audio->nid, NULL,NULL, TRUE),
'image' => array('url' => $base_url .'/'. $image['filepath']),
'enclosure' => array('url' => $audio->url_play)
);
}
}
audio_feeds_generate_podcast($items, $metadata);
}
Comment #7
zirafa commentedHey,
When printing out CCK fields usually you can't just do $node->field_description, you have to do something like:
or to get the raw value:
If you choose the latter approach you can use this command to see exactly how it is stored in the array:
-z
Comment #8
podworks commentedHi zirafa,
All that you have told me has done wonders. I am having a few problems with some of my fields being put in rss feed correctly.
Do you know how to convert the "created" number into "Wed, 15 Jun 2007 19:00:00 GMT" format?
portion of code below:
'created' => $node->created,
'language' => $node->field_language[0]['value'],
'copyright' => $node->field_copyright[0]['value'],
'explicit' => $node->field_explicit[0]['value'],
'subtitle' => $node->field_subtitle[0]['value'],
'author' => $node->field_author[0]['value'],
'summary' => $node->field_summary[0]['value'],
'description' => $node->field_description[0]['value'],
Thank you,
Matthew S. Ross
Comment #9
podworks commentedHi zirafa,
Still having issues with the "created" timeformat but will also bring up issue with feed_url link. Is there a way to replace the http with itpc? I have looked for other posts on this but nothing working like I need.
I have even tried a string replace command on the base_url and it works when I echo the results but it does not correctly on webpage. Is it possibly getting over ridden somewhere else in code?
Have you run into this request and know of a fix?
Thank you,
Matthew S. Ross
Comment #10
podworks commentedHi zirafa,
I am having difficulty coming up with a way to search a url for "/podcast" and if present then return the protocol as itpc.
I found some code earlier that changed the protocol from http to https. I modified it and it is below.
if (!strcasecmp(substr($_SERVER['REQUEST_URI'],0,5),'/podcast') && !isset($_SERVER['HTTPS'])) {
header("Location: https://" . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']);
exit();
}
if (!strcasecmp(substr($_SERVER['REQUEST_URI'],0,5),'/podcast')) {
$protocol = "itcp";
}
else {
$protocol = "http";
}
$base_url = $protocol . "://www.mypodworks.com";
Do you have any ideas to make this work and have it live in my settings.php file?
Thanks,
Matt
Comment #11
zirafa commentedAbout $node->created :
You can format this with the date_format() function. Also see PHP's own date() function for the syntax to use for this.
As for the itpc protocol I have no idea what you are trying to do. I think it is best to try not to mess with the settings.php file though.