本文整理汇总了Python中feedgen.feed.FeedGenerator.language方法的典型用法代码示例。如果您正苦于以下问题:Python FeedGenerator.language方法的具体用法?Python FeedGenerator.language怎么用?Python FeedGenerator.language使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类feedgen.feed.FeedGenerator
的用法示例。
在下文中一共展示了FeedGenerator.language方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: feed
# 需要导入模块: from feedgen.feed import FeedGenerator [as 别名]
# 或者: from feedgen.feed.FeedGenerator import language [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
示例2: generate_feed
# 需要导入模块: from feedgen.feed import FeedGenerator [as 别名]
# 或者: from feedgen.feed.FeedGenerator import language [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)
示例3: GET
# 需要导入模块: from feedgen.feed import FeedGenerator [as 别名]
# 或者: from feedgen.feed.FeedGenerator import language [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)
示例4: feed
# 需要导入模块: from feedgen.feed import FeedGenerator [as 别名]
# 或者: from feedgen.feed.FeedGenerator import language [as 别名]
def feed(column_id):
api = Api(column_id)
with request.urlopen(api.info) as stream:
result = stream.read().decode('utf-8')
if not result:
return '', 404
info = json.loads(result)
with request.urlopen(api.posts) as stream:
result = stream.read().decode('utf-8')
entries = json.loads(result)
fg = FeedGenerator()
fg.id(str(entries[0]['slug']))
fg.title(info['name'])
fg.language('zh_CN')
fg.icon(info['avatar']['template'].replace('{id}', info['avatar']['id']).replace('{size}', 's'))
fg.logo(info['avatar']['template'].replace('{id}', info['avatar']['id']).replace('{size}', 'l'))
fg.description(info['intro'])
fg.author(dict(name=info['creator']['name']))
fg.link(href=api.base_url + info['url'], rel='alternate')
for entry in entries:
fe = fg.add_entry()
fe.id(entry['url'])
fe.title(entry['title'])
fe.published(entry['publishedTime'])
fe.updated(entry['publishedTime'])
fe.author(dict(name=entry['author']['name']))
fe.link(href=api.base_url + entry['url'], rel='alternate')
fe.content(entry['content'])
return fg.atom_str(pretty=True)
示例5: build_feed
# 需要导入模块: from feedgen.feed import FeedGenerator [as 别名]
# 或者: from feedgen.feed.FeedGenerator import language [as 别名]
def build_feed(self):
"Build the feed given our existing URL"
# Get all the episodes
page_content = str(requests.get(self.url).content)
parser = BassdriveParser()
parser.feed(page_content)
links = parser.get_links()
# And turn them into something usable
fg = FeedGenerator()
fg.id(self.url)
fg.title(self.title)
fg.description(self.title)
fg.author({'name': self.dj})
fg.language('en')
fg.link({'href': self.url, 'rel': 'alternate'})
fg.logo(self.logo)
for link in links:
fe = fg.add_entry()
fe.author({'name': self.dj})
fe.title(link[0])
fe.description(link[0])
fe.enclosure(self.url + link[1], 0, 'audio/mpeg')
# Bassdrive always uses date strings of
# [yyyy.mm.dd] with 0 padding on days and months,
# so that makes our lives easy
date_start = link[0].find('[')
date_str = link[0][date_start:date_start+12]
published = datetime.strptime(date_str, '[%Y.%m.%d]')
fe.pubdate(UTC.localize(published))
fe.guid((link[0]))
return fg
示例6: gen_feed
# 需要导入模块: from feedgen.feed import FeedGenerator [as 别名]
# 或者: from feedgen.feed.FeedGenerator import language [as 别名]
def gen_feed(user, base_url, path, debug=False):
# Create feed
feed = FeedGenerator()
feed.id(urlparse.urljoin(base_url, user + '.xml'))
feed.title('Snapchat story for ' + user)
feed.link( href=urlparse.urljoin(base_url, user + '.xml'), rel='self' )
feed.language('en')
feed.description('Snapchat media')
# Iterate through files in path, sort by unix timestamp (newest first), then add to feed
files = sorted(os.listdir(path), reverse=True)
for filename in files:
split = filename.split('~')
if split[0] != user:
continue
if os.path.splitext(filename)[1] in ['.mp4', '.jpg']:
entry = feed.add_entry()
entry.id(urlparse.urljoin(base_url, filename))
entry.link(href=urlparse.urljoin(base_url, filename))
entry.title(filename)
# Write feed to disk
feed.rss_file(os.path.join(path, user + '.xml'))
date = datetime.datetime.now().strftime("%Y-%m-%d %H:%M")
if debug:
print('{0} Regenerated {1}'.format(date, urlparse.urljoin(base_url,
user + '.xml')))
示例7: generate
# 需要导入模块: from feedgen.feed import FeedGenerator [as 别名]
# 或者: from feedgen.feed.FeedGenerator import language [as 别名]
def generate(app, category, torrents):
"""
generate an rss feed from category with torrents as results
if category is None this feed is for all categories
"""
feed = FeedGenerator()
if category:
url = util.fullSiteURL(app, 'feed', '{}.rss'.format(category))
else:
url = util.fullSiteURL(app, 'feed', 'all.rss')
feed.link(href=url, rel="self")
feed.id(url)
if category:
title = "new {} torrents on index ex invisibilis".format(category)
else:
title = "new torrents on index ex invisibilis"
feed.title(title)
feed.description(title)
feed.author({"name": "anonymous"})
feed.language("en")
for torrent in torrents:
item = feed.add_entry()
url = util.fullSiteURL(app, torrent.downloadURL())
item.id(torrent.infohash)
item.link(href=url)
item.title(torrent.title)
item.description(torrent.summary(100))
return feed
示例8: get_feed
# 需要导入模块: from feedgen.feed import FeedGenerator [as 别名]
# 或者: from feedgen.feed.FeedGenerator import language [as 别名]
def get_feed(atom=False):
fg = FeedGenerator()
domain = get_domain()
items = get_posts({"limit": "10"}, full=True)["results"]
fg.id("http://%s/"%domain)
fg.title("Blog do MatrUFSC2")
fg.description("Feed do blog do MatrUFSC2, onde noticias e novos recursos sao anunciados primeiro!")
fg.language('pt-BR')
fg.link({"href":"/blog/feed","rel":"self"})
fg.updated(items[0]["posted_at"].replace(tzinfo=pytz.UTC))
for item in items:
entry = fg.add_entry()
entry.title(item["title"])
tree = html.fromstring(item["summary"])
cleaner = Cleaner(allow_tags=[])
tree = cleaner.clean_html(tree)
text = tree.text_content()
entry.description(text, True)
entry.link({"href":item["link"],"rel":"self"})
entry.content(item["body"])
entry.published(item["posted_at"].replace(tzinfo=pytz.UTC))
entry.updated(item["posted_at"].replace(tzinfo=pytz.UTC))
entry.category({"label": item["category"]["title"], "term": item["category"]["slug"]})
entry.id(item["id"])
if atom:
return fg.atom_str(pretty=True)
else:
return fg.rss_str(pretty=True)
示例9: build
# 需要导入模块: from feedgen.feed import FeedGenerator [as 别名]
# 或者: from feedgen.feed.FeedGenerator import language [as 别名]
def build():
global fg
fg = FeedGenerator()
fg.title(parser.get('technowatch', 'name'))
fg.language('en')
fg.description(parser.get('technowatch', 'name'))
fg.link(href=parser.get('technowatch', 'link'), rel='alternate')
# Cleaning stories if too much
if len(known_stories) > int(parser.get('technowatch', 'cache_max')):
clean()
# Sorting stories by crawled date
for item in sorted(known_stories.values(), key=operator.itemgetter('crawledDate'), reverse=True):
fe = fg.add_entry()
fe.link(href=item['url'], rel='alternate')
fe.title("[" + item['type'] + "] " + item['title'])
fe.category({
'label': item['type'],
'term': item['type']
})
fe.author({'name': item['by']})
fe.description(item['desc'])
fe.pubdate(item['crawledDate'])
# Caching RSS building
pickle.dump(known_stories, open(cust_path + "/technowatch.data", "wb"))
if parser.get('wsgi', 'activated') == "True":
fg.rss_file(cust_path + '/static/rss.xml')
if parser.get('ftp', 'activated') == "True":
upload()
示例10: makeRss
# 需要导入模块: from feedgen.feed import FeedGenerator [as 别名]
# 或者: from feedgen.feed.FeedGenerator import language [as 别名]
def makeRss(self):
fg = FeedGenerator()
fg.load_extension('podcast')
fg.id('http://hypecast.blackmad.com/' + self.mode)
fg.title('Hype Machine Robot Radio: ' + self.mode)
fg.author( {'name':'David Blackmad','email':'[email protected]'} )
fg.logo('http://dump.blackmad.com/the-hype-machine.jpg')
fg.language('en')
fg.link(href='http://hypecast.blackmad.com/' + self.mode)
fg.description('Hype Machine Robot Radio: ' + self.mode)
description = ' <br/>'.join(['%s. %s' % (index + 1, self.mk_song_id(s)) for index, s in enumerate(self.songs)])
fe = fg.add_entry()
fe.title(self.track_name)
fe.description(description)
fe.id(self.filename)
# add length
print(self.relative_dir)
print(self.filename)
fe.enclosure(url = 'http://hypecast.blackmad.com/%s' % (self.filename), type="audio/mpeg")
rss_str = fg.rss_str()
newItem = ET.fromstring(rss_str)[0].find('item')
out = open(self.get_filename('xml'), 'w')
out.write(ET.tostring(newItem))
out.close()
self.updateRss()
示例11: render_atom
# 需要导入模块: from feedgen.feed import FeedGenerator [as 别名]
# 或者: from feedgen.feed.FeedGenerator import language [as 别名]
def render_atom(self):
fg = FeedGenerator()
fg.id(self.site_url)
fg.title(self.site_title)
fg.link(href = self.site_url,rel = 'alternate')
fg.link(href = self.site_url + 'atom.xml',rel = 'self')
fg.language('zh-cn')
link_list = ArticleManager.sharedManager().link_list()
for link in link_list:
article = ArticleManager.sharedManager().article_for_link(link)
if not article:
continue
fe = fg.add_entry()
fe.id(article.article_link)
fe.link(link = {'href':self.site_url + article.article_link})
fe.title(article.article_title)
fe.description(article.article_subtitle or '')
fe.author(name = article.author or '',
email = article.author_email or '')
d = datetime.strptime(article.article_publish_date,'%Y-%m-%d')
pubdate = datetime(year = d.year, month = d.month, day = d.day,tzinfo = UTC(8))
fe.pubdate(pubdate)
article.render_content_html()
fe.content(content = article._content_html,
type = 'html')
atom_feed = fg.atom_str(pretty = True)
return atom_feed
示例12: latestRss
# 需要导入模块: from feedgen.feed import FeedGenerator [as 别名]
# 或者: from feedgen.feed.FeedGenerator import language [as 别名]
def latestRss(userID):
userID = userID.lower()
shows = {}
episodes = []
today = date.today().strftime('%Y-%m-%d')
for showID in series.getUserShowList(userID):
shows[showID] = series.getShowInfo(userID, showID, withEpisodes=True, onlyUnseen=True)
episodes.extend((showID, episode) for episode in shows[showID]['episodes'] if episode['airdate'] and airdateKey(episode['airdate']) < today)
episodes.sort(key=episodeAirdateKey, reverse=True)
feed = FeedGenerator()
feed.id(userID)
feed.title('%s\'s shows' % userID)
feed.description('Unseen episodes')
feed.link(href=request.url_root)
feed.language('en')
for showID, episode in episodes:
entry = feed.add_entry()
entry.id('%s/%s' % (showID, episode['episode_id']))
entry.title('%s S%02dE%02d: %s' % (shows[showID]['name'], episode['season'], episode['episode'], episode['title']))
return feed.rss_str(pretty=True)
示例13: generateFeeds
# 需要导入模块: from feedgen.feed import FeedGenerator [as 别名]
# 或者: from feedgen.feed.FeedGenerator import language [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]'})
示例14: main
# 需要导入模块: from feedgen.feed import FeedGenerator [as 别名]
# 或者: from feedgen.feed.FeedGenerator import language [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()
示例15: create_mock_fg
# 需要导入模块: from feedgen.feed import FeedGenerator [as 别名]
# 或者: from feedgen.feed.FeedGenerator import language [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