mirror of
https://github.com/samuelclay/NewsBlur.git
synced 2025-04-13 09:42:01 +00:00
OPML import: Using custom feed titles if they don't match what's in the feed DB.
This commit is contained in:
parent
0f0bb2e92c
commit
57ebbb0790
2 changed files with 14 additions and 2 deletions
|
@ -116,8 +116,15 @@ class OPMLImporter(Importer):
|
|||
feed = item
|
||||
if not hasattr(feed, 'htmlUrl'):
|
||||
setattr(feed, 'htmlUrl', None)
|
||||
if not hasattr(feed, 'title') or not feed.title:
|
||||
# If feed title matches what's in the DB, don't override it on subscription.
|
||||
feed_title = getattr(feed, 'title', None) or getattr(feed, 'text', None)
|
||||
if not feed_title:
|
||||
setattr(feed, 'title', feed.htmlUrl or feed.xmlUrl)
|
||||
user_feed_title = None
|
||||
else:
|
||||
setattr(feed, 'title', feed_title)
|
||||
user_feed_title = feed.title
|
||||
|
||||
feed_address = urlnorm.normalize(feed.xmlUrl)
|
||||
feed_link = urlnorm.normalize(feed.htmlUrl)
|
||||
if len(feed_address) > Feed._meta.get_field('feed_address').max_length:
|
||||
|
@ -139,6 +146,9 @@ class OPMLImporter(Importer):
|
|||
feed_link=feed_link,
|
||||
defaults=dict(**feed_data))
|
||||
|
||||
if user_feed_title == feed_db.feed_title:
|
||||
user_feed_title = None
|
||||
|
||||
us, _ = UserSubscription.objects.get_or_create(
|
||||
feed=feed_db,
|
||||
user=self.user,
|
||||
|
@ -146,6 +156,7 @@ class OPMLImporter(Importer):
|
|||
'needs_unread_recalc': True,
|
||||
'mark_read_date': datetime.datetime.utcnow() - datetime.timedelta(days=1),
|
||||
'active': self.user.profile.is_premium,
|
||||
'user_title': user_feed_title
|
||||
}
|
||||
)
|
||||
if self.user.profile.is_premium and not us.active:
|
||||
|
|
|
@ -18,6 +18,7 @@ NEWSBLUR_URL = 'http://www.newsblur.com'
|
|||
# ==================
|
||||
|
||||
DEBUG = True
|
||||
DEBUG_ASSETS = DEBUG
|
||||
MEDIA_URL = '/media/'
|
||||
SECRET_KEY = 'YOUR SECRET KEY'
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue