[podcast]

Description

Link: [podcast]
Author: Jason Huck
Category: XML
Version: 8.x
License:
Posted: Nov. 18, 2006
Updated: Jan. 01, 0001
More by this author...
Three tags to make generating podcast feeds in Lasso easier:

[podcast_categories] - A constant which is a map of all allowed top-level categories. The value of each item in the map is an array of allowed subcategories.

[podcast_item] - A custom type for creating item nodes for the feeds -- the block of xml that describes an individual episode in your podcast.

[podcast] - A custom type for assembling and serving the complete feed.

All of the parameters specified in the Apple spec are supported. See the official documentation and the sample code below. Requires [xml_tree].

Parameters

none


Sample Usage

var('myitem') = podcast_item(
	-title='test title',
	-author='me',
	-enclosure=map(
		'href' = 'http://www.somewhere.com/',
		'length' = 123456,
		'type' = 'audio/mpeg'
	),
	-summary='Much ado about nothing.',
	-guid='90210',
	-pubDate=date,
	-duration=duration('00:03:35')
);

var('items') = array($myitem);

var('myfeed') = podcast(
	-title='mypodcast',
	-link='http://somewhere.com/',
	-language='en-us',
	-copyright='©2006 Somebody.',
	-description='The podcast about nothing. Just like all the rest.',
	-summary='Really, it is just a bunch of talking.',
	-ownername='me',
	-image='blah.gif',
	-category='Arts',
	-subcats=(: 'Design', 'Visual Arts'),
	-items=$items
);

content_type('text/xml;charset=utf-8');
$myfeed;
						

Source Code

Click the "Download" button below to retrieve a copy of this tag, including the complete documentation and sample usage shown on this page. Place the downloaded ".inc" file in your LassoStartup folder, restart Lasso, and you can begin using this tag immediately.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
!lasso_tagexists('podcast_categories') ?
define_constant(
	'categories', 
	-namespace='podcast_',
	map(
		'Arts' = (: 'Design', 'Fashion & Beauty', 'Food', 'Literature', 'Performing Arts', 'Visual Arts'),
		'Business' = (: 'Business News', 'Careers', 'Investing', 'Management & Marketing', 'Shopping'),
		'Comedy' = array,
		'Education' = (: 'Education Technology', 'Higher Education', 'K-12', 'Language Courses', 'Training'),
		'Games & Hobbies' = (: 'Automotive', 'Aviation', 'Hobbies', 'Other Games', 'Video Games'),
		'Government & Organizations' = (: 'Local', 'National', 'Non-Profit', 'Regional'),
		'Health' = (: 'Alternative Health', 'Fitness & Nutrition', 'Self-Help', 'Sexuality'),
		'Kids & Family' = array,
		'Music' = array,
		'News & Politics' = array,
		'Religion & Spirituality' = (: 'Buddhism', 'Christianity', 'Hinduism', 'Islam', 'Judaism', 'Other', 'Spirituality'),
		'Science & Medicine' = (: 'Medicine', 'Natural Sciences', 'Social Sciences'),
		'Society & Culture' = (: 'History', 'Personal Journals', 'Philosophy', 'Places & Travel'),
		'Sports & Recreation' = (: 'Amateur', 'College & High School', 'Outdoor', 'Professional'),
		'Technology' = (: 'Gadgets', 'Tech News', 'Podcasting', 'Software How-To'),
		'TV & Film' = array
	)
);



define_type(
	'podcast',
	-description='Extends [xml_tree] specifically for the podcast RSS format.'
);
	local('data' = xml_tree);

	define_tag(
		'onCreate',
		-opt='title',
		-opt='link',
		-opt='language',
		-opt='copyright',
		-opt='description',
		-opt='subtitle',
		-opt='author',
		-opt='summary',
		-opt='block',
		-opt='explicit',
		-opt='keywords',
		-opt='image',
		-opt='ownername',
		-opt='owneremail',
		-opt='new-feed-url',
		-opt='items',
		-opt='category',
		-opt='subcats', -type='array'
	);
		self->'data'->setname('rss');
		self->'data'->addattribute('version'='2.0');
		self->'data'->addnamespace('itunes'='http://www.itunes.com/dtds/podcast-1.0.dtd');
		self->'data'->newchild('channel');
		
		iterate((:'title', 'link', 'language', 'copyright', 'description'), local('i'));
			if(local_defined(#i));
				self->'data'->channel->newchild(#i);
				self->'data'->channel->getnode(#i)->addcontent(local(#i));
			/if;
		/iterate;
		
		iterate((:'subtitle', 'author', 'summary', 'block', 'explicit', 'keywords', 'new-feed-url'), local('i'));
			if(local_defined(#i));
				local('nodename' = 'itunes:' + #i);
				self->'data'->channel->newchild(#nodename);
				self->'data'->channel->getnode(#nodename)->addcontent(local(#i));
			/if;
		/iterate;
		
		if(local_defined('image'));
			self->'data'->channel->newchild('itunes:image');
			self->'data'->channel->getnode('itunes:image')->addattribute('href'=#image);
		/if;
		
		// workaround
		iterate((:'ownername', 'owneremail'), local('i'));
			if(local_defined(#i));
				self->'data'->channel->newchild('itunes:owner');
				loop_abort;
			/if;
		/iterate;
		
		iterate((:'ownername', 'owneremail'), local('i'));
			if(local_defined(#i));
				local('nodename' = 'itunes:' + string_removeleading(#i, -pattern='owner'));					
				self->'data'->channel->getnode('itunes:owner')->newchild(#nodename);
				self->'data'->channel->getnode('itunes:owner')->getnode(#nodename)->addcontent(local(#i));
			/if;		
		/iterate;
		
		if(local_defined('category') && podcast_categories->find(#category) != '');
			self->'data'->channel->newchild('itunes:category');
			self->'data'->channel->getnode('itunes:category')->addattribute('text'=#category);
			
			if(local_defined('subcats'));
				iterate(#subcats, local('i'));
					if(podcast_categories->find(#category)->size && podcast_categories->find(#category) >> #i);
						self->'data'->channel->getnode('itunes:category')->newchild('itunes:category');
						self->'data'->channel->getnode('itunes:category')->lastchild->addattribute('text'=#i);
					/if;
				/iterate;
			/if;
		/if;
		
		if(local_defined('items'));
			iterate(#items, local('i'));
				// may have problems getting this to work with xml_tree...
				self->'data'->channel->addchild(xml(#i));
			/iterate;
		/if;
	/define_tag;
	
	define_tag('_unknownTag');
		return(self->'data'->tag_name);
	/define_tag;
	
	define_tag('onConvert');
		return(string(self->'data'));
	/define_tag;
/define_type;



define_type(
	'item',
	-namespace='podcast_',
	-description='Generates XML for a podcast item RSS node.'
);
	local('data' = xml_tree);
	
	define_tag(
		'onCreate',
		-opt='title',
		-opt='author',
		-opt='subtitle',
		-opt='summary',
		-opt='enclosure', -type='map',
		-opt='guid',
		-opt='pubDate', -type='date',
		-opt='duration', -type='duration',
		-opt='keywords',
		-opt='block',
		-opt='explicit'
	);
		self->'data'->setname('item');
		self->'data'->addnamespace('itunes'='http://www.itunes.com/dtds/podcast-1.0.dtd');
		
		iterate((:'title', 'guid'), local('i'));
			if(local_defined(#i));
				self->'data'->newchild(#i);
				self->'data'->getnode(#i)->addcontent(local(#i));
			/if;
		/iterate;
		
		iterate((:'subtitle', 'author', 'summary', 'block', 'explicit', 'keywords', 'duration'), local('i'));
			if(local_defined(#i));
				local('nodename' = 'itunes:' + #i);
				self->'data'->newchild(#nodename);
				self->'data'->getnode(#nodename)->addcontent(local(#i));
			/if;
		/iterate;
		
		if(local_defined('pubDate'));
			self->'data'->newchild('pubDate');
			// Wed, 15 Jun 2005 19:00:00 GMT
			self->'data'->pubDate->addcontent(date_localtogmt(#pubDate)->format('%a, %d %b %Y %H:%M:%S GMT'));
		/if;
		
		if(local_defined('enclosure'));
			self->'data'->newchild('enclosure');
			self->'data'->enclosure->addattribute('url'=#enclosure->find('url'));
			self->'data'->enclosure->addattribute('length'=#enclosure->find('length'));
			self->'data'->enclosure->addattribute('type'=#enclosure->find('type'));
		/if;
		
		// convert to xml type when finished to work around inheritance bugs
		self->'data' = xml(self->'data');
	/define_tag;

	define_tag('_unknownTag');
		return(self->'data'->tag_name);
	/define_tag;
	
	define_tag('onConvert');
		return(string(self->'data'));
	/define_tag;
/define_type;

 

Related Tags



Comments

none

Email:


Password:



Newest

Most Popular