|
|
|
from feedparser import parse
|
|
|
|
from csvparser.csvparser import getfieldsofinterest, getfullpublication
|
|
|
|
|
|
|
|
feed = parse("http://varia.zone/en/feeds/all-en.rss.xml")
|
|
|
|
|
|
|
|
|
|
|
|
def getentries():
|
|
|
|
entries = {}
|
|
|
|
for entry in feed.entries:
|
|
|
|
if "readrepair" in entry.category:
|
|
|
|
entries[entry.title] = []
|
|
|
|
entrylist = entries[entry.title]
|
|
|
|
entrylist.append(entry.description)
|
|
|
|
entrylist.append(rabbithole(entry))
|
|
|
|
return entries
|
|
|
|
|
|
|
|
|
|
|
|
def getlatestevent():
|
|
|
|
for entry in feed.entries:
|
|
|
|
if "readrepair" in entry.category:
|
|
|
|
return entry
|
|
|
|
|
|
|
|
|
|
|
|
def gettitles():
|
|
|
|
titles = []
|
|
|
|
for entry in feed.entries:
|
|
|
|
if "readrepair" in entry.category:
|
|
|
|
titles.append(entry.title)
|
|
|
|
return titles
|
|
|
|
|
|
|
|
|
|
|
|
def rabbithole(entry):
|
|
|
|
pubtitles = {}
|
|
|
|
fieldsofinterest = getfieldsofinterest()
|
|
|
|
categories = [t.get('term') for t in entry.tags]
|
|
|
|
for id, fields in fieldsofinterest.items():
|
|
|
|
if [f for f in fields if(f.lower().strip() in categories.lower())]:
|
|
|
|
# print("book found")
|
|
|
|
publicationinfo = getfullpublication(id)
|
|
|
|
fulltitle = "{0} - {1}".format(
|
|
|
|
publicationinfo["Author"], publicationinfo["Title"])
|
|
|
|
pubtitles[id] = fulltitle
|
|
|
|
return pubtitles
|
|
|
|
|
|
|
|
|
|
|
|
def getevents():
|
|
|
|
events = getentries()
|
|
|
|
return events
|