From d4867b6627d04076da0b12e3cf0df624ef7dbbc8 Mon Sep 17 00:00:00 2001 From: Oleg Lavrovsky Date: Fri, 17 Nov 2017 17:22:09 +0100 Subject: [PATCH] Improve stream content parsing --- feedler/feedparser.py | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/feedler/feedparser.py b/feedler/feedparser.py index 4fb8827..1c44d87 100644 --- a/feedler/feedparser.py +++ b/feedler/feedparser.py @@ -37,18 +37,20 @@ def parse(obj, raw, stream): obj.visual = '' # Collect text in nested JSON content - if 'content' in obj.raw: - obj.content = obj.raw['content'] + if 'summary' in obj.raw: + if 'content' in obj.raw['summary']: + obj.content = obj.raw['summary']['content'] + else: + obj.content = obj.raw['summary'] + elif 'content' in obj.raw: + if 'content' in obj.raw['content']: + obj.content = obj.raw['content']['content'] + else: + obj.content = obj.raw['content'] elif 'fullContent' in obj.raw: obj.content = obj.raw['fullContent'] else: - if 'summary' in obj.raw: - if 'content' in obj.raw['summary']: - obj.content = obj.raw['summary']['content'] - else: - obj.content = obj.raw['summary'] - else: - obj.content = '' + obj.content = '' # Detect language try: