Instead of writing the URL as the 'text' attribute and ignoring it on
read, we now use the attribute to store the feed name. This avoids
auto-generated feed names on import. From the OPML 2.0 spec [1]:
Subscription lists
...
Required attributes: type, text, xmlUrl. For outline elements whose
type is rss, the text attribute should initially be the top-level
title element in the feed being pointed to, however since it is
user-editable, processors should not depend on it always containing
the title of the feed. xmlUrl is the http address of the feed.
We are not following the 'should' recommendation, but since we have
user-generated titles, I believe that the new usage is appropriate.
It's certainly closer to spec than storing a URL in 'text' :p.
[1]: http://dev.opml.org/spec2.html
Signed-off-by: W. Trevor King <wking@tremily.us>
v3.5 (unreleased)
* Fix html2text configuration (ignored since 2012-10-04).
* Fix opmlexport crash due to orphaned feed data.
+ * Use feed names in OPML 'text' attributes.
v3.4 (2013-05-14)
* Added post-processing hooks for user-specified message manipulation.
for feed in new_feeds:
if feed.hasAttribute('xmlUrl'):
url = _saxutils.unescape(feed.getAttribute('xmlUrl'))
- feed = feeds.new_feed(url=url)
+ name = None
+ if feed.hasAttribute('text'):
+ text = _saxutils.unescape(feed.getAttribute('text'))
+ if text != url:
+ name = text
+ feed = feeds.new_feed(name=name, url=url)
_LOG.info('add new feed {}'.format(feed))
feeds.save()
if not feed.url:
_LOG.debug('dropping {}'.format(feed))
continue
+ name = _saxutils.escape(feed.name)
url = _saxutils.escape(feed.url)
- f.write('<outline type="rss" text="{0}" xmlUrl="{0}"/>'.format(url))
+ f.write('<outline type="rss" text="{}" xmlUrl="{}"/>'.format(
+ name, url))
f.write(
'</body>\n'
'</opml>\n')