aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--pyaggr3g470r/lib/utils.py9
-rw-r--r--pyaggr3g470r/views/feed.py7
2 files changed, 8 insertions, 8 deletions
diff --git a/pyaggr3g470r/lib/utils.py b/pyaggr3g470r/lib/utils.py
index 041a2d29..6d6725c8 100644
--- a/pyaggr3g470r/lib/utils.py
+++ b/pyaggr3g470r/lib/utils.py
@@ -77,7 +77,7 @@ def construct_feed_from(url=None, fp_parsed=None, feed=None, query_site=True):
response = requests.get(feed['site_link'], verify=False)
bs_parsed = BeautifulSoup(response.content, 'html.parser',
- parse_only=SoupStrainer('head'))
+ parse_only=SoupStrainer('head'))
if not feed.get('title'):
try:
@@ -115,9 +115,8 @@ def construct_feed_from(url=None, fp_parsed=None, feed=None, query_site=True):
alternate = bs_parsed.find_all(check_keys(rel=['alternate'],
type=['application/rss+xml']))
if len(alternate) == 1:
- feed['link'] = rebuild_url(alternate[0].attrs['href'], split)
+ feed['link'] = alternate[0].attrs['href']
elif len(alternate) > 1:
- feed['link'] = rebuild_url(alternate[0].attrs['href'], split)
- feed['other_link'] = [rebuild_url(al.attrs['href'], split)
- for al in alternate[1:]]
+ feed['link'] = alternate[0].attrs['href']
+ feed['other_link'] = [al.attrs['href'] for al in alternate[1:]]
return feed
diff --git a/pyaggr3g470r/views/feed.py b/pyaggr3g470r/views/feed.py
index 8bd2f8e9..d31aa212 100644
--- a/pyaggr3g470r/views/feed.py
+++ b/pyaggr3g470r/views/feed.py
@@ -12,6 +12,7 @@ from flask.ext.login import login_required
import conf
from pyaggr3g470r import utils
+from pyaggr3g470r.lib.utils import construct_feed_from
from pyaggr3g470r.forms import AddFeedForm
from pyaggr3g470r.controllers import FeedController, ArticleController
@@ -94,14 +95,14 @@ def bookmarklet():
flash(gettext("Couldn't add feed: url missing."), "error")
raise BadRequest("url is missing")
- existing_feeds = list(feed_contr.read(link=url))
- if existing_feeds:
+ feed_exists = list(feed_contr.read(__or__={'link': url, 'site_link': url}))
+ if feed_exists:
flash(gettext("Couldn't add feed: feed already exists."),
"warning")
return redirect(url_for('feed.form',
feed_id=existing_feeds[0].id))
- feed = feed_contr.create(link=url)
+ feed = feed_contr.create(**construct_feed_from(url))
flash(gettext('Feed was successfully created.'), 'success')
if conf.CRAWLING_METHOD == "classic":
utils.fetch(g.user.id, feed.id)
bgstack15