async def create_entry(article): heading = article.select_one(".main-article-heading-box") entry = FeedEntry() entry.id(heading.select_one("a").get("href")) entry.link(href=heading.select_one("a").get("href")) entry.title(" / ".join(s.text for s in heading.select("span"))) name = article.select_one(".main-article-author-box a").text.strip() entry.author({"name": name}) entry.summary(article.select_one(".perex-lim").text.strip()) date = article.select_one(".main-article-author-box small").text.strip() date = datetime.strptime(date, "%d.%m.%Y, %H:%M") entry.published(date.replace(tzinfo=timezone.utc)) return entry
def rss_entries(links, feed=None): entries = [] for link in links: fe = FeedEntry() fe.title(link.title) fe.content(link.text) fe.summary("Post by {} in {}.".format( link.user.name, feed.name if feed else link.feed.name)) fe.link(href=link.url) fe.published(link.created_at) fe.comments(link.url) fe.author(name=link.user.name) entries.append(fe) return entries
def make_entry(f, yargs, html): """Construct a (datetime, FeedEntry)...""" from feedgen.entry import FeedEntry uri = yargs.feed_link + (str(f.parent) + "/").replace("./", "") + str( f.stem) + ".html" print(uri) title = str(f.stem).replace('_', ' ').title() updated = datetime.datetime.fromtimestamp(os.path.getmtime(f), datetime.timezone.utc) # anything YAML based to get better metadata goes here too, I suppose y = getyaml(f) print(y) if "title" in y: title = y["title"] e = FeedEntry() e.link(href=uri) e.id(uri) e.content(html) e.updated(updated) e.title(title) if "date" in y: d = y["date"] # anything other than the below is super messy e.published( datetime.datetime(d.year, d.month, d.day, tzinfo=datetime.timezone.utc)) if "keywords" in y: for k in y["keywords"]: e.category(category={'term': k, 'scheme': '', 'label': k}) if "subtitle" in y: # close enough e.summary(y["subtitle"]) if "abstract" in y: # but this is even better, if it exists e.summary(y["abstract"]) return (updated, e)