[DRE-maint] Bug#824382: feed2imap: script to export OPML from configuration

Antoine Beaupre anarcat at debian.org
Thu Aug 31 01:20:59 UTC 2017


Control: forwarded -1 https://github.com/feed2imap/feed2imap/pull/22
Control: tags -1 +patch

On Sun, May 15, 2016 at 04:20:28PM +0800, Paul Wise wrote:
> Package: feed2imap
> Version: 1.2.5-1
> Severity: wishlist
> File: /usr/bin/feed2imap-opmlexport
> 
> rss2email has an option to export OPML from the configuration.
> Since OPML is the standard interchange format for RSS feed reader
> configuration it would be nice if feed2imap could allow export to OPML
> for people who want to switch to a different feed reading system.

I wrote one, attached.

It's in Python, unfortunately, but if you're going to migrate to
rss2email, you'll need that anyways.

A.
-------------- next part --------------
#!/usr/bin/python

from __future__ import division, absolute_import
from __future__ import print_function, unicode_literals


from datetime import datetime
import fileinput


from xml.sax.saxutils import escape
import yaml


def main():
    buf = ''
    for line in fileinput.input():
        buf += line.decode('utf-8')
    feeds = yaml.load(buf)
    body = ''
    xml_tmpl = '''<opml version="1.0">
  <head>
    <title>{title}</title>
    <dateModified>{date}</dateModified>
  </head>
  <body>
{body}</body>
</opml>'''
    outline_tmpl = '<outline title="{name}" type="rss" xmlUrl="{url}" />'
    for feed in feeds['feeds']:
        body += outline_tmpl.format(name=escape(feed['name']),
                                    url=escape(feed['url'])) + "\n"
    output = xml_tmpl.format(title='feed2imap RSS feeds',
                             date=datetime.now(),
                             body=body).encode('utf-8')
    print(output)


if __name__ == '__main__':
    main()
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 488 bytes
Desc: not available
URL: <http://lists.alioth.debian.org/pipermail/pkg-ruby-extras-maintainers/attachments/20170830/27c2df2a/attachment.sig>


More information about the Pkg-ruby-extras-maintainers mailing list