本文整理汇总了Python中feedgen.feed.FeedGenerator.category方法的典型用法代码示例。如果您正苦于以下问题:Python FeedGenerator.category方法的具体用法?Python FeedGenerator.category怎么用?Python FeedGenerator.category使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类feedgen.feed.FeedGenerator
的用法示例。
在下文中一共展示了FeedGenerator.category方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: print_enc
# 需要导入模块: from feedgen.feed import FeedGenerator [as 别名]
# 或者: from feedgen.feed.FeedGenerator import category [as 别名]
print_enc (' atom -- Generate ATOM test output and print it to stdout.')
print_enc (' rss -- Generate RSS test output and print it to stdout.')
print_enc (' <file>.atom -- Generate ATOM test feed and write it to file.atom.')
print_enc (' <file>.rss -- Generate RSS test teed and write it to file.rss.')
print_enc (' podcast -- Generator Podcast test output and print it to stdout.')
print_enc ('')
exit()
arg = sys.argv[1]
fg = FeedGenerator()
fg.id('http://lernfunk.de/_MEDIAID_123')
fg.title('Testfeed')
fg.author( {'name':'Lars Kiesow','email':'[email protected]'} )
fg.link( href='http://example.com', rel='alternate' )
fg.category(term='test')
fg.contributor( name='Lars Kiesow', email='[email protected]' )
fg.contributor( name='John Doe', email='[email protected]' )
fg.icon('http://ex.com/icon.jpg')
fg.logo('http://ex.com/logo.jpg')
fg.rights('cc-by')
fg.subtitle('This is a cool feed!')
fg.link( href='http://larskiesow.de/test.atom', rel='self' )
fg.language('de')
fe = fg.add_entry()
fe.id('http://lernfunk.de/_MEDIAID_123#1')
fe.title('First Element')
fe.content('''Lorem ipsum dolor sit amet, consectetur adipiscing elit. Tamen
aberramus a proposito, et, ne longius, prorsus, inquam, Piso, si ista
mala sunt, placet. Aut etiam, ut vestitum, sic sententiam habeas aliam
domesticam, aliam forensem, ut in fronte ostentatio sit, intus veritas
示例2: print_enc
# 需要导入模块: from feedgen.feed import FeedGenerator [as 别名]
# 或者: from feedgen.feed.FeedGenerator import category [as 别名]
print_enc(" podcast -- Generate Podcast test output and print it to stdout.")
print_enc(" dc.atom -- Generate DC extension test output (atom format) and print it to stdout.")
print_enc(" dc.rss -- Generate DC extension test output (rss format) and print it to stdout.")
print_enc(" syndication.atom -- Generate DC extension test output (atom format) and print it to stdout.")
print_enc(" syndication.rss -- Generate DC extension test output (rss format) and print it to stdout.")
print_enc("")
exit()
arg = sys.argv[1]
fg = FeedGenerator()
fg.id("http://lernfunk.de/_MEDIAID_123")
fg.title("Testfeed")
fg.author({"name": "Lars Kiesow", "email": "[email protected]"})
fg.link(href="http://example.com", rel="alternate")
fg.category(term="test")
fg.contributor(name="Lars Kiesow", email="[email protected]")
fg.contributor(name="John Doe", email="[email protected]")
fg.icon("http://ex.com/icon.jpg")
fg.logo("http://ex.com/logo.jpg")
fg.rights("cc-by")
fg.subtitle("This is a cool feed!")
fg.link(href="http://larskiesow.de/test.atom", rel="self")
fg.language("de")
fe = fg.add_entry()
fe.id("http://lernfunk.de/_MEDIAID_123#1")
fe.title("First Element")
fe.content(
"""Lorem ipsum dolor sit amet, consectetur adipiscing elit. Tamen
aberramus a proposito, et, ne longius, prorsus, inquam, Piso, si ista
mala sunt, placet. Aut etiam, ut vestitum, sic sententiam habeas aliam
示例3: setUp
# 需要导入模块: from feedgen.feed import FeedGenerator [as 别名]
# 或者: from feedgen.feed.FeedGenerator import category [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
示例4: main
# 需要导入模块: from feedgen.feed import FeedGenerator [as 别名]
# 或者: from feedgen.feed.FeedGenerator import category [as 别名]
def main():
if len(sys.argv) != 2 or not (
sys.argv[1].endswith('rss') or
sys.argv[1].endswith('atom') or
sys.argv[1] == 'torrent' or
sys.argv[1] == 'podcast'):
print(USAGE)
exit()
arg = sys.argv[1]
fg = FeedGenerator()
fg.id('http://lernfunk.de/_MEDIAID_123')
fg.title('Testfeed')
fg.author({'name': 'Lars Kiesow', 'email': '[email protected]'})
fg.link(href='http://example.com', rel='alternate')
fg.category(term='test')
fg.contributor(name='Lars Kiesow', email='[email protected]')
fg.contributor(name='John Doe', email='[email protected]')
fg.icon('http://ex.com/icon.jpg')
fg.logo('http://ex.com/logo.jpg')
fg.rights('cc-by')
fg.subtitle('This is a cool feed!')
fg.link(href='http://larskiesow.de/test.atom', rel='self')
fg.language('de')
fe = fg.add_entry()
fe.id('http://lernfunk.de/_MEDIAID_123#1')
fe.title('First Element')
fe.content('''Lorem ipsum dolor sit amet, consectetur adipiscing elit. Tamen
aberramus a proposito, et, ne longius, prorsus, inquam, Piso, si
ista mala sunt, placet. Aut etiam, ut vestitum, sic sententiam
habeas aliam domesticam, aliam forensem, ut in fronte ostentatio
sit, intus veritas occultetur? Cum id fugiunt, re eadem defendunt,
quae Peripatetici, verba.''')
fe.summary(u'Lorem ipsum dolor sit amet, consectetur adipiscing elit…')
fe.link(href='http://example.com', rel='alternate')
fe.author(name='Lars Kiesow', email='[email protected]')
if arg == 'atom':
print_enc(fg.atom_str(pretty=True))
elif arg == 'rss':
print_enc(fg.rss_str(pretty=True))
elif arg == 'podcast':
# Load the podcast extension. It will automatically be loaded for all
# entries in the feed, too. Thus also for our “fe”.
fg.load_extension('podcast')
fg.podcast.itunes_author('Lars Kiesow')
fg.podcast.itunes_category('Technology', 'Podcasting')
fg.podcast.itunes_explicit('no')
fg.podcast.itunes_complete('no')
fg.podcast.itunes_new_feed_url('http://example.com/new-feed.rss')
fg.podcast.itunes_owner('John Doe', '[email protected]')
fg.podcast.itunes_summary('Lorem ipsum dolor sit amet, consectetur ' +
'adipiscing elit. Verba tu fingas et ea ' +
'dicas, quae non sentias?')
fe.podcast.itunes_author('Lars Kiesow')
print_enc(fg.rss_str(pretty=True))
elif arg == 'torrent':
fg.load_extension('torrent')
fe.link(href='http://example.com/torrent/debian-8-netint.iso.torrent',
rel='alternate',
type='application/x-bittorrent, length=1000')
fe.torrent.filename('debian-8.4.0-i386-netint.iso.torrent')
fe.torrent.infohash('7661229811ef32014879ceedcdf4a48f256c88ba')
fe.torrent.contentlength('331350016')
fe.torrent.seeds('789')
fe.torrent.peers('456')
fe.torrent.verified('123')
print_enc(fg.rss_str(pretty=True))
elif arg.startswith('dc.'):
fg.load_extension('dc')
fg.dc.dc_contributor('Lars Kiesow')
if arg.endswith('.atom'):
print_enc(fg.atom_str(pretty=True))
else:
print_enc(fg.rss_str(pretty=True))
elif arg.startswith('syndication'):
fg.load_extension('syndication')
fg.syndication.update_period('daily')
fg.syndication.update_frequency(2)
fg.syndication.update_base('2000-01-01T12:00+00:00')
if arg.endswith('.rss'):
print_enc(fg.rss_str(pretty=True))
else:
print_enc(fg.atom_str(pretty=True))
elif arg.endswith('atom'):
fg.atom_file(arg)
elif arg.endswith('rss'):
fg.rss_file(arg)
示例5: _build_feed
# 需要导入模块: from feedgen.feed import FeedGenerator [as 别名]
# 或者: from feedgen.feed.FeedGenerator import category [as 别名]
def _build_feed(id, lang, url, return_type=None):
fg = None
fg = FeedGenerator()
fg.id(url)
fg.link( href=url, rel='self' )
req = urllib2.Request('%s://%s:%i%sview/series/%s?with_name=true' % (
app.config['LERNFUNK_CORE_PROTOCOL'],
app.config['LERNFUNK_CORE_HOST'],
app.config['LERNFUNK_CORE_PORT'],
app.config['LERNFUNK_CORE_PATH'],
id))
req.add_header('Accept', 'application/json')
u = urllib2.urlopen(req)
try:
series = json.loads(u.read())
finally:
u.close()
s = series['result']['lf:series'][0]
fg.title(s['dc:title'])
fg.language(s['dc:language'])
for cat in s['dc:subject']:
fg.category( term=cat.lower(), label=cat )
fg.description(s['dc:description'] or s['dc:title'])
for name in s.get('lf:creator') or ['']:
fg.author( name=name )
# Get media
req = urllib2.Request('%s://%s:%i%sview/series/%s/media/%s%s' % (
app.config['LERNFUNK_CORE_PROTOCOL'],
app.config['LERNFUNK_CORE_HOST'],
app.config['LERNFUNK_CORE_PORT'],
app.config['LERNFUNK_CORE_PATH'],
id,
lang or '',
'?with_file=1&with_name=1'))
req.add_header('Accept', 'application/json')
u = urllib2.urlopen(req)
try:
media = json.loads(u.read())
finally:
u.close()
# Add media to feed
for media in media['result']['lf:media']:
fe = fg.add_entry()
fe.id('%s/%s/%s' % (url, media['dc:identifier'], media['lf:version']))
fe.title(media['dc:title'])
for name in media.get('lf:creator') or ['']:
fe.author( name=name )
fg.contributor( name=name )
for name in media.get('lf:contributor') or []:
fe.contributor( name=name )
fg.contributor( name=name )
fe.content(media['dc:description'])
is_av = lambda x: x.startswith('video') or x.startswith('audio')
for file in media['lf:file']:
fe.link(
href=file['lf:uri'],
rel=( 'enclosure' if is_av(file['dc:format']) else 'alternate' ),
type=file['dc:format'] )
fe.published(media['dc:date'] + ' +0')
rssfeed = fg.rss_str(pretty=False)
atomfeed = fg.atom_str(pretty=False)
# Podcast specific values
fg.load_extension('podcast')
podcast = fg.rss_str(pretty=False)
r_server = get_redis()
r_server.set('%slast_update_%s_%s' % (REDIS_NS, id, lang), int(time.time()))
r_server.set('%srss_%s_%s' % (REDIS_NS, id, lang), rssfeed)
r_server.set('%satom_%s_%s' % (REDIS_NS, id, lang), atomfeed)
r_server.set('%spodcast_%s_%s' % (REDIS_NS, id, lang), podcast)
if return_type == 'rss':
return rssfeed
if return_type == 'atom':
return atomfeed
if return_type == 'podcast':
return podcast