aboutsummaryrefslogtreecommitdiff
path: root/pyaggr3g470r
diff options
context:
space:
mode:
authorCédric Bonhomme <cedric@cedricbonhomme.org>2014-02-09 21:22:33 +0100
committerCédric Bonhomme <cedric@cedricbonhomme.org>2014-02-09 21:22:33 +0100
commitcd403ee877f2121d8bd3454ac670df50e635cd81 (patch)
tree7480af27dee603385b95d6463ec26a5e8e4edf89 /pyaggr3g470r
parentIt is now possible to import OPML files. (diff)
downloadnewspipe-cd403ee877f2121d8bd3454ac670df50e635cd81.tar.gz
newspipe-cd403ee877f2121d8bd3454ac670df50e635cd81.tar.bz2
newspipe-cd403ee877f2121d8bd3454ac670df50e635cd81.zip
Improvements to the OPML importer.
Diffstat (limited to 'pyaggr3g470r')
-rwxr-xr-x[-rw-r--r--]pyaggr3g470r/initialization.py0
-rw-r--r--pyaggr3g470r/templates/feed.html12
-rwxr-xr-xpyaggr3g470r/utils.py33
-rw-r--r--pyaggr3g470r/views.py4
4 files changed, 39 insertions, 10 deletions
diff --git a/pyaggr3g470r/initialization.py b/pyaggr3g470r/initialization.py
index 15e83563..15e83563 100644..100755
--- a/pyaggr3g470r/initialization.py
+++ b/pyaggr3g470r/initialization.py
diff --git a/pyaggr3g470r/templates/feed.html b/pyaggr3g470r/templates/feed.html
index 0af94ef4..95465170 100644
--- a/pyaggr3g470r/templates/feed.html
+++ b/pyaggr3g470r/templates/feed.html
@@ -10,9 +10,15 @@
<div class="jumbotron">
<p>
This feed contains {{ feed.articles|count }} <a href="/articles/{{ feed.oid }}/100">articles</a>
- ({{ ((feed.articles|count * 100 ) / nb_articles) | round(2, 'floor') }}% of the database).<br />
- Address of the feed: <a href="{{ feed.link }}">{{ feed.link }}</a>.<br />
- Address of the site: <a href="{{ feed.site_link }}">{{ feed.site_link }}</a>.<br />
+ {% if nb_articles != 0 %}
+ ({{ ((feed.articles|count * 100 ) / nb_articles) | round(2, 'floor') }}% of the database)
+ {% endif %}
+ .<br />
+ Address of the feed: <a href="{{ feed.link }}">{{ feed.link }}</a><br />
+ {% if feed.site_link != "" %}
+ Address of the site: <a href="{{ feed.site_link }}">{{ feed.site_link }}</a>
+ {% endif %}
+ <br />
{% if feed.articles|count != 0 %}
The last article was posted {{ elapsed.days }} day(s) ago.<br />
Daily average: {{ average }}, between the {{ first_post_date.strftime('%Y-%m-%d') }} and the {{ end_post_date.strftime('%Y-%m-%d') }}.
diff --git a/pyaggr3g470r/utils.py b/pyaggr3g470r/utils.py
index 0b112615..4d65f14c 100755
--- a/pyaggr3g470r/utils.py
+++ b/pyaggr3g470r/utils.py
@@ -82,11 +82,34 @@ def import_opml(email, opml_file):
except Exception as e:
raise e
for subscription in subscriptions:
- existing_feed = [feed for feed in user.feeds if feed.link == subscription.xmlUrl]
- if len(existing_feed) == 0:
- new_feed = models.Feed(title=subscription.title, description=subscription.description, link=subscription.xmlUrl, \
- site_link=subscription.htmlUrl, email=False, enabled=True)
- user.feeds.append(new_feed)
+
+ try:
+ title = subscription.text
+ except:
+ title = ""
+ print title
+ try:
+ description = subscription.description
+ except:
+ description = ""
+
+ try:
+ link = subscription.xmlUrl
+ except:
+ continue
+
+ existing_feed = [feed for feed in user.feeds if feed.link == link]
+ if len(existing_feed) != 0:
+ continue
+
+ try:
+ site_link = subscription.htmlUrl
+ except:
+ site_link = ""
+
+ new_feed = models.Feed(title=title, description=description, link=link, site_link=site_link, email=False, enabled=True)
+ user.feeds.append(new_feed)
+
user.save()
def open_url(url):
diff --git a/pyaggr3g470r/views.py b/pyaggr3g470r/views.py
index c8616d60..03ade91c 100644
--- a/pyaggr3g470r/views.py
+++ b/pyaggr3g470r/views.py
@@ -384,8 +384,8 @@ def management():
try:
utils.import_opml(g.user.email, opml_path)
flash("New feeds imported", "success")
- except:
- flash("Impossible to import the new feeds.", "danger")
+ except Exception as e:
+ flash("Impossible to import the new feeds."+str(e), "danger")
form = AddFeedForm()
bgstack15