本文整理汇总了Python中feedgen.feed.FeedGenerator.subtitle方法的典型用法代码示例。如果您正苦于以下问题:Python FeedGenerator.subtitle方法的具体用法?Python FeedGenerator.subtitle怎么用?Python FeedGenerator.subtitle使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类feedgen.feed.FeedGenerator
的用法示例。
在下文中一共展示了FeedGenerator.subtitle方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: generate_feed
# 需要导入模块: from feedgen.feed import FeedGenerator [as 别名]
# 或者: from feedgen.feed.FeedGenerator import subtitle [as 别名]
def generate_feed(output_file, exclude_highlights=True):
# Parse RSS feed
d = feedparser.parse(ESPN_RSS_FEED)
IMAGE_URL = d.feed.image["href"]
# RSS feed generation
fg = FeedGenerator()
fg.load_extension("podcast", rss=True)
## RSS tags
# Required
fg.title(d.feed.title)
fg.link(href="https://github.com/aaearon/lebatard-show-rss")
fg.description(d.feed.description)
# Optional
fg.language(d.feed.language)
fg.image(IMAGE_URL)
fg.subtitle(d.feed.subtitle)
# iTunes
fg.podcast.itunes_author(d.feed.author)
fg.podcast.itunes_category(itunes_category=d.feed.category)
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"])
tz = pytz.timezone("America/Los_Angeles")
for e in d.entries:
if exclude_highlights and episode_duration_string_to_int(e["itunes_duration"]) > 3600:
pass
else:
fe = fg.add_entry()
fe.id(e.id)
fe.title(e.title)
fe.description(e.description)
fe.enclosure(url=e.enclosures[0]["href"], length=e.enclosures[0]["length"], type=e.enclosures[0]["type"])
fe.podcast.itunes_summary(e.description)
fe.podcast.itunes_subtitle(e.description)
fe.podcast.itunes_duration(e["itunes_duration"])
dt = datetime.fromtimestamp(time.mktime(e.published_parsed))
date = tz.localize(dt)
# Local hour
if "Show: " in e.title:
fe.published(date)
elif "Hour 1" in e.title:
fe.published(date + timedelta(hours=1))
elif "Hour 2" in e.title:
fe.published(date + timedelta(hours=2))
elif "Hour 3" in e.title:
fe.published(date + timedelta(hours=3))
else:
fe.published(date + timedelta(hours=-1))
fg.rss_str(pretty=True)
fg.rss_file(output_file)
示例2: feed
# 需要导入模块: from feedgen.feed import FeedGenerator [as 别名]
# 或者: from feedgen.feed.FeedGenerator import subtitle [as 别名]
def feed():
"""
Generate atom feed
"""
entries = parse_posts(0, C.feed_count)
fg = FeedGenerator()
fg.id(str(len(entries)))
fg.title(C.title)
fg.subtitle(C.subtitle)
fg.language(C.language)
fg.author(dict(name=C.author, email=C.email))
fg.link(href=C.root_url, rel='alternate')
fg.link(href=make_abs_url(C.root_url, 'feed'), rel='self')
for entry in entries:
fe = fg.add_entry()
fe.id(entry.get('url'))
fe.title(entry.get('title'))
fe.published(entry.get('date'))
fe.updated(entry.get('updated') or entry.get('date'))
fe.link(href=make_abs_url(C.root_url, entry.get('url')), rel='alternate')
fe.author(dict(name=entry.get('author'), email=entry.get('email')))
fe.content(entry.get('body'))
atom_feed = fg.atom_str(pretty=True)
return atom_feed
示例3: generateFeeds
# 需要导入模块: from feedgen.feed import FeedGenerator [as 别名]
# 或者: from feedgen.feed.FeedGenerator import subtitle [as 别名]
def generateFeeds(buffered, meta):
utc = pytz.utc
fg = FeedGenerator()
fg.id(meta['id'])
fg.title(meta['title'])
fg.author(meta['author'])
fg.subtitle(meta['subtitle'])
fg.link( href=meta['link'], rel='self' )
fg.language(meta['language'])
for tweet in buffered:
fe = fg.add_entry()
fe.id(tweet['url'].decode('utf-8'))
fe.published(utc.localize(tweet['created_at']).astimezone(pytz.timezone(locale)))
#fe.guid(tweet['url'].decode('utf-8'))
fe.link(href=tweet['url'].decode('utf-8'), rel='alternate')
fe.title(tweet['readable_title'])
fe.description(tweet['readable_article'])
try:
fe.author({'name': '', 'email':tweet['user_name'].decode('utf-8') + ": " + tweet['text'].decode('utf-8')})
except Exception, e:
logger.error(e)
fe.author({'name': 'a', 'email':'[email protected]'})
示例4: main
# 需要导入模块: from feedgen.feed import FeedGenerator [as 别名]
# 或者: from feedgen.feed.FeedGenerator import subtitle [as 别名]
def main():
client = moduleSocial.connectTumblr()
posts = client.posts('fernand0')
fg = FeedGenerator()
fg.id(posts['blog']['url'])
fg.title(posts['blog']['title'])
fg.author( {'name':posts['blog']['name'],'email':'[email protected]'} )
fg.link( href=posts['blog']['url'], rel='alternate' )
fg.subtitle('Alternate feed due to Tumblr GDPR restrictions')
fg.language('en')
print(len(posts['posts']))
for i in range(len(posts['posts'])):
fe = fg.add_entry()
print(posts['posts'][i]['post_url'])
if 'title' in posts['posts'][i]:
title = posts['posts'][i]['title']
print('T', posts['posts'][i]['title'])
else:
title = posts['posts'][i]['summary'].split('\n')[0]
print('S', posts['posts'][i]['summary'].split('\n')[0])
fe.title(title)
fe.link(href=posts['posts'][i]['post_url'])
fe.id(posts['posts'][i]['post_url'])
print(fg.atom_file('/var/www/html/elmundoesimperfecto/tumblr.xml'))
sys.exit()
示例5: GET
# 需要导入模块: from feedgen.feed import FeedGenerator [as 别名]
# 或者: from feedgen.feed.FeedGenerator import subtitle [as 别名]
def GET(self):
cherrypy.response.headers["Access-Control-Allow-Origin"] = "*"
fg = FeedGenerator()
#TODO create icon
# fg.icon('http://www.det.ua.pt')
fg.id(config.get('rss','id'))
fg.title(config.get('rss','title'))
fg.subtitle(config.get('rss','subtitle'))
fg.description(config.get('rss','description'))
fg.author({'name': config.get('rss','author_name'), 'email':config.get('rss','author_email')})
fg.language(config.get('rss','language'))
fg.link(href=config.get('rss','href'), rel='related')
client = EmailClient()
for msgn in reversed(client.listBox(config.get('imap','mailbox'))[:config.getint('rss','maxitems')]):
cherrypy.log("RSS Entry: "+msgn)
em = client.getEMail(msgn)
entry = fg.add_entry()
entry.title(em['subject'])
entry.author({'name': em['From']['name'], 'email': em['From']['email']})
entry.guid(config.get("main","baseurl")+'news/'+msgn)
entry.link({'href':config.get("main","baseurl")+'news/'+msgn, 'rel':'alternate'})
entry.pubdate(em['date'])
entry.content(em['body'])
return fg.rss_str(pretty=True)
示例6: create_mock_fg
# 需要导入模块: from feedgen.feed import FeedGenerator [as 别名]
# 或者: from feedgen.feed.FeedGenerator import subtitle [as 别名]
def create_mock_fg():
fg = FeedGenerator()
fg.id(FEED_ID)
fg.title('Some Test Feed')
fg.author({'name': 'Edfward', 'email': '[email protected]'})
fg.subtitle('Test feed subtitle!')
fg.link(href=FEED_ID, rel='self')
fg.language('en')
return fg
示例7: rss
# 需要导入模块: from feedgen.feed import FeedGenerator [as 别名]
# 或者: from feedgen.feed.FeedGenerator import subtitle [as 别名]
def rss(conversation,
url,
author_name,
author_email,
title,
subtitle,
language,
output_path):
"""Export all the links of the conversation in a simple RSS feed"""
from feedgen.feed import FeedGenerator
fg = FeedGenerator()
fg.id(url)
fg.title(title)
fg.author(
{
'name': author_name,
'email': author_email,
}
)
fg.link(
href=url,
rel='alternate'
)
if subtitle:
fg.subtitle(subtitle)
fg.language(language)
for message in conversation.history():
match = re.search(
"^.*<(?P<url>[^>|]+)\|?(?P<title>[^>]+)?>.*$",
message.data["text"],
flags=re.MULTILINE
)
if match is not None:
fe = fg.add_entry()
link = match.group("url")
title = match.group("title") or link
date = naive_to_local(datetime.datetime.fromtimestamp(float(message.data["ts"])))
description = message.data["text"]
if "attachments" in message.data:
attachment = [a for a in message.data["attachments"] if
a["title_link"] == link][0]
title += " | " + attachment["title"]
description += """
""" + attachment["text"]
fe.id(link)
fe.title(title)
fe.link(href=link)
fe.published(date)
user = config.slack.get_user(message.data["user"])
author = {
"name": message.data["username"],
"email": user.email or "noemail",
}
fe.author(author)
fe.description(description)
fg.rss_file(output_path, pretty=True)
示例8: build_feed_generator
# 需要导入模块: from feedgen.feed import FeedGenerator [as 别名]
# 或者: from feedgen.feed.FeedGenerator import subtitle [as 别名]
def build_feed_generator(query=None):
gen = FeedGenerator()
gen.title(FEED_TITLE)
gen.subtitle(FEED_SUBTITLE)
gen.language(FEED_LANG)
feed_link = url_for('views.feed', query=query, _external=True)
gen.link(href=feed_link, rel='self', type='application/rss+xml')
return gen
示例9: main
# 需要导入模块: from feedgen.feed import FeedGenerator [as 别名]
# 或者: from feedgen.feed.FeedGenerator import subtitle [as 别名]
def main(argv):
ap = argparse.ArgumentParser(
description='''
Render RSS and Atom feeds from a CSV of food inspection data.
''')
ap.add_argument(
'-v', '--verbose', action='count', dest='verbosity', default=0,
help='increase global logging verbosity; can be used multiple times')
ap.add_argument(
'-f', '--format', choices=['rss', 'atom'], default='atom',
help='''
specify the format to use when rendering the feed (default: %(default)s)')
''')
ap.add_argument(
'-n', '--num_incidents', metavar='<num>', type=int, default=10,
help='render <num> recent incidents in the feed (default: %(default)s)')
ap.add_argument(
'flavor', nargs='?', default='all', choices=['all', 'failures'],
help='select the flavor of feed to render (default: %(default)s)')
args = ap.parse_args()
logging.basicConfig(
level=logging.ERROR - args.verbosity * 10,
style='{',
format='{}: {{message}}'.format(ap.prog))
fg = FeedGenerator()
fg.id('http://pgriess.github.io/dallas-foodscores/')
fg.link(href=fg.id(), rel='self')
fg.title('Dallas Food Inspection Scores')
fg.subtitle('''
Food inspection scores from the official City of Dallas dataset; updated daily
''')
fg.description(fg.subtitle())
fg.language('en')
fg.author(
name='Peter Griess',
email='[email protected]',
uri='https://twitter.com/pgriess')
for i in get_inspections_to_feed(sys.stdin, args.num_incidents,
args.flavor):
fe = fg.add_entry()
fe.title('{name} at {address} scored {score}'.format(
name=i.name, address=i.address, score=i.score))
fe.id(fg.id() + '#!/' + str(abs(hash(i))))
fe.link(href=fe.id(), rel='alternate')
fe.content(fe.title())
fe.published(TZ.localize(i.date))
if args.format == 'atom':
print(fg.atom_str(pretty=True))
else:
print(fg.rss_str(pretty=True))
示例10: rss
# 需要导入模块: from feedgen.feed import FeedGenerator [as 别名]
# 或者: from feedgen.feed.FeedGenerator import subtitle [as 别名]
def rss(request):
# track it!
# v=1 // Version.
# &tid=UA-XXXXX-Y // Tracking ID / Property ID.
# &cid=555 // Anonymous Client ID.
# &t=pageview // Pageview hit type.
# &dh=mydemo.com // Document hostname.
# &dp=/home // Page.
# &dt=homepage // Title.
angrates_uuid = uuid.UUID('f93c5388-f60b-5159-bbfc-d08d6f7b401f')
x_forwarded_for = request.META.get('HTTP_X_FORWARDED_FOR')
if x_forwarded_for:
ip = x_forwarded_for.split(',')[0]
else:
ip = request.META.get('REMOTE_ADDR')
cid = uuid.uuid5(angrates_uuid, ip)
data = {
'v': 1,
'tid': 'UA-19269567-1',
'cid': cid,
't': 'pageview',
'dh': 'armstrongandgettybingo.com',
'dp': '/rss/',
'dt': 'Podcast',
}
requests.post('https://www.google-analytics.com/collect', data=data)
fg = FeedGenerator()
fg.load_extension('podcast')
fg.id('http://www.armstrongandgettybingo.com/rss')
fg.podcast.itunes_category('News & Politics', 'Conservative (Right)')
fg.podcast.itunes_explicit('no')
fg.title('The Armstrong and Getty Show (Bingo)')
fg.author( {'name':'Ben Friedland','email':'[email protected]'} )
fg.link( href='http://www.armstrongandgettybingo.com', rel='alternate' )
fg.logo('https://s3-us-west-1.amazonaws.com/bencast/bingologo.png')
fg.subtitle('Armstrong and Getty Bingo')
fg.description('The Armstrong and Getty Show - Unofficial Feed including Archives back to 2001.')
fg.link( href='http://www.armstrongandgettybingo.com/rss', rel='self' )
fg.language('en')
pacific = pytz.timezone('America/Los_Angeles')
for hour in Hour.objects.all().order_by('-pub_date'):
fe = fg.add_entry()
fe.id(hour.link)
fe.title(hour.title)
fe.description(hour.description)
fe.enclosure(hour.link, 0, 'audio/mpeg')
fe.published(pacific.localize(hour.pub_date))
return HttpResponse(fg.rss_str(pretty=True), content_type='application/rss+xml')
示例11: create_fg
# 需要导入模块: from feedgen.feed import FeedGenerator [as 别名]
# 或者: from feedgen.feed.FeedGenerator import subtitle [as 别名]
def create_fg():
# Create the feed
fg = FeedGenerator()
fg.id("http://www.accre.vanderbilt.edu")
fg.title("ACCRE's Status Feed")
fg.author(dict(name="Josh Arnold", email="[email protected]"))
fg.link(href="http://www.accre.vanderbilt.edu", rel="alternate")
fg.logo("http://www.accre.vanderbilt.edu/"
"wp-content/themes/ashford/favicon.ico")
fg.subtitle("ACCRE's Status Feed")
fg.language('en')
return fg
示例12: blog_feed
# 需要导入模块: from feedgen.feed import FeedGenerator [as 别名]
# 或者: from feedgen.feed.FeedGenerator import subtitle [as 别名]
def blog_feed(self, values):
domain = request.httprequest.host_url.rstrip('/')
blog = values['blog']
fg = FeedGenerator()
fg.id(domain + values['pager']['page']['url'])
fg.title(blog.name)
fg.subtitle(blog.subtitle)
for post in values['blog_posts']:
fe = fg.add_entry()
fe.id(domain + '/blog/{}/post/{}'.format(slug(blog), slug(post)))
fe.title(post.name)
fe.content(post.content)
return fg
示例13: render_feed
# 需要导入模块: from feedgen.feed import FeedGenerator [as 别名]
# 或者: from feedgen.feed.FeedGenerator import subtitle [as 别名]
def render_feed(text_paths, outpath):
# http://rhodesmill.org/brandon/feed
# http://rhodesmill.org/brandon/category/python/feed
# http://rhodesmill.org/brandon/feed/atom/
t0 = datetime.min.time()
def fix(d):
dt = datetime.combine(d, t0)
return timezone('US/Eastern').localize(dt)
posts = [post_info(path) for path in text_paths if date_of(path)]
posts = sorted(posts, key=lambda post: post['date'])
posts = posts[-1:]
most_recent_date = max(post['date'] for post in posts)
def full(url):
return 'http://rhodesmill.org/' + url.lstrip('/')
fg = FeedGenerator()
fg.id(full('/'))
fg.author({'name': 'Brandon Rhodes'})
fg.language('en')
fg.link(href=full('/brandon/'), rel='alternate')
if 'python' in outpath:
fg.link(href=full('/brandon/category/python/feed/'), rel='self')
else:
fg.link(href=full('/brandon/feed/'), rel='self')
fg.subtitle('Thoughts and ideas from Brandon Rhodes')
fg.title("Let's Discuss the Matter Further")
fg.updated(fix(most_recent_date))
for post in posts:
url = full(post['url_path'])
excerpt = truncate_at_more(post['body_html'], url)
fe = fg.add_entry()
fe.content(excerpt, type='html')
fe.guid(url, permalink=True)
fe.id(url)
fe.link({'href': url})
fe.published(fix(post['date']))
fe.title(post['title'])
fe.updated(fix(post['date']))
rss = fg.rss_str(pretty=True)
fg.link(href=full('/brandon/feed/atom/'), rel='self', replace=True)
atom = fg.atom_str(pretty=True)
return rss, atom
示例14: get
# 需要导入模块: from feedgen.feed import FeedGenerator [as 别名]
# 或者: from feedgen.feed.FeedGenerator import subtitle [as 别名]
def get(self):
fg = FeedGenerator()
fg.id("http://test.ts")
fg.title("My Test Feed")
fg.icon("https://avatars1.githubusercontent.com/u/715660?v=3&s=32")
fg.author({'name': "The Author", 'email': "[email protected]"})
fg.link(href="http://example.org/index.atom?page=2", rel="next")
fg.link(href="http://test.ts", rel="alternate")
fg.logo("https://avatars1.githubusercontent.com/u/715660?v=3&s=32")
fg.description("Este é o monstro do lago 1")
fg.subtitle("This is an example feed!")
fg.language("en-us")
# Handle this:
#< sy:updatePeriod > hourly < / sy:updatePeriod >
#< sy:updateFrequency > 1 < / sy:updateFrequency >
fg.lastBuildDate(datetime.now(pytz.timezone("America/Sao_Paulo")))
fi = fg.add_item()
fi.id("http://test.ts/id/1", )
#fi.link(link="http://test.ts/id/1")
fi.title("Monstro do Lago 1")
fi.description("Este é o monstro do lago 1")
fi.comments("http://test.ts/id/1/comments")
fi.pubdate(datetime.now(pytz.timezone("America/Sao_Paulo")))
fi = fg.add_item()
fi.id("http://test.ts/id/2")
fi.title("Monstro do Lago 2")
fi.description("Este é o monstro do lago 2")
fi.pubdate(datetime.now(pytz.timezone("America/Sao_Paulo")))
#test = fg.atom_str(pretty=True)
rss_str = fg.rss_str(pretty=True)
self.set_header("Content-Type", 'application/xml; charset="utf-8"')
#self.set_header("Content-Disposition",
# "attachment; filename='test.xml'")
self.write(rss_str)
#if regexp.search(word) is not None:
# print
# 'matched'
if self.is_browser_mobile():
print("buu")
else:
print(self.request.headers["User-Agent"])
示例15: setup_feed
# 需要导入模块: from feedgen.feed import FeedGenerator [as 别名]
# 或者: from feedgen.feed.FeedGenerator import subtitle [as 别名]
def setup_feed():
fg = FeedGenerator()
fg.load_extension("podcast")
fg.language("en")
fg.id("https://jdelman.me/potato")
fg.author(name="Potato", email="[email protected]")
fg.link(href="https://jdelman.me/potato", rel="alternate")
fg.logo("https://jdelman.me/static/potato.jpg")
fg.title("Potato - Josh's Saved Videos")
fg.subtitle("Automatically generated RSS.")
return fg