Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

now also able to return feed info from a feed url. quite useful for A…

…PI that don't want to bother and just get a user entered url
  • Loading branch information...
commit f5faaa31507dda51f5a59ac06eb49dd55f3cdc14 1 parent 0df650e
@julien51 julien51 authored
View
BIN  extractlinks.pyc
Binary file not shown
View
3,900 feedparser.py
3,900 additions, 0 deletions not shown
View
BIN  feedparser.pyc
Binary file not shown
View
12 main.py
@@ -29,6 +29,8 @@
import extractlinks
from extractlinks import LinkExtractor
+import feedparser
+import re
class MainHandler(webapp.RequestHandler):
@@ -53,9 +55,17 @@ def get(self):
parser.set_base_url(site_url)
parser.feed(result.content)
feeds = parser.links
+ if not feeds:
+ # Let's check if by any chance this is actually not a feed?
+ data = feedparser.parse(result.content)
+ mimeType = "application/atom+xml"
+ href = site_url
+ if re.match("atom", data.version):
+ mimeType = "application/atom+xml"
+ feeds = [{'title': data.feed.title, 'rel': 'self', 'type': mimeType, 'href': href}]
+
if not memcache.add(site_url, feeds, 604800):
logging.error("Memcache set failed.")
-
self.render_json(feeds)
except:
self.render_json([])
Please sign in to comment.
Something went wrong with that request. Please try again.