2021-01-10 00:07:22 +01:00
|
|
|
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:
|
2021-02-06 17:08:07 +01:00
|
|
|
if "readrepair" in entry.category:
|
2021-02-14 19:34:50 +01:00
|
|
|
entries[entry.title] = []
|
|
|
|
entrylist = entries[entry.title]
|
|
|
|
entrylist.append(entry.description)
|
|
|
|
entrylist.append(rabbithole(entry))
|
2021-01-10 00:07:22 +01:00
|
|
|
return entries
|
|
|
|
|
|
|
|
|
2021-02-14 22:11:58 +01:00
|
|
|
def getlatestevent():
|
|
|
|
for entry in feed.entries:
|
|
|
|
if "readrepair" in entry.category:
|
2021-05-23 22:52:54 +02:00
|
|
|
entry[entry.title] = []
|
|
|
|
entrylist = entry[entry.title]
|
|
|
|
entrylist.append(entry.description)
|
2021-02-14 22:11:58 +01:00
|
|
|
return entry
|
|
|
|
|
|
|
|
|
2021-01-10 00:07:22 +01:00
|
|
|
def gettitles():
|
|
|
|
titles = []
|
|
|
|
for entry in feed.entries:
|
2021-02-06 17:08:07 +01:00
|
|
|
if "readrepair" in entry.category:
|
2021-01-10 00:07:22 +01:00
|
|
|
titles.append(entry.title)
|
|
|
|
return titles
|
|
|
|
|
|
|
|
|
2021-02-06 17:08:07 +01:00
|
|
|
def rabbithole(entry):
|
2021-02-14 19:34:50 +01:00
|
|
|
pubtitles = {}
|
2021-01-10 00:07:22 +01:00
|
|
|
fieldsofinterest = getfieldsofinterest()
|
2021-05-23 22:52:54 +02:00
|
|
|
categories = [t.get('term').lower() for t in entry.tags]
|
2021-02-06 17:08:07 +01:00
|
|
|
for id, fields in fieldsofinterest.items():
|
2021-05-23 22:52:54 +02:00
|
|
|
if [f for f in fields if(f.strip().lower() in categories)]:
|
2021-02-14 19:34:50 +01:00
|
|
|
# print("book found")
|
2021-02-06 17:08:07 +01:00
|
|
|
publicationinfo = getfullpublication(id)
|
2021-02-14 19:34:50 +01:00
|
|
|
fulltitle = "{0} - {1}".format(
|
|
|
|
publicationinfo["Author"], publicationinfo["Title"])
|
|
|
|
pubtitles[id] = fulltitle
|
|
|
|
return pubtitles
|
2021-02-06 17:08:07 +01:00
|
|
|
|
|
|
|
|
|
|
|
def getevents():
|
|
|
|
events = getentries()
|
|
|
|
return events
|