fbfeed + sectionreset

This commit is contained in:
Andreas Stephanides
2017-01-15 14:43:02 +01:00
parent 449a278d58
commit f475364213
7 changed files with 95 additions and 36 deletions

View File

@@ -6,9 +6,7 @@ from datetime import datetime
import re
import urlparse
from src import clogger, cfg
from src.fb import graph
from fixing import fix_link
from facebook import GraphAPIError
import feedparser
#from fetching import downloadfile
@@ -26,7 +24,7 @@ def do_compile(tpe, cont):
return cont
from comp import rssfeed
from comp import fbfeed
def dummyarticle(url, raw):
return {"url": url, "article":{"url": url, "section": "dummysection", "sourcetype": "dummy", "title":"dummytitle", "text": raw, "image": "fff", "author": "me", "published": None}}
@@ -213,33 +211,6 @@ def fsbizindex(url, raw):
def fbfeed(url, raw):
js = json.loads(raw)
arts=[]
u=urlparse.urlparse(url)
for m in js["data"]:
aa={}
aa["url"]=urlparse.urlunsplit(("http","www.facebook.at",m["id"],"",""))
aa["published"] =parse(m["created_time"])
if m.has_key("message")==True:
aa["text"] = m["message"]
else:
try:
h=graph.get_object(id=m["id"].split("_")[1])
if h.has_key("description"):
aa["text"]=h["description"]
else:
aa["text"]=json.dumps()
except GraphAPIError:
aa["text"]=""
if m.has_key("story")==True:
aa["title"] = m["story"]
else:
aa["title"] = u[1]+ " at " + aa["published"].strftime("%Y-%m-%d %H:%M")
aa["section"]="Facebook: "+u[1]
arts.append(aa)
return {"url": url, "next_page": js["paging"]["next"],"articles": arts}
def fsmbindex(url, raw):
if raw is None:
raise Error