feedgen: PodcastGenerator finished (incl. docs)
This commit is contained in:
parent
b1af50776f
commit
222f3932be
2 changed files with 69 additions and 0 deletions
|
@ -69,6 +69,9 @@ if __name__ == '__main__':
|
||||||
fg.itunes_explicit('no')
|
fg.itunes_explicit('no')
|
||||||
fg.itunes_complete('no')
|
fg.itunes_complete('no')
|
||||||
fg.itunes_new_feed_url('http://example.com/new-feed.rss')
|
fg.itunes_new_feed_url('http://example.com/new-feed.rss')
|
||||||
|
fg.itunes_owner('John Doe', 'john@example.com')
|
||||||
|
fg.itunes_summary('Lorem ipsum dolor sit amet, consectetur adipiscing elit. Verba tu fingas et ea dicas, quae non sentias?')
|
||||||
|
|
||||||
print fg.podcast_str(pretty=True)
|
print fg.podcast_str(pretty=True)
|
||||||
elif arg.endswith('atom'):
|
elif arg.endswith('atom'):
|
||||||
fg.atom_file(arg)
|
fg.atom_file(arg)
|
||||||
|
|
|
@ -31,6 +31,9 @@ class PodcastGenerator(FeedGenerator):
|
||||||
__itunes_explicit = None
|
__itunes_explicit = None
|
||||||
__itunes_complete = None
|
__itunes_complete = None
|
||||||
__itunes_new_feed_url = None
|
__itunes_new_feed_url = None
|
||||||
|
__itunes_owner = None
|
||||||
|
__itunes_subtitle = None
|
||||||
|
__itunes_summary = None
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -78,6 +81,21 @@ class PodcastGenerator(FeedGenerator):
|
||||||
new_feed_url = etree.SubElement(channel, '{%s}new-feed-url' % ITUNES_NS)
|
new_feed_url = etree.SubElement(channel, '{%s}new-feed-url' % ITUNES_NS)
|
||||||
new_feed_url.text = self.__itunes_new_feed_url
|
new_feed_url.text = self.__itunes_new_feed_url
|
||||||
|
|
||||||
|
if self.__itunes_owner:
|
||||||
|
owner = etree.SubElement(channel, '{%s}owner' % ITUNES_NS)
|
||||||
|
owner_name = etree.SubElement(owner, '{%s}name' % ITUNES_NS)
|
||||||
|
owner_name.text = self.__itunes_owner.get('name')
|
||||||
|
owner_email = etree.SubElement(owner, '{%s}email' % ITUNES_NS)
|
||||||
|
owner_email.text = self.__itunes_owner.get('email')
|
||||||
|
|
||||||
|
if self.__itunes_subtitle:
|
||||||
|
subtitle = etree.SubElement(channel, '{%s}subtitle' % ITUNES_NS)
|
||||||
|
subtitle.text = self.__itunes_subtitle
|
||||||
|
|
||||||
|
if self.__itunes_summary:
|
||||||
|
summary = etree.SubElement(channel, '{%s}summary' % ITUNES_NS)
|
||||||
|
summary.text = self.__itunes_summary
|
||||||
|
|
||||||
return feed, doc
|
return feed, doc
|
||||||
|
|
||||||
|
|
||||||
|
@ -241,6 +259,54 @@ class PodcastGenerator(FeedGenerator):
|
||||||
return self.__itunes_new_feed_url
|
return self.__itunes_new_feed_url
|
||||||
|
|
||||||
|
|
||||||
|
def itunes_owner(self, name=None, email=None):
|
||||||
|
'''Get or set the itunes:owner of the podcast. This tag contains
|
||||||
|
information that will be used to contact the owner of the podcast for
|
||||||
|
communication specifically about the podcast. It will not be publicly
|
||||||
|
displayed.
|
||||||
|
|
||||||
|
:param itunes_owner: The owner of the feed.
|
||||||
|
:returns: Data of the owner of the feed.
|
||||||
|
'''
|
||||||
|
if not name is None:
|
||||||
|
if name and email:
|
||||||
|
self.__itunes_owner = {'name':name, 'email':email}
|
||||||
|
elif not name and not email:
|
||||||
|
self.__itunes_owner = None
|
||||||
|
else:
|
||||||
|
raise ValueError('Both name and email have to be set.')
|
||||||
|
return self.__itunes_owner
|
||||||
|
|
||||||
|
|
||||||
|
def itunes_subtitle(self, itunes_subtitle=None):
|
||||||
|
'''Get or set the itunes:subtitle value for the podcast. The contents of
|
||||||
|
this tag are shown in the Description column in iTunes. The subtitle
|
||||||
|
displays best if it is only a few words long.
|
||||||
|
|
||||||
|
:param itunes_subtitle: Subtitle of the podcast.
|
||||||
|
:returns: Subtitle of the podcast.
|
||||||
|
'''
|
||||||
|
if not itunes_subtitle is None:
|
||||||
|
self.__itunes_subtitle = itunes_subtitle
|
||||||
|
return self.__itunes_subtitle
|
||||||
|
|
||||||
|
|
||||||
|
def itunes_summary(self, itunes_summary=None):
|
||||||
|
'''Get or set the itunes:summary value for the podcast. The contents of
|
||||||
|
this tag are shown in a separate window that appears when the "circled i"
|
||||||
|
in the Description column is clicked. It also appears on the iTunes page
|
||||||
|
for your podcast. This field can be up to 4000 characters. If
|
||||||
|
<itunes:summary> is not included, the contents of the <description> tag
|
||||||
|
are used.
|
||||||
|
|
||||||
|
:param itunes_summary: Summary of the podcast.
|
||||||
|
:returns: Summary of the podcast.
|
||||||
|
'''
|
||||||
|
if not itunes_summary is None:
|
||||||
|
self.__itunes_summary = itunes_summary
|
||||||
|
return self.__itunes_summary
|
||||||
|
|
||||||
|
|
||||||
_itunes_categories = {
|
_itunes_categories = {
|
||||||
'Arts': [ 'Design', 'Fashion & Beauty', 'Food', 'Literature',
|
'Arts': [ 'Design', 'Fashion & Beauty', 'Food', 'Literature',
|
||||||
'Performing Arts', 'Visual Arts' ],
|
'Performing Arts', 'Visual Arts' ],
|
||||||
|
|
Loading…
Reference in a new issue