aboutsummaryrefslogtreecommitdiff
path: root/pyaggr3g470r/lib/article_utils.py
diff options
context:
space:
mode:
authorCédric Bonhomme <cedric@cedricbonhomme.org>2015-07-06 23:24:01 +0200
committerCédric Bonhomme <cedric@cedricbonhomme.org>2015-07-06 23:24:01 +0200
commit2c1629e5974195899411da73e3b601dad5c24a3e (patch)
tree3cf8c10e2eb99bdfb2c95fb3a0ebdcf8b887d1fc /pyaggr3g470r/lib/article_utils.py
parentUpdated translations. (diff)
parentMerged in jaesivsm/pyaggr3g470r (pull request #17) (diff)
downloadnewspipe-2c1629e5974195899411da73e3b601dad5c24a3e.tar.gz
newspipe-2c1629e5974195899411da73e3b601dad5c24a3e.tar.bz2
newspipe-2c1629e5974195899411da73e3b601dad5c24a3e.zip
Merge branch 'master' of bitbucket.org:cedricbonhomme/pyaggr3g470r
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