コード例 #1
0
ファイル: rss.py プロジェクト: lmergner/contrivers
 def create_generator(self):
     """ Setup and return a feedgen generator object """
     fg = FeedGenerator()
     fg.title(self.title)
     fg.id(self.root_url)
     fg.link(href=self.root_url, rel='alternate')
     fg.language(u'en')
     fg.description(self.description)
     fg.rights(u"Copyright Contrivers' Review {}".format(datetime.datetime.now().year))
     return fg
コード例 #2
0
def _generate_feed(feed, feeds_config, atom_path):
    utcnow = arrow.utcnow()
    fg = FeedGenerator()
    fg.title(feeds_config['feeds'][feed]['title'])
    fg.id(_build_tag_uri('2015-12-12', feed, utcnow, feeds_config, atom_path))
    fg.language('en-ca')
    fg.author(name='Salish Sea MEOPAR Project',
              uri=f'https://{feeds_config["domain"]}/')
    fg.rights(f'Copyright 2015-{utcnow.year}, Salish Sea MEOPAR Project '
              f'Contributors and The University of British Columbia')
    fg.link(href=(f'https://{feeds_config["domain"]}/{atom_path}/{feed}'),
            rel='self',
            type='application/atom+xml')
    fg.link(href=f'https://{feeds_config["domain"]}/storm-surge/forecast.html',
            rel='related',
            type='text/html')
    return fg
コード例 #3
0
def _generate_feed(feed, feeds_config, atom_path):
    utcnow = arrow.utcnow()
    fg = FeedGenerator()
    fg.title(feeds_config["feeds"][feed]["title"])
    fg.id(_build_tag_uri("2015-12-12", feed, utcnow, feeds_config, atom_path))
    fg.language("en-ca")
    fg.author(
        name="Salish Sea MEOPAR Project", uri=f'https://{feeds_config["domain"]}/'
    )
    fg.rights(
        f"Copyright 2015-{utcnow.year}, Salish Sea MEOPAR Project "
        f"Contributors and The University of British Columbia"
    )
    fg.link(
        href=(f'https://{feeds_config["domain"]}/{atom_path}/{feed}'),
        rel="self",
        type="application/atom+xml",
    )
    fg.link(
        href=f'https://{feeds_config["domain"]}/storm-surge/forecast.html',
        rel="related",
        type="text/html",
    )
    return fg
コード例 #4
0
ファイル: __main__.py プロジェクト: shon/python-feedgen
		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':'*****@*****.**'} )
	fg.link( href='http://example.com', rel='alternate' )
	fg.category(term='test')
	fg.contributor( name='Lars Kiesow', email='*****@*****.**' )
	fg.contributor( name='John Doe', email='*****@*****.**' )
	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('Lorem ipsum dolor sit amet, consectetur adipiscing elit...')
	fe.link( href='http://example.com', rel='alternate' )
	fe.author( name='Lars Kiesow', email='*****@*****.**' )
コード例 #5
0
ファイル: __main__.py プロジェクト: jnaulty/python-feedgen
        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": "*****@*****.**"})
    fg.link(href="http://example.com", rel="alternate")
    fg.category(term="test")
    fg.contributor(name="Lars Kiesow", email="*****@*****.**")
    fg.contributor(name="John Doe", email="*****@*****.**")
    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…")
コード例 #6
0
ファイル: org2podcast.py プロジェクト: amoblin/tools
nodelist = Orgnode.makelist(sys.argv[1])

info = nodelist[0]
properties = info.Properties()
fg.podcast.itunes_category('Technology', 'Podcasting')

fg.title(info.Heading())
fg.author( {'name':properties['author'],'email':properties['email']} )
fg.id(properties["id"])
fg.link( href='http://whoomin.marboo.biz', rel='alternate' )
fg.logo(properties["logo"])
fg.subtitle(properties["subtitle"])
fg.link(href=properties["link"], rel='self' )
fg.language(properties["language"])
fg.image(properties["image"], height="140", width="140")
fg.rights(properties["copyright"])
fg.podcast.itunes_author(properties["author"])
fg.podcast.itunes_subtitle(properties["subtitle"])
fg.podcast.itunes_summary(properties["summary"])
#fg.podcast.itunes_keywords(properties["keywords"])
#fg.ttl(1440)

for i in range(1, len(nodelist)):
    node = nodelist[i]
    if node.Todo() == "DRAFT":
        continue
    mp3_length = "1024"
    fe = fg.add_entry()

    title = node.Heading()
    category = {"term": node.Tag(), "scheme":"", "label":""}
コード例 #7
0
ファイル: __main__.py プロジェクト: lkiesow/python-feedgen
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': '*****@*****.**'})
    fg.link(href='http://example.com', rel='alternate')
    fg.category(term='test')
    fg.contributor(name='Lars Kiesow', email='*****@*****.**')
    fg.contributor(name='John Doe', email='*****@*****.**')
    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='*****@*****.**')

    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', '*****@*****.**')
        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)
コード例 #8
0
def generateRSS(type="", username=""):
    if type not in ["rss", "atom"]:
        raise ValueError(
            'Wrong Type of RSS Feed given to the generator, only "rss" and "atom" accepted.'
        )

    try:
        user = FeedUser.objects.get(username=username)
    except ObjectDoesNotExist:
        raise ValueError("The requested user ['" + username +
                         "'] doesn't exist.")

    try:
        max_rss_posts = int(
            Option.objects.get(parameter="max_rss_posts").value)
    except ObjectDoesNotExist:
        raise ValueError("The Option 'max_rss_posts' doesn't exist.")

    ########## ======================================== FEED GENERATION =========================================== ##########

    fg = FeedGenerator()
    fg.id('https://www.feedcrunch.io/@' + username + '/')
    fg.title('Feedcrunch.IO - @' + user.username + " - " + user.rss_feed_title)
    fg.subtitle(user.description)

    fg.link(href="https://www.feedcrunch.io/", rel='alternate')
    if type == "rss":
        fg.link(href='https://www.feedcrunch.io/@' + username + '/rss/',
                rel='self',
                type="application/rss+xml")
    else:
        fg.link(href='https://www.feedcrunch.io/@' + username + '/atom/',
                rel='self',
                type="application/atom+xml")

    fg.logo('https://www.feedcrunch.io/static/images/favicon.png')
    fg.icon('https://www.feedcrunch.io/static/images/favicon.png')

    for interest in user.interests.all():
        fg.category(term=interest.name)

    fg.language("en-us")
    fg.rights('cc-by')
    fg.author({'name': user.get_full_name(), 'email': user.email})

    last_post_date = Post.objects.filter(
        user=user.username).order_by("-when")[:1][0].when
    fg.lastBuildDate(last_post_date)

    # ======== Adding Posts to the Feed ======== #

    listPosts = Post.objects.filter(
        user=username, activeLink=True).order_by('-id')[:max_rss_posts]

    for post in listPosts:
        fe = fg.add_entry()
        #fe.id(post.link)
        fe.id('https://www.feedcrunch.io/@' + username + '/redirect/' +
              str(post.id))
        fe.title(post.title)
        fe.summary(post.title)
        """
        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.''', type="CDATA")
        """

        fe.link(href='https://www.feedcrunch.io/@' + username + '/redirect/' +
                str(post.id),
                rel='alternate')
        fe.author({'name': user.get_full_name(), 'email': user.email})
        fe.updated(post.when)

        #fe.category([{'term' : 'category', 'scheme': 'http://www.somedomain.com/category', 'label' : 'Category'}])
        for tag in post.tags.all():
            fe.category([{'term': tag.name}])

    return fg