setting for all feeds, change the value in the \fB[DEFAULT]\fR
section. To override a setting for a particular feed, add that
setting to the feed-specific section. Here is an example overriding
-\fBuse-publisher-email\fR and \fBfriendly-name\fR for the
+\fBuse-publisher-email\fR and \fBname-format\fR for the
\fBfeedname\fR feed.
.P
.RS 4
from = user@rss2email.invalid
force-from = False
use-publisher-email = False
-friendly-name = True
+name-format = '{feed-title}: {author}'
.\|.\|.
verbose = warning
[feed.feedname]
url = http://feed.url/somewhere.rss
use-publisher-email = True
-friendly-name = False
+name-format = '{author} ({feed.title})'
.RE
.P
.SH FILES
# True: Use the publisher's email if you can't find the author's.
# False: Just use the 'from' email instead.
('use-publisher-email', str(False)),
- # Only use the feed email address rather than friendly name
- # plus email address
- ('friendly-name', str(True)),
+ # If empty, only use the feed email address rather than
+ # friendly name plus email address. Available attributes may
+ # include 'feed', 'feed-title', 'author', and 'publisher', but
+ # only 'feed' is guaranteed.
+ ('name-format', '{feed-title}: {author}'),
# Set this to default To email addresses.
('to', ''),
'digest',
'force_from',
'use_publisher_email',
- 'friendly_name',
'active',
'date_header',
'trust_guid',
... '</feed>\\n'
... )
>>> entry = parsed.entries[0]
- >>> f.friendly_name = False
+ >>> f.name_format = ''
>>> f._get_entry_name(parsed, entry)
''
- >>> f.friendly_name = True
+ >>> f.name_format = '{author}'
>>> f._get_entry_name(parsed, entry)
'Example author'
+ >>> f.name_format = '{feed-title}: {author}'
+ >>> f._get_entry_name(parsed, entry)
+ ': Example author'
+ >>> f.name_format = '{author} ({feed.name})'
+ >>> f._get_entry_name(parsed, entry)
+ 'Example author (test-feed)'
"""
- if not self.friendly_name:
+ if not self.name_format:
return ''
- parts = ['']
+ data = {'feed': self}
feed = parsed.feed
- parts.append(feed.get('title', ''))
+ data['feed-title'] = feed.get('title', '')
for x in [entry, feed]:
if 'name' in x.get('author_detail', []):
if x.author_detail.name:
- if ''.join(parts):
- parts.append(': ')
- parts.append(x.author_detail.name)
+ data['author'] = x.author_detail.name
break
- if not ''.join(parts) and self.use_publisher_email:
- if 'name' in feed.get('publisher_detail', []):
- if ''.join(parts):
- parts.append(': ')
- parts.append(feed.publisher_detail.name)
- return _html2text.unescape(''.join(parts))
+ if 'name' in feed.get('publisher_detail', []):
+ data['publisher'] = feed.publisher_detail.name
+ name = self.name_format.format(**data)
+ return _html2text.unescape(name)
def _validate_email(self, email, default=None):
"""Do a basic quality check on email address