Add IEEE Spectrum Magazine recipe

This commit is contained in:
yodha8 2022-05-01 07:35:32 -07:00 committed by GitHub
parent 1a7c1ba809
commit 616fcaf0bc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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