本文整理汇总了Python中feedgen.feed.FeedGenerator.ttl方法的典型用法代码示例。如果您正苦于以下问题:Python FeedGenerator.ttl方法的具体用法?Python FeedGenerator.ttl怎么用?Python FeedGenerator.ttl使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类feedgen.feed.FeedGenerator
的用法示例。
在下文中一共展示了FeedGenerator.ttl方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: generate_feed
# 需要导入模块: from feedgen.feed import FeedGenerator [as 别名]
# 或者: from feedgen.feed.FeedGenerator import ttl [as 别名]
def generate_feed(input_file, output_file):
fg = FeedGenerator()
fg.load_extension('podcast', rss=True)
## RSS tags
# Required
fg.title(TITLE)
fg.link(href=LINK)
fg.description(DESCRIPTION)
# Optional
fg.language('en')
fg.image(url=IMAGE_URL, title=TITLE, link=LINK)
fg.ttl(720)
fg.webMaster(CONTACT['name'])
now = datetime.datetime.now()
tz = pytz.timezone('Europe/Amsterdam')
fg.pubDate(tz.localize(now))
# iTunes
fg.podcast.itunes_author('Dan LeBatard')
fg.podcast.itunes_category(itunes_category='Sports & Recreation', itunes_subcategory='Professional')
fg.podcast.itunes_image(itunes_image=IMAGE_URL)
fg.podcast.itunes_explicit(itunes_explicit='clean')
fg.podcast.itunes_owner(name=CONTACT['name'], email=CONTACT['email'])
# Add items
items = read_items(input_file)
for item in items:
fe = fg.add_entry()
## RSS tags
fe.id(item['guid'])
fe.title(item['title'])
fe.description(item['description'])
fe.enclosure(item['link'], 0, 'audio/mpeg')
fe.pubdate(item['pubDate'])
# Finish off the file
fg.rss_str(pretty=True)
fg.rss_file(output_file)
示例2: generate_feed
# 需要导入模块: from feedgen.feed import FeedGenerator [as 别名]
# 或者: from feedgen.feed.FeedGenerator import ttl [as 别名]
def generate_feed():
tz = pytz.timezone(config.timezone)
# Get latest X entries from database
entries = dbhelper.get_latest_entries()
fg = FeedGenerator()
# Feed id
fg.id(config.bot_link)
# Creator info (for Atom)
fg.author(name=config.author_name, email=config.author_email, replace=True )
# Self link to the feed
fg.link(href=config.feed_link, rel='self')
# Set description of your feed
fg.description(config.feed_description)
# Last time feed updated (use system time with timezone)
fg.lastBuildDate(formatdate(datetime.timestamp(datetime.now(tz)), localtime=True))
fg.title(config.feed_title)
# Set time-to-live (I really don't know why set this)
fg.ttl(5)
# Does this parameter mean anything?
fg.language(config.feed_language)
for entry in entries:
item = fg.add_entry()
# Use message id to form valid URL (new feature in Telegram since Feb 2016)
item.id("{!s}".format(entry["pid"]))
item.link(href="{!s}/{!s}".format(config.bot_link, entry["pid"]), rel="alternate")
# Set title and content from message text
item.title(entry["ptext"])
item.content(entry["ptext"])
# Set publish/update datetime
item.pubdate(entry["pdate"])
item.updated(entry["pdate"])
# Write RSS/Atom feed to file
# It's preferred to have only one type at a time (or just create two functions)
fg.atom_file('static/atom.xml')
示例3: setUp
# 需要导入模块: from feedgen.feed import FeedGenerator [as 别名]
# 或者: from feedgen.feed.FeedGenerator import ttl [as 别名]
def setUp(self):
fg = FeedGenerator()
self.nsAtom = "http://www.w3.org/2005/Atom"
self.nsRss = "http://purl.org/rss/1.0/modules/content/"
self.feedId = 'http://lernfunk.de/media/654321'
self.title = 'Some Testfeed'
self.authorName = 'John Doe'
self.authorMail = '[email protected]'
self.author = {'name': self.authorName, 'email': self.authorMail}
self.linkHref = 'http://example.com'
self.linkRel = 'alternate'
self.logo = 'http://ex.com/logo.jpg'
self.subtitle = 'This is a cool feed!'
self.link2Href = 'http://larskiesow.de/test.atom'
self.link2Rel = 'self'
self.language = 'en'
self.categoryTerm = 'This category term'
self.categoryScheme = 'This category scheme'
self.categoryLabel = 'This category label'
self.cloudDomain = 'example.com'
self.cloudPort = '4711'
self.cloudPath = '/ws/example'
self.cloudRegisterProcedure = 'registerProcedure'
self.cloudProtocol = 'SOAP 1.1'
self.icon = "http://example.com/icon.png"
self.contributor = {'name': "Contributor Name",
'uri': "Contributor Uri",
'email': 'Contributor email'}
self.copyright = "The copyright notice"
self.docs = 'http://www.rssboard.org/rss-specification'
self.managingEditor = '[email protected]'
self.rating = '(PICS-1.1 "http://www.classify.org/safesurf/" ' + \
'1 r (SS~~000 1))'
self.skipDays = 'Tuesday'
self.skipHours = 23
self.textInputTitle = "Text input title"
self.textInputDescription = "Text input description"
self.textInputName = "Text input name"
self.textInputLink = "Text input link"
self.ttl = 900
self.webMaster = '[email protected]'
fg.id(self.feedId)
fg.title(self.title)
fg.author(self.author)
fg.link(href=self.linkHref, rel=self.linkRel)
fg.logo(self.logo)
fg.subtitle(self.subtitle)
fg.link(href=self.link2Href, rel=self.link2Rel)
fg.language(self.language)
fg.cloud(domain=self.cloudDomain, port=self.cloudPort,
path=self.cloudPath,
registerProcedure=self.cloudRegisterProcedure,
protocol=self.cloudProtocol)
fg.icon(self.icon)
fg.category(term=self.categoryTerm, scheme=self.categoryScheme,
label=self.categoryLabel)
fg.contributor(self.contributor)
fg.copyright(self.copyright)
fg.docs(docs=self.docs)
fg.managingEditor(self.managingEditor)
fg.rating(self.rating)
fg.skipDays(self.skipDays)
fg.skipHours(self.skipHours)
fg.textInput(title=self.textInputTitle,
description=self.textInputDescription,
name=self.textInputName, link=self.textInputLink)
fg.ttl(self.ttl)
fg.webMaster(self.webMaster)
fg.updated('2017-02-05 13:26:58+01:00')
fg.pubDate('2017-02-05 13:26:58+01:00')
fg.generator('python-feedgen', 'x', uri='http://github.com/lkie...')
fg.image(url=self.logo,
title=self.title,
link=self.link2Href,
width='123',
height='123',
description='Example Inage')
self.fg = fg