aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--newspipe/controllers/feed.py3
-rw-r--r--newspipe/lib/data.py4
-rw-r--r--newspipe/lib/feed_utils.py3
3 files changed, 10 insertions, 0 deletions
diff --git a/newspipe/controllers/feed.py b/newspipe/controllers/feed.py
index 0f3f03e7..8a1b6b0b 100644
--- a/newspipe/controllers/feed.py
+++ b/newspipe/controllers/feed.py
@@ -88,6 +88,9 @@ class FeedController(AbstractController):
icon_contr.create(**{"url": attrs["icon_url"]})
def create(self, **attrs):
+ assert (
+ 'link' in attrs
+ ), "A feed must have a link."
self._ensure_icon(attrs)
return super().create(**attrs)
diff --git a/newspipe/lib/data.py b/newspipe/lib/data.py
index a335d040..d2698c8a 100644
--- a/newspipe/lib/data.py
+++ b/newspipe/lib/data.py
@@ -112,6 +112,8 @@ def import_json(nickname, json_content):
nb_feeds, nb_articles = 0, 0
# Create feeds:
for feed in json_account:
+ if 'link' not in feed.keys() or feed['link'] is None:
+ continue
if (
None
!= Feed.query.filter(
@@ -132,6 +134,8 @@ def import_json(nickname, json_content):
db.session.commit()
# Create articles:
for feed in json_account:
+ if 'link' not in feed.keys() or feed['link'] is None:
+ continue
user_feed = Feed.query.filter(
Feed.user_id == user.id, Feed.link == feed["link"]
).first()
diff --git a/newspipe/lib/feed_utils.py b/newspipe/lib/feed_utils.py
index 0de78580..6a072329 100644
--- a/newspipe/lib/feed_utils.py
+++ b/newspipe/lib/feed_utils.py
@@ -140,4 +140,7 @@ def construct_feed_from(url=None, fp_parsed=None, feed=None, query_site=True):
if len(alternates) >= 1:
feed["link"] = rebuild_url(alternates[0].attrs["href"], feed_split)
break
+ else:
+ assert feed.get("link", None) is not None
+
return feed
bgstack15