From 616fcaf0bcea380b6ff1e5639d301e0170c53297 Mon Sep 17 00:00:00 2001 From: yodha8 <104330897+yodha8@users.noreply.github.com> Date: Sun, 1 May 2022 07:35:32 -0700 Subject: [PATCH] Add IEEE Spectrum Magazine recipe --- recipes/ieee_spectrum_mag.recipe | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 recipes/ieee_spectrum_mag.recipe diff --git a/recipes/ieee_spectrum_mag.recipe b/recipes/ieee_spectrum_mag.recipe new file mode 100644 index 0000000000..0a1893334e --- /dev/null +++ b/recipes/ieee_spectrum_mag.recipe @@ -0,0 +1,29 @@ +#!/usr/bin/env python +# vim:fileencoding=utf-8 + +from calibre.web.feeds.news import BasicNewsRecipe +import datetime + +class IEEESpectrumMagazine(BasicNewsRecipe): + title = "IEEE Spectrum Magazine" + description = "Published on day 1 of every month." + oldest_article = 120 # Mag gathers articles published older than a month online. So we scan for 4 months in the feed. + max_articles_per_feed = 100 + auto_cleanup = True + + # RSS feed for the current month + now = datetime.datetime.now() + year_month = now.strftime("%Y/%B").lower() + month_feed_url = "https://spectrum.ieee.org/feeds/magazine/{}.rss".format(year_month) + + feeds = [ + ('IEEE Spectrum Magazine', month_feed_url), + ] + + def get_cover_url(self): + """Go to this month's URL and pull cover image from there.""" + month_url = "https://spectrum.ieee.org/magazine/{}".format(self.year_month) + soup = self.index_to_soup(month_url) + img_meta = soup.find("meta", property="og:image") + img_url = img_meta["content"] + return img_url