def notices_feed(feed_type): if feed_type not in ["atom", "rss"]: flask.abort(404) url_root = flask.request.url_root base_url = flask.request.base_url feed = FeedGenerator() feed.generator("Feedgen") feed.id(url_root) feed.copyright( f"{datetime.now().year} Canonical Ltd. " "Ubuntu and Canonical are registered trademarks of Canonical Ltd." ) feed.title("Ubuntu security notices") feed.description("Recent content on Ubuntu security notices") feed.link(href=base_url, rel="self") def feed_entry(notice, url_root): _id = notice.id title = f"{_id}: {notice.title}" description = notice.details published = notice.published notice_path = flask.url_for(".notice", notice_id=notice.id).lstrip("/") link = f"{url_root}{notice_path}" entry = FeedEntry() entry.id(link) entry.title(title) entry.description(description) entry.link(href=link) entry.published(f"{published} UTC") entry.author({"name": "Ubuntu Security Team"}) return entry notices = ( db_session.query(Notice) .order_by(desc(Notice.published)) .limit(10) .all() ) for notice in notices: feed.add_entry(feed_entry(notice, url_root), order="append") payload = feed.atom_str() if feed_type == "atom" else feed.rss_str() return flask.Response(payload, mimetype="text/xml")
def create_feed_container(app): #from feedformatter import Feed feed = FeedGenerator() feed.title(app.config.project) feed.link(href=app.config.feed_base_url) feed.author(dict(name=app.config.feed_author)) feed.description(app.config.feed_description) if app.config.language: feed.language(app.config.language) if app.config.copyright: feed.copyright(app.config.copyright) app.builder.env.feed_feed = feed if not hasattr(app.builder.env, 'feed_items'): app.builder.env.feed_items = {}
def feed(): # Entries are added backwards episodes = Episode.query.order_by(asc(Episode.date)).all() fg = FeedGenerator() fg.load_extension("podcast") fg.title("The Crypto-Mises Podcast") fg.podcast.itunes_author("Satoshi Nakamoto Institute") fg.link(href=url_for("main.index", _external=True), rel="alternate") fg.subtitle("The official podcast of the Satoshi Nakamoto Institute") fg.language("en") fg.copyright("cc-by-sa") fg.podcast.itunes_summary( "Michael Goldstein and Daniel Krawisz of the Satoshi Nakamoto Institute discuss Bitcoin, economics, and cryptography." # noqa ) fg.podcast.itunes_owner("Michael Goldstein", "*****@*****.**") fg.link(href=url_for("podcast.feed", _external=True), rel="self") fg.podcast.itunes_explicit("no") fg.image(url_for("static", filename="img/cryptomises/cmpodcast_144.jpg")) fg.podcast.itunes_image( url_for("static", filename="img/cryptomises/cmpodcast_1440.jpg")) fg.podcast.itunes_category("Technology", "Tech News") for episode in episodes: description = f"""{episode.summary} If you enjoyed this episode, show your support by donating to SNI: {url_for('main.donate', _external=True)}""" enclosure_url = ( f"https://s3.amazonaws.com/nakamotoinstitute/cryptomises/{episode.slug}.mp3" ) fe = fg.add_entry() fe.id(url_for("podcast.detail", slug=episode.slug, _external=True)) fe.title(episode.title) fe.podcast.itunes_summary(description) fe.description(description) fe.podcast.itunes_subtitle(episode.subtitle) fe.podcast.itunes_author("Satoshi Nakamoto Institute") fe.enclosure(enclosure_url, 0, "audio/mpeg") fe.podcast.itunes_duration(episode.duration) fe.pubDate(localize_time(episode.time)) response = make_response(fg.rss_str(encoding="utf-8", pretty=True)) response.headers.set("Content-Type", "application/rss+xml") return response
fg = FeedGenerator() fg.load_extension('podcast') fg.id('https://episodios.depois.cafe') fg.title('Depois do Café Exclusivo') fg.subtitle(podcast_description) fg.author({'name': podcast_author, 'email': podcast_email}) fg.link(href='https://episodios.depois.cafe', rel='alternate') fg.link(href='https://episodios.depois.cafe', rel='self', type='application/rss+xml') fg.logo(podcast_cover) fg.language('pt-BR') fg.generator('https://github.com/lkiesow/python-feedgen') fg.copyright(podcast_author) fg.podcast.itunes_author(podcast_author) fg.podcast.itunes_category('Technology') fg.podcast.itunes_subtitle(podcast_description) fg.podcast.itunes_summary(podcast_description) fg.podcast.itunes_owner(name=podcast_author, email=podcast_email) fg.podcast.itunes_explicit('no') fg.podcast.itunes_image(podcast_cover) for ep_extra in extras: entry = fg.add_entry() entry.title(ep_extra['title']) entry.id(ep_extra['mp3_link']) entry.link(href=ep_extra['mp3_link'], rel='alternate') entry.enclosure(ep_extra['mp3_link'], str(ep_extra['mp3_size']),
RSS = len(args.rss) > 0 TZ = config.get('Common', 'timezone') TWEET = args.tweet SITE = config.get('Common', 'site') if RSS: rssfile = args.rss rsstitle = config.get('RSS', 'rsstitle') fg = FeedGenerator() fg.title(rsstitle) fg.description(config.get('RSS', 'rssdescription')) rsslink = config.get('RSS', 'rsslink') fg.link(href=rsslink, rel='self') rssfeed = fg.rss_str(pretty=True) fg.rss_file(rssfile) fg.copyright(copyright="CC-BY 4.0") rssauthor = {'name': config.get('RSS', 'rssauthorname'), 'email': config.get('RSS', 'rssauthoremail'), } fg.author(author=rssauthor, replace=True) if TWEET: APP_KEY = config.get('Twitter', 'appkey') APP_SECRET = config.get('Twitter', 'appsecret') OAUTH_TOKEN = config.get('Twitter', 'token') OAUTH_TOKEN_SECRET = config.get('Twitter', 'tokensecret') twitter = Twython(APP_KEY, APP_SECRET, OAUTH_TOKEN, OAUTH_TOKEN_SECRET) timezone = pytz.timezone(TZ) today = datetime.now(timezone).date() indir = os.path.join(DATADIR, str(today));
RSS = len(args.rss) > 0 TZ = config.get('Common', 'timezone') TWEET = args.tweet SITE = config.get('Common', 'site') if RSS: rssfile = args.rss rsstitle = config.get('RSS', 'rsstitle') fg = FeedGenerator() fg.title(rsstitle) fg.description(config.get('RSS', 'rssdescription')) rsslink = config.get('RSS', 'rsslink') fg.link(href=rsslink, rel='self') rssfeed = fg.rss_str(pretty=True) fg.rss_file(rssfile) fg.copyright(copyright="CC-BY 4.0") rssauthor = { 'name': config.get('RSS', 'rssauthorname'), 'email': config.get('RSS', 'rssauthoremail'), } fg.author(author=rssauthor, replace=True) if TWEET: APP_KEY = config.get('Twitter', 'appkey') APP_SECRET = config.get('Twitter', 'appsecret') OAUTH_TOKEN = config.get('Twitter', 'token') OAUTH_TOKEN_SECRET = config.get('Twitter', 'tokensecret') twitter = Twython(APP_KEY, APP_SECRET, OAUTH_TOKEN, OAUTH_TOKEN_SECRET) timezone = pytz.timezone(TZ) today = datetime.now(timezone).date() indir = os.path.join(DATADIR, str(today))
from sqlalchemy import desc def print_enc(s): '''Print function compatible with both python2 and python3 accepting strings and byte arrays. ''' print(s.decode('utf-8') if type(s) == type(b'') else s) fg = FeedGenerator() fg.load_extension('podcast') fg.title('The Crypto-Mises Podcast') fg.podcast.itunes_author('Satoshi Nakamoto Institute') fg.link( href='http://nakamotoinstitute.org/', rel='alternate' ) fg.subtitle('The official podcast of the Satoshi Nakamoto Institute') fg.language('en') fg.copyright('cc-by-sa') fg.podcast.itunes_summary('Michael Goldstein and Daniel Krawisz of the Satoshi Nakamoto Institute discuss Bitcoin, economics, and cryptography.') fg.podcast.itunes_owner('Michael Goldstein', '*****@*****.**') fg.link( href='http://nakamotoinstitute.org/podcast/feed/', rel='self' ) fg.podcast.itunes_explicit('no') fg.image('http://nakamotoinstitute.org/static/img/cryptomises/cmpodcast_144.jpg') fg.podcast.itunes_image('http://nakamotoinstitute.org/static/img/cryptomises/cmpodcast_1440.jpg') fg.podcast.itunes_category('Technology', 'Tech News') eps = Episode.query.order_by(desc(Episode.date)).all() for ep in eps: fe = fg.add_entry() fe.id('http://nakamotoinstitute/podcast/'+ep.slug+'/') fe.title(ep.title)
def print_enc(s): ''' Print function compatible with both python2 and python3 accepting strings and byte arrays. ''' print(s.decode('utf-8') if type(s) == type(b'') else s) fg = FeedGenerator() fg.load_extension('podcast') fg.title('The Crypto-Mises Podcast') fg.podcast.itunes_author('Satoshi Nakamoto Institute') fg.link(href='http://nakamotoinstitute.org/', rel='alternate') fg.subtitle('The official podcast of the Satoshi Nakamoto Institute') fg.language('en') fg.copyright('cc-by-sa') fg.podcast.itunes_summary('Michael Goldstein and Daniel Krawisz of the Satoshi Nakamoto Institute discuss Bitcoin, economics, and cryptography.') fg.podcast.itunes_owner('Michael Goldstein', '*****@*****.**') fg.link(href='http://nakamotoinstitute.org/podcast/feed/', rel='self') fg.podcast.itunes_explicit('no') fg.image('http://nakamotoinstitute.org/static/img/cryptomises/cmpodcast_144.jpg') fg.podcast.itunes_image('http://nakamotoinstitute.org/static/img/cryptomises/cmpodcast_1440.jpg') fg.podcast.itunes_category('Technology', 'Tech News') eps = Episode.query.order_by(desc(Episode.date)).all() for ep in eps: fe = fg.add_entry() fe.id('http://nakamotoinstitute/podcast/'+ep.slug+'/') fe.title(ep.title)
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 = '*****@*****.**' 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 = '*****@*****.**' 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 = '*****@*****.**' 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
return stat.st_birthtime except AttributeError: return stat.st_mtime fg = FeedGenerator() fg.load_extension('podcast') fg.language('pl') fg.podcast.itunes_explicit('no') if (len(sys.argv) > 1 and sys.argv[1] == '3'): fg.title(u'Trójka') fg.podcast.itunes_author(u'Trójka') fg.link(href='https://www.polskieradio.pl/9,Trojka', rel='alternate') fg.subtitle(u'Nieoficjalny podcast Trójki') fg.copyright('cc-by-PolskieRadio') fg.podcast.itunes_summary(u'Podcast Trójki') fg.image('https://www.simx.mobi/trojka/trojka.jpg') fg.podcast.itunes_image('https://www.simx.mobi/trojka/trojka.jpg') fg.podcast.itunes_category('International', 'Polish') url = u'https://www.simx.mobi/trojka/' else: fg.title(u'Weszło FM') fg.podcast.itunes_author(u'Weszło FM') fg.link(href='http://weszlo.fm/', rel='alternate') fg.subtitle(u'Nieoficjalny podcast WeszłoFM') fg.copyright('cc-by-Weszlo') fg.podcast.itunes_summary(u'Podcast WeszłoFM') fg.podcast.itunes_owner('Krzysztof Stanowski', '*****@*****.**') fg.image('https://i1.sndcdn.com/avatars-000421118988-38c4cq-t200x200.jpg')
else: stat = os.stat(path_to_file) try: return stat.st_birthtime except AttributeError: return stat.st_mtime fg = FeedGenerator() fg.load_extension('podcast') fg.title(u'Weszło FM') fg.podcast.itunes_author(u'Weszło FM') fg.link(href='http://weszlo.fm/', rel='alternate') fg.subtitle(u'Nieoficjalny podcast WeszłoFM') fg.language('pl') fg.copyright('cc-by-Weszlo') fg.podcast.itunes_summary(u'Podcast WeszłoFM') fg.podcast.itunes_owner('Krzysztof Stanowski', '*****@*****.**') fg.link(href='https://www.simx.mobi/weszlo/', rel='self') fg.podcast.itunes_explicit('no') fg.image('https://i1.sndcdn.com/avatars-000421118988-38c4cq-t200x200.jpg') fg.podcast.itunes_image( 'https://i1.sndcdn.com/avatars-000421118988-38c4cq-t200x200.jpg') fg.podcast.itunes_category('Sport', 'Sport News') root_path = os.getcwd() + "/" only_folders_from_root_path = [ f for f in listdir(root_path) if isdir(join(root_path, f)) ]
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 = '*****@*****.**' 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 = '*****@*****.**' 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 = '*****@*****.**' 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