aboutsummaryrefslogtreecommitdiff
path: root/pyaggr3g470r/lib/article_utils.py
diff options
context:
space:
mode:
authorCédric Bonhomme <kimble.mandel+bitbucket@gmail.com>2015-07-06 23:22:59 +0200
committerCédric Bonhomme <kimble.mandel+bitbucket@gmail.com>2015-07-06 23:22:59 +0200
commit2676d9881593f03142bd790ae5603c07e99c1adf (patch)
tree8f12fe10f1c79b6e036c09f44902f83f76940e6f /pyaggr3g470r/lib/article_utils.py
parentMinor fixes from a quick review. Need to test deeper. (diff)
parentmaking it possible for super admin to update other's feed (diff)
downloadnewspipe-2676d9881593f03142bd790ae5603c07e99c1adf.tar.gz
newspipe-2676d9881593f03142bd790ae5603c07e99c1adf.tar.bz2
newspipe-2676d9881593f03142bd790ae5603c07e99c1adf.zip
Merged in jaesivsm/pyaggr3g470r (pull request #17)
sorry, another pull request in a very short delay
Diffstat (limited to 'pyaggr3g470r/lib/article_utils.py')
-rw-r--r--pyaggr3g470r/lib/article_utils.py14
1 files changed, 8 insertions, 6 deletions
diff --git a/pyaggr3g470r/lib/article_utils.py b/pyaggr3g470r/lib/article_utils.py
index 3c642167..115b6058 100644
--- a/pyaggr3g470r/lib/article_utils.py
+++ b/pyaggr3g470r/lib/article_utils.py
@@ -35,8 +35,10 @@ def extract_id(entry, keys=[('link', 'link'),
def construct_article(entry, feed):
+ if hasattr(feed, 'dump'): # this way can be a sqlalchemy obj or a dict
+ feed = feed.dump()
"Safe method to transorm a feedparser entry into an article"
- now = datetime.now()
+ date = datetime.now()
for date_key in ('published', 'updated'):
if entry.get(date_key):
@@ -63,12 +65,12 @@ def construct_article(entry, feed):
logger.warning("Unable to get the real URL of %s. Error: %s",
article_link, error)
- return {'feed_id': feed.id,
- 'user_id': feed.user_id,
+ return {'feed_id': feed['id'],
+ 'user_id': feed['user_id'],
'entry_id': extract_id(entry).get('entry_id', None),
- 'link': entry.get('link', feed.site_link),
+ 'link': entry.get('link', feed['site_link']),
'title': entry.get('title', 'No title'),
'readed': False, 'like': False,
'content': content,
- 'retrieved_date': now.isoformat(),
- 'date': (date or now).isoformat()}
+ 'retrieved_date': date.isoformat(),
+ 'date': date.isoformat()}
bgstack15